• Post Reply Bookmark Topic Watch Topic
  • New Topic

Open a new JFrame from the main JFrame  RSS feed

 
Roberto De Giuli
Greenhorn
Posts: 17
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have the following problem: I need to open a JFrame (ConfigUI) from the main JFrame (ApplicationUI), when, for example, I push a button in the ApplicationUI.
The first thing I thought to do is to instance a new ConfigUI in the ActionPerformed method of the button and run the new JFrame.
I don't know if it is the raccomended way to do it and any suggestion is appreciated.

On the other hand, when the ConfigUI JFrame is showed, the focus should be locked on it and it should be impossibile to access the ApplicationUI until the ConfigUI is opened. I have no idea on how to do it and, once again, any suggestion is strongly appreciated.

One last thing: what I really need is a book/tutorial on simple and advanced Swing programming. Thanks for any kind of help!
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberto De Giuli wrote:when the ConfigUI JFrame is showed, the focus should be locked on it and it should be impossibile to access the ApplicationUI until the ConfigUI is opened.

I presume you mean closed.

You need a modal JDialog, not a second JFrame. For almost all GUI applications, there shouldn't be more than one JFrame.

Check out the Oracle tutorial on How to Make Dialogs.
 
Roberto De Giuli
Greenhorn
Posts: 17
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:
Roberto De Giuli wrote:when the ConfigUI JFrame is showed, the focus should be locked on it and it should be impossibile to access the ApplicationUI until the ConfigUI is opened.

I presume you mean closed.

You need a modal JDialog, not a second JFrame. For almost all GUI applications, there shouldn't be more than one JFrame.

Check out the Oracle tutorial on How to Make Dialogs.


Thank you very much Darryl!
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!