Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Show images on the screen without using JFrame

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 69756
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 21971
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technically there is only one top-level container class: Window. Frame, Dialog and JWindow are subclasses of Window.
 
Campbell Ritchie
Marshal
Posts: 69756
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you're right, Rob. But what about Applets? Don't they count as top-level too?
 
Rob Spoor
Sheriff
Posts: 21971
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 69756
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
Devasia Manuel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well then in that case, how do I take off the tilte bar and the border?
 
Campbell Ritchie
Marshal
Posts: 69756
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21971
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setUndecorated(true) is the other way to do it.
 
Campbell Ritchie
Marshal
Posts: 69756
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that post did mention setUndecorated, but I could remember when it was posted, better than I could remember setUndecorated.
 
There’s no place like 127.0.0.1. But I'll always remember this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic