Java GUIDiscussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Java GUI section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
Howdy all. (Edit: I swear I know how to spell disappear)
I have a really simple app I'm trying to get going but, I've hit a wall.
I create a simple empty JFrame and display it. When it is displayed a small JPanel pops up asking you to hit one of two buttons:
"Okay" button to change the background color of the JFrame.contentPane to pink.
"Cancel" button to change nothing.
After either button is pressed I want the JPanel with the buttons to go away.
Currently, I have implemented this JPanel as a seperate class - ButtonPanel.
So, my question is: What can I do within this ButtonPanel to make the ButtonPanel go away? When in the ButtonPanel.actionPerformed(Event) method what can I do to make the ButtonPanel go away and possibly change the background color of the contentPane of the JFrame?
I thought about creating some sort of intermediate class to which I would pass an instance of the ButtonPanel. I would also pass an instance of this intermediate class to the ButtonPanel.
The intermediate class would have a method called "makeButtonPanelGoAway()" which could be called in the actionPerformed method of the ButtonPanel to get rid of the ButtonPanel.
However, I figure someone probably thought of a brighter way of handling this. Could anyone tell me a better way of doing what I want to do?
Thanks everyone. Just tell me if none of it makes sense and I'll try to clarify.
You can use simple option dialog provided in swings [JFC]. Use one of JOptionPane.showConfirmDialog OR JOptionPane.showMessageDialog OR JOptionPane.showOptionDialog
These methods return values referring which button was pressed by the user, you can use this value to decide whether to changes the color or not.