Results 1 to 5 of 5
  1. #1
    ntagrafix's Avatar
    ntagrafix is offline Member
    Join Date
    Nov 2009
    Location
    Denmark
    Posts
    29
    Rep Power
    0

    Question Show/Hide Label with JToggleButton

    Hi guys,

    I am working on a Guitar chord programe in NetBeans 6.7.1 IDE

    I want to use JToggleButton to show and hide a "Mute" label.

    What i actually want is:

    If the JToggleButton is clicked (down), it shows Mute & if clicked (up) again, it hide the Mute label.

    Plz how can i achieve that. I tried using ActionListener() but i couldn't do a dime.

    lotta tnx
    Life is not perfect, but the way you live it can make it perfectly wongerful :cool:

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

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

    Default

    Also, for a toggle button, consider using an ItemListener and checking if the ItemEvent's state (via the getStateChange() method) == ItemEvent.SELECTED or ItemEvent.DESELECTED. The Sun button tutorial and the APIs will show you the way.

    If you're still stuck, then show us your code.

  4. #4
    ntagrafix's Avatar
    ntagrafix is offline Member
    Join Date
    Nov 2009
    Location
    Denmark
    Posts
    29
    Rep Power
    0

    Wink Tnx a zillions

    Thanks a lot Fubarable.

    Its worked fine...

    Actually, I wasn't serious about d ItemListener when i saw it before, but now i must thank for your help.


    Cheers ...
    Last edited by ntagrafix; 11-04-2009 at 02:21 AM. Reason: grammer n spelling mistake
    Life is not perfect, but the way you live it can make it perfectly wongerful :cool:

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

    Default

    Glad your code now works. If you haven't familiarized yourself with the Sun Swing tutorials, you owe it to yourself to do so. They're probably the best Swing resource around.

Similar Threads

  1. Cross-Browser Issue with show/hide divs
    By jmchaffie in forum New To Java
    Replies: 3
    Last Post: 03-10-2011, 10:41 AM
  2. How to hide a control in SWT?
    By lottalava in forum SWT / JFace
    Replies: 11
    Last Post: 10-18-2010, 10:52 AM
  3. Resize shell on show/hide controls.
    By spacetoha in forum SWT / JFace
    Replies: 1
    Last Post: 03-24-2009, 01:20 PM
  4. JToggleButton Demonstration
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 08:38 PM
  5. netbeans 6.0 not show commpunent or show blank page
    By fahimaamir in forum NetBeans
    Replies: 1
    Last Post: 01-26-2008, 07:20 AM

Tags for this Thread

Posting Permissions

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