p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Java > Other Java > Java GUI
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java GUI Discussions 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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 21st, 2009, 09:32 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get a JPanel to make itself dissapear?

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 5th, 2009, 03:00 AM
Friend of Wrox
Points: 1,108, Level: 13
Points: 1,108, Level: 13 Points: 1,108, Level: 13 Points: 1,108, Level: 13
Activity: 2%
Activity: 2% Activity: 2% Activity: 2%
 
Join Date: Mar 2007
Location: Hyderabad, A.P., India.
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.

check the java documentation of JOptionPane class at bellow link
http://java.sun.com/j2se/1.5.0/docs/...ptionPane.html
__________________
- Rakesh
http://iam-rakesh.blogspot.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing JPanel to Another Class d-mart Java Basics 1 May 29th, 2009 06:50 AM
How to paste a bitmap into a JPanel? AndrewH Java GUI 1 May 1st, 2007 01:19 AM
Can I add a JComboBox twice to the same jpanel david.byrne Java GUI 4 May 14th, 2005 12:42 PM
Some variable dissapear after goin tru 10 pages Monkeycoder Beginning PHP 4 January 5th, 2005 07:46 PM
Dissapear mouse and use key to navigate on web pag karib JSP Basics 0 July 2nd, 2004 01:53 AM



All times are GMT -4. The time now is 12:49 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc