Results 1 to 3 of 3
- 03-26-2011, 10:58 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
Java exercise I REALLY need help on
Okay last ditch effort. I've done everything my professor wants me to and now I have one last thing to do. I need to display an image when a check box is clicked. I've got my check boxes displayed and I know my image stuff is wrong but I'm so freaking exhausted I can no longer wrap my brain around the stuff. Here's the meat and potatoes of the code for the check boxes and if someone out there in Java Land can help me I will dance at your wedding!
//creating checkboxes
on=new JCheckBox ("ON");
off=new JCheckBox ("OFF");
//image
penguin= new ImageIcon ("ac.jpeg");
//listener
StyleListener listener=new StyleListener ();
on.addItemListener (listener);
off.addItemListener (listener);
//add checkboxes
add (on);
add (off);
}
private class StyleListener implements ItemListener
{
public void itemStateChanged (ItemEvent event)
{
Object source=event.getItemSelectable();
if (on.isSelected());
imageLabel.setIcon (penguin);
}
}
-
But what is your specific question? What are you stuck on? What have you tried that isn't working? What errors are you getting? Understand that we're not going to do this for you, but will be happy to help you figure out how to do it yourself.
- 03-27-2011, 04:02 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 8
- Rep Power
- 0
I guess that would help..whoops! So my check boxes are showing, but I'm not sure of the code I need to use to get the image to display. I'm not getting any errors because I don't think it's going anywhere. Does that make sense? I don't think my listener is "Listening" because the image isn't coded correctly.
Similar Threads
-
finishing up a DB/Java exercise
By hayden06f4i in forum New To JavaReplies: 47Last Post: 12-12-2010, 10:57 PM -
Exercise for java 3d
By armiri in forum Java 2DReplies: 2Last Post: 05-14-2010, 12:14 AM -
Exercise for java 3d
By armiri in forum Java SoftwareReplies: 3Last Post: 05-14-2010, 12:13 AM -
Help needed with Java exercise - Including arrays - Reward
By TheDarkReverend in forum New To JavaReplies: 7Last Post: 10-23-2008, 03:52 AM -
help with exercise
By e_as're in forum New To JavaReplies: 3Last Post: 09-25-2007, 11:14 AM
Bookmarks