This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Clarification needed for top level containers

 
Geeta Balasubramanian
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Top level containers are listed as - JFrame, JWindow, JDialog, JApplet.

Applets cannot be viewed without a browser or an appletviewer. How are they considered as top level containers?
 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Applets.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know the canonical answer, but perhaps it's because JApplet implements the RootPaneContainer interface.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A "top level container" is a Java term for something that's not embedded inside of another Java GUI object. But just like applets run inside a native launcher (the browser), so do standalone desktop apps (inside the "java" executable).
 
Rob Spoor
Sheriff
Posts: 20827
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But unlike other top level containers, you can add an applet to another container like a JPanel.
 
Fred Hamilton
Ranch Hand
Posts: 684
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf's explanation generally matches my way of thinking about the situation. Just to expand on that a bit...

A JApplet is the Swing browser high level container while JFrame is the desktop high level container, if you design your GUI so that all of the components are defined on a JPanel, then you should be able to use that JPanel within a JFrame or a JApplet interchangeably, with no modifications to the application itself. The JFrame and JApplet classes would just be shells with only a few lines of code each.

Of course there are some functionalities that are meant for Desktop and not JApplet, but in general the above paragraph holds true
 
Geeta Balasubramanian
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!