Skip to content
Anthony Christe edited this page Oct 16, 2013 · 6 revisions

GUI Frameworks

  • AWT - basic widgets and windows
  • Swing - provides native look and feel, platform independent, advanced widgets (tabs, scroll panes, tables, trees)
  • JavaFX - rich internet applications across platforms (sound familiar?)
  • SWT - started at IBM, now maintained by Eclipse, non-portable using JNI, better performance?

Building GUIs with Swing

Top Level Containers

  • Using Top Level Containers
  • To appear on screen, every component must be part of a GUI hierarchy
  • Each component can be contained only once
  • Menu bars can be added to top level containers
  • JFrame is generally used as top level container
  • Most of the GUI work is done in children containers such as JPanels

JComponents

  • JComponents are the building blocks of a Swing application
  • Provides UI widgets (buttons, text areas, scroll bars, tabs, menus, trees, progress bars, etc)

JPanels

  • JPanels provide an empty canvas to place JComponents onto
  • It's possible to include as many JPanels in an application as you need
  • JPanels can be embedded into other JPanels
  • JComponents can be added manually to a JPanels by x, y location
  • JComponents can be sized manually on a JPanel
  • But.... it's better to let Swing handle the layout of components, but how?

Layout Managers

  • Let Swing handle the layout of your components
  • Allows for automatic resizing of windows
  • Sub-components can also automatically be resized
  • Visual Guide to Swing Layouts

More Resources

Clone this wiki locally