Results 1 to 5 of 5
- 01-25-2010, 12:57 AM #1
Member
- Join Date
- Jan 2010
- Posts
- 12
- Rep Power
- 0
JButton doesn't disappear when it is supposed to?
Hi guys, sorry for all of the posting lately but I've been working non stop on my program.
The problem for this part of my GUI is that when one button is clicked, another is supposed to show up (which works fine). But when that second button is clicked, it is supposed to disappear (which does not work). Here's the coding.
Java Code:panel5 = new JPanel(); //Panel for getting info on student studentNameLabel2 = new JLabel("Student Info is displayed here"); studentInfo = new JTextArea(); studentInfo.setColumns(40); studentInfo.setLineWrap(true); studentInfo.setRows(36); studentInfo.setWrapStyleWord(true); studentInfo.setEditable(false); studentInfoScroll = new JScrollPane(studentInfo); studentInfoScroll.createVerticalScrollBar(); editStuds = new JButton("Edit Students"); editStuds.addActionListener(this); doneStudEdit = new JButton("Done Editing"); doneStudEdit.setVisible(false); panel5.add(studentNameLabel2); panel5.add(studentInfoScroll); panel5.add(studentInfo); panel5.add(editStuds); panel5.add(doneStudEdit); public void actionPerformed(ActionEvent e) { if (e.getSource() == editStuds) { doneStudEdit.setVisible(true); studentInfo.setEditable(true); if(e.getSource() == doneStudEdit) { doneStudEdit.setVisible(false); studentInfo.setEditable(false); } }
-Ecliptical
-
Do you revalidate and repaint the container?
Other options: keep one button but change the text.
- 01-25-2010, 01:36 AM #3
Member
- Join Date
- Jan 2010
- Posts
- 12
- Rep Power
- 0
Whoops, problem solved. I forgot to add an action listener to the button. Silly mistake.
Thanks for the input though Fubarable!
-
- 01-25-2010, 01:41 AM #5
Member
- Join Date
- Jan 2010
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
Drawing disappear!!!!
By gan5016 in forum Java 2DReplies: 7Last Post: 09-26-2009, 03:58 AM -
Help interpreting what a class is supposed to do
By bornwithnoname in forum New To JavaReplies: 2Last Post: 11-20-2008, 01:19 AM -
How to make a JButton disappear?
By diab01ical in forum New To JavaReplies: 2Last Post: 06-04-2008, 03:48 AM -
Help with JButton
By geoffreybarwise in forum New To JavaReplies: 4Last Post: 05-21-2008, 11:48 AM -
results to code disappear too fast for DOS window
By dubdubdub in forum New To JavaReplies: 3Last Post: 12-29-2007, 06:07 PM
Bookmarks