Results 1 to 7 of 7

Thread: toggle button

  1. #1
    gbonecapone is offline Member
    Join Date
    May 2013
    Posts
    68
    Blog Entries
    1
    Rep Power
    0

    Default toggle button

    How do i use a toggle button to make panels visible and not visible?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default Re: toggle button

    Quote Originally Posted by gbonecapone View Post
    How do i use a toggle button to make panels visible and not visible?
    Make the panels (in)visible in the ActionListener registered to the JToggleButton (I forgot whether or not you have to revalidate() the parent component).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    gbonecapone is offline Member
    Join Date
    May 2013
    Posts
    68
    Blog Entries
    1
    Rep Power
    0

    Default Re: toggle button

    i want them to be invisible until i click it. and then disappear when i click it "off". will doing what you said do that?


    this is what i have now. howTap is the panel i want to reveal and hide
    private void tapTogActionPerformed(java.awt.event.ActionEvent evt) {
    tapTog.addActionListener(new ActionListener(){
    @Override
    public void actionPerformed(ActionEvent ev){
    howTap.setVisible(true);

    }

    });

    }

  4. #4
    gbonecapone is offline Member
    Join Date
    May 2013
    Posts
    68
    Blog Entries
    1
    Rep Power
    0

    Default Re: toggle button

    right now the panel is hidden and reveals when i click the toggle on and then off again. but then never goes away.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default Re: toggle button

    Your ActionListener always sets the visibility to true ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    gbonecapone is offline Member
    Join Date
    May 2013
    Posts
    68
    Blog Entries
    1
    Rep Power
    0

    Default Re: toggle button

    how would you recommend changing that?

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,337
    Blog Entries
    7
    Rep Power
    20

    Default Re: toggle button

    Make it visible if the toggle button is in the selected state?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 1
    Last Post: 12-17-2010, 05:01 PM
  2. Toggle Trobble
    By pottsmgg in forum New To Java
    Replies: 22
    Last Post: 09-20-2010, 04:25 PM
  3. Replies: 4
    Last Post: 01-04-2010, 01:23 PM
  4. [SOLVED] Toggle Mouse Left-Right Handed
    By sirwiggles in forum New To Java
    Replies: 4
    Last Post: 04-10-2009, 10:27 PM
  5. Checking toggle state of a menu item
    By xsive in forum SWT / JFace
    Replies: 1
    Last Post: 09-22-2008, 02:42 PM

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
  •