• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

create a new window in a JFrame

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to have a typical JFrame, and then have a menu to open a new "popup" window. I can handle the main frame and the menu, but the new JFrame? I want to be "attached" to the other JFrame.
Examples of these windows are everywhere, I want it to work just like a "Properties box". As it is now, when I click my button a new Frame is created, but it is not attached to the other one. I want the main frame to be disabled (I can do that) when the properties frame comes up, but I would rather it not create a new item in the taskbar. Specifically, I would like for whenever I click on the main frame in the taskbar, the properties window stays on top when it is open.

I hope what I am trying to do is clear...

Eric
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A modal JDialog is exactly what you want.
 
Eric Crockett
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks about right, as long as I can add JTextFields, JLists, JButtons etc to a panel (or just the Dialog itself) then that IS exactly what I want!

I have been messing around with JInternalFrame, any comment on why one would be better than the other?

Thanks
Eric
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Crockett:
That looks about right, as long as I can add JTextFields, JLists, JButtons etc to a panel (or just the Dialog itself) then that IS exactly what I want!


A JDialog behaves exactly the same as a JFrame as far as setting layouts and adding components.

Prior to Java 1.5, you had to get a frame/dialog's content pane using getContentPane(). This Container could then be used to set the layout and add components just as regular containers like JPanel.
In Java 1.5 and up, you can set the layout of the frame/dialog directly, as well as add components. This will basically use the content pane in the background.

So if you already have a panel, you can call dialog.getContentPane().add(panel), or even dialog.setContentPane(panel).

I have been messing around with JInternalFrame, any comment on why one would be better than the other?


JInternalFrame is mostly used inside a JDesktopPane for an MDI environment; the JInternalFrame will not exit the JDesktopPane area. JDialog however can be used anywhere, will be shown on top of its parent frame (or dialog), and can be moved all over the screen.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic