Results 1 to 5 of 5
- 03-17-2013, 08:55 PM #1
Member
- Join Date
- Mar 2013
- Posts
- 22
- Rep Power
- 0
when i click on Jbutton i want one jpanel to disappear and another to appear
when i click on a button moneyButton, im trying to make it so the timePanel disappears and is replaced by a moneyPanel.
Also before any button is clicked the timePanel is visible. when i click on the timeButton i just made components visible, however i cant do this for the moneyButton hence ive created a new JPanel which i want to make visible. However i cant make this happen.
heres some of my code, msg me if you want to see all of it.
Java Code:JPanel moneyPanel = new JPanel(); moneyPanel.setVisible(true); JComboBox priceairportbox = new JComboBox(Airport); moneyPanel.setBackground(Color.BLUE); moneyPanel.setPreferredSize(new Dimension(320, 240)); moneyPanel.add(priceairportbox); priceairportbox.setVisible(true);
Java Code:actionmoneybutton clicktime = new actionmoneybutton(); moneyButton.addActionListener(clicktime);
Java Code:public class actionmoneybutton implements ActionListener{ public void actionPerformed(ActionEvent clicktime){ timePanel.setVisible(false); moneyPanel.setVisible(true); } }Last edited by beginnerprog; 03-17-2013 at 09:13 PM.
-
Re: when i click on Jbutton i want one jpanel to disappear and another to appear
If this were my project, I'd look into using a CardLayout to help me swap views. For example: Notifying a cardlayout manager from within a custom Panel
Last edited by Fubarable; 03-17-2013 at 09:29 PM.
- 03-18-2013, 09:31 AM #3
Member
- Join Date
- Mar 2013
- Posts
- 22
- Rep Power
- 0
- 03-18-2013, 10:40 AM #4
- 03-18-2013, 04:51 PM #5
Member
- Join Date
- Mar 2013
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
JButton after a click
By tnrh1 in forum AWT / SwingReplies: 9Last Post: 12-09-2011, 12:45 AM -
JButton click
By mine0926 in forum New To JavaReplies: 0Last Post: 07-30-2010, 04:50 AM -
JButton click problem
By mine0926 in forum NetBeansReplies: 7Last Post: 06-11-2010, 03:00 AM -
JButton doesn't disappear when it is supposed to?
By ecliptical in forum New To JavaReplies: 4Last Post: 01-25-2010, 12:41 AM -
How to make a JButton disappear?
By diab01ical in forum New To JavaReplies: 2Last Post: 06-04-2008, 02:48 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks