Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Do Swing Components (but 4) look identical for Operating Systems

 
Jeffry Cray
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've looked all over and investigated alot. But still for some reason I still have one doubt, becuase swings are still vauge to me.
Do all(but 4) swing components "LOOK IDENTICAL" for all OS for the same program. Or are they just consistent (i.e. their image can be customized and will look that they were made for that particulat OS) or both ?
thanks
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both.
They will look very similar (font sizes may vary) on all systems. That is one reason for Swing. Each component handles its own rendering therefore they will be drawn the same on all systems.
You can also force the Swing components to look like Motif, Windows, or Metal on all systems. If you just use Swing components without setting a look-and-feel you will see the Swing default (Metal). You can however force Swing to use Windows look-and-feel which would then draw Windows type components on all systems.
Wow the power of Swing!
Manfred.
 
Jeffry Cray
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Manfred,
Now I'm finally beginning to understand, but what do you mean by Metal and Motif OS .
 
Kaustuv Bhattacharya
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 3 look&feels for the Swing Components,namely, Metal, Motif and Windows. They differ in the looks of the components.
You can use the Java Packages :
1)javax.swing.plaf.metal.MetalLookAndFeel - Metal Look
2)com.sun.java.swing.plaf.motif.MotifLookAndFeel - Motif Look
3)com.sun.java.swing.plaf.windows.WindowsLookAndFeel - Window Look
With Regards,
Kaustuv
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The AWT uses heavyweight components, and Swing uses lightweight components.
Heavyweight components rely on peer functions provided by the underlying operating system, and as such require much more system resources. The Look and Feel is determined by the operating system.
Lightweight components are completely removed from the operating system and rely only on java. They always have the same Look and Feel except when specifically set differently (as described above).
 
Jeffry Cray
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all,
I think know I'm alot more familiar with swings.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic