This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Transfer Learning for Natural Language Processing (MEAP) and have Paul Azunre on-line!
See this thread for details.
Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven
  • Mark post as helpful
  • send pies
  • 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
  •  
    Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
    Two software engineers solve most of the world's problems in one K&R sized book
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
      Bookmark Topic Watch Topic
    • New Topic