Results 1 to 3 of 3
- 11-01-2009, 01:16 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 1
- Rep Power
- 0
Not able to display icon with JCheckBox
So this is a snippet code I am using:
class BarPanel extends JPanel {
URL iconURL = Test.class.getResource("caper.jpg");
ImageIcon caper = new ImageIcon(iconURL);
JCheckBox check1 = new JCheckBox("Check 1", caper,true);
public BarPanel() {
setLayout(new FlowLayout());
add(check1);
}
}
The image shows up fine but I can't see a checkbox, only the image icon with the Label. If I define the JCheckBox instance without an icon, the checkbox appears just fine.
Any help would be appreciated.
-
Are you trying to shove this panel into too small a location? Without a small compilable program that demonstrates your problem, it's going to be difficult to tell what you're doing wrong.
- 11-01-2009, 03:19 AM #3
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
The check box is an Icon, so when you use the setIcon method you are actually replacing the existing icon.
Darryl's Toggle Button Icons solution might be what you are looking for.
Similar Threads
-
JCheckbox in Jtree
By shajuantony in forum AWT / SwingReplies: 10Last Post: 09-09-2009, 10:42 AM -
can java program display icon on unix?
By java2008 in forum Advanced JavaReplies: 1Last Post: 10-06-2008, 07:33 AM -
Issue with Jcheckbox on JTableheader
By ram_76uk in forum AWT / SwingReplies: 2Last Post: 07-30-2008, 08:24 AM -
Can we add JCheckBox array into JTextArea?
By nancyhung in forum AWT / SwingReplies: 1Last Post: 02-17-2008, 12:07 AM -
jcheckbox issues need help. thanks.
By carlos123 in forum New To JavaReplies: 3Last Post: 11-05-2007, 10:37 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks