I have a JCheckbox
,this is in a JPanel
, that is supposed to show an image in the JPanel
, when you select it. The problem is this: as you can see in the screenshot, the text of the JCheckbox
is difficult to read because of the image.
I was thinking if there was some way to contrast the text to the image, so that the color of the text is the opposite of the image.
I know that there're other ways to fix it, like setting the JCheckbox
outside the image, but I'd have to change design of my program and structure code.
For example, here's how I want it to look:
.
This is all the code that the JCheckBox
currently has, it is something simple:
final JCheckBox INFO_IMG = new JCheckBox("Ver img");
INFO_IMG.setFont(new Font("Dialog", 0, 12));
INFO_IMG.setBounds(-2, 2, 78, 13);
INFO_IMG.setOpaque(false);
INFO_IMG.setFocusable(false);
INFO_IMG.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent ie) {
if (1 == ie.getStateChange()) {
INFO_IMG.setText("Ver info");
IMG.setVisible(true);
/* INFO_IMG.setForegound(ROBOT.getPixelColor(
(int)INFO_IMG.getLocationOnScreen.getX() + 12
,(int) INFO_IMG.getLocationOnScreen().getY() + 10));
This is another way that I had thought of,
although it does not work well,would also have to get
the opposite color from the one return.
*/
} else {
INFO_IMG.setText("Ver img");
IMG.setVisible(false);
}
}
});
add(INFO_IMG);