Results 1 to 6 of 6
  1. #1
    Peter_Aye is offline Member
    Join Date
    Nov 2012
    Location
    Nigeria
    Posts
    4
    Rep Power
    0

    Default Overlying JPanels

    Hello. I am trying to write an application that needs a set of buttons to be hidden, and some other buttons shown, like on top of them, and then, maybe using a JToggle button, to show those hidden buttons when that button is depressed. Would really appreciate the help.

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

    Default Re: Overlying JPanels

    Maybe a CardLayout can do what you want; read its API documentation.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,947
    Rep Power
    19

    Default Re: Overlying JPanels

    Have a JPanel containing one lot of buttons, and another containing the others.
    Add both Panels to whatever container you're using.
    One the toggle, hide one and show the other.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Overlying JPanels

    Moved from Advanced Java. Not an advanced question either.

    CardLayout is the way to go.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Peter_Aye is offline Member
    Join Date
    Nov 2012
    Location
    Nigeria
    Posts
    4
    Rep Power
    0

    Default Re: Overlying JPanels

    Thanks, Jos. I appreciate your help. CardLayout is definitely the way to go, and I have tried implementing it. I have a little challenge, though. I use the Netbeans IDE, and you know the code for the design of the app GUI is automatically generated, and non-editable. I wanted to switch to eclipse, but I have gone far in designing with Netbeans, and it would mean a lot of stress for me to start all over again. The challenge I have is in switching between the JPanels. I implemented the CardLayout with Netbeans, and it works, but I intend to use a JToggleButton to switch between cards, like adding a ChangedState listener to the JToggleButton, and then switching when the JToggleButton is clicked. I tried it this way, but it didn't work.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Overlying JPanels

    The NetBeans visual designer is not a beginners' tool. Until you thoroughly understand Swing coding, it's much easier to hand-code your GUIs.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. JPanels ?
    By santa in forum New To Java
    Replies: 5
    Last Post: 02-25-2012, 07:10 PM
  2. Replies: 2
    Last Post: 04-26-2011, 02:50 PM
  3. Problems regarding JPanels in JPanels
    By ColtonPhillips in forum AWT / Swing
    Replies: 2
    Last Post: 07-19-2010, 08:33 PM
  4. Posistioning Jpanels
    By owain1221 in forum Java Applets
    Replies: 7
    Last Post: 11-15-2009, 11:21 PM
  5. HELP with jPanels
    By maverik_vz in forum AWT / Swing
    Replies: 1
    Last Post: 03-12-2009, 11:46 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
  •