Results 1 to 3 of 3
  1. #1
    velvetymold is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default 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);
    }
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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.

  3. #3
    velvetymold is offline Member
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default

    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

  1. finishing up a DB/Java exercise
    By hayden06f4i in forum New To Java
    Replies: 47
    Last Post: 12-12-2010, 09:57 PM
  2. Exercise for java 3d
    By armiri in forum Java 2D
    Replies: 2
    Last Post: 05-13-2010, 11:14 PM
  3. Exercise for java 3d
    By armiri in forum Java Software
    Replies: 3
    Last Post: 05-13-2010, 11:13 PM
  4. Help needed with Java exercise - Including arrays - Reward
    By TheDarkReverend in forum New To Java
    Replies: 7
    Last Post: 10-23-2008, 02:52 AM
  5. help with exercise
    By e_as're in forum New To Java
    Replies: 3
    Last Post: 09-25-2007, 10:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •