Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User Defined Class Frame Popup 1

Status
Not open for further replies.

Watts

Programmer
Jan 18, 2001
80
US
I have developed a user defined class that extend to the java Frame class. It creates a popup Frame with a simple message and a couple of button inside it. What I want to do is disable everything in the window behind this Frame until the user clicks on one of the buttons and the Frame closes.

Any ideas on how to do this or if it is even possible? Keep in mind that I want the Frame to disable the background window regardless of what is in it. This means that I can not just disable individual controls which would take forever anyways.
 
Maybe you need a JDialog instead a Frame?
You can make a modal JDialog an you don't need to disable components...

Javier
 
That was great! The setModal of that Dialog class is exactly what I needed! But I have another quick question, how do I calculate the screen size so I can center my Dialog on the screen when it pops up?

I know how to use the setBounds and setLocation functions. I just need to know how to find out the Max X & Y so I can calculate the center programmically.
 
Never mind I found it in another post:

Dimension d=Toolkit.getDefaultToolkit().getScreenSize();
centerX=(d.width-dialogWidth)/2;
centerY=(d.height-dialogHeight)/2;
dialog.setLocation(centerX, centerY);

I think I am getting the hang of this stuff!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top