Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
    Bookmark Topic Watch 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
SwingIsAProperNoun - Avoiding a common mistake when referring to Swing in writing or speech.

PreventingEnterFromChangingTheRowInJTable

BackgroundImageOnJPanel

JProgressBarDoesntUpdate

PlotTest - simple example of how to create an X/Y graph; can be changed to use AWT easily

PlotSineCurve - simple example of how to draw a curve; can be changed to use AWT easily

NumericTextField - how to create a text field that only accepts numbers as input

ComponentDoesntUpdatePromptly - Usage of SwingWorker for background tasks


Q. I created a JOptionPane.showConfirmDialog and no matter which button I have focused, when I hit enter, I always get the OK result.

A. Default button behavior is dependent on the Look and Feel you have specified. To get the desired result in Windows, use the Windows Look and Feel for your application.


Q. Why are Swing components called lightweight, while AWT components are heavyweight?

A. Swing components are considered lightweight because they draw themselves and do not rely on native calls to the OS. AWT (And SWT for that matter) make calls to the OS and say "Hey, I need a button" and the OS throws them back a button. Swing uses the Graphics2D API to draw its widgets.

Note that not all components in the javax.swing package are lightweight. Namely, top level containers like JFrame are still considered heavyweight components because they extend java.awt.Frame.

While mixing AWT and Swing used to be fraught with problem, updates to Java 6 and 7 have made that less troublesome. See this article for more information on that.

(The above was posted in a Saloon discussion. Further information can be found in this thread and on jGuru.)


Q. The GridBagLayout class is too complex for my tastes; is anything simpler available?

A. There is indeed. If all you're looking for is a GridLayout with variable row and column sizes, then GridLayout2 may be for you. If you're looking for even more options, check out SGLayout.

JavaDoc:java.awt.GridLayout

JavaDoc:java.awt.GridBagLayout


Links to further information

  • Swing Tutorial
  • The full text of the first edition of Swing is available
  • Article Speed up your Swing GUI construction with better building blocks
  • RSyntaxTextArea, an LGPL-ed syntax highlighting text (editing) component
  • Artcile Translucent and Shaped Swing Windows
  •  
    On top of spaghetti all covered in cheese, there was this tiny ad:
    SKIP - a book about connecting industrious people with elderly land owners
    https://coderanch.com/t/skip-book
      Bookmark Topic Watch Topic
    • New Topic