| Author |
Show images on the screen without using JFrame
|
Devasia Manuel
Ranch Hand
Joined: May 13, 2008
Posts: 57
|
|
I am dying to know how you can show images and swing components on the screen without putting in all in a Jframe first. I know there is a way of doing it, I just dont know how. Thanks --Devasia
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
|
I believe that you have to use some root container but that it doesn't have to be a JFrame. You could use a JDialog, a JOptionPane, or a JWindow. You could set your app to have no "decorations", no titlebar, or resize/exit buttons if desired. I suggest that you study the Sun Swing tutorials for more detail. Good luck.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
|
Pete Stein is correct, but the actual list of top-level containers is (I think) Window Frame Applet and Dialog. Frame includes JFrame (as a subclass) (etc), and what you get from JOptionPane is actually a Dialog.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Technically there is only one top-level container class: Window. Frame, Dialog and JWindow are subclasses of Window.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
|
Yes, you're right, Rob. But what about Applets? Don't they count as top-level too?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
No, they are still in a Frame. I've retrieved it for showing modal dialogs. Of course you should treat Applets as top-level as far as creating components goes (i.e. you don't add it to anything yourself), but it certainly is not a top-level component in the same way as Frame or Dialog are. [ October 23, 2008: Message edited by: Rob Prime ]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
|
Thank you.
|
 |
Devasia Manuel
Ranch Hand
Joined: May 13, 2008
Posts: 57
|
|
|
Well then in that case, how do I take off the tilte bar and the border?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
|
Either use a JWindow or find the thread from the end of March last year about how to take buttons off a JFrame.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
setUndecorated(true) is the other way to do it.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
I think that post did mention setUndecorated, but I could remember when it was posted, better than I could remember setUndecorated.
|
 |
 |
|
|
subject: Show images on the screen without using JFrame
|
|
|