Making Swing feel like Web 2.0

The more people use Web 2.0 application, the more they enjoy the lovely (mostly blue / purple) look-and-feels. The problem is that while you have lovely CSS and loads of images to make a web page look nice, desktop applications look just the same as they always did. So I’ve collected a few tips and tricks to make you Swing applications look really really good.

  1. Look and Feels
    1. JGoodies Plastic – my personal choice
    2. Javootoo Look & Feel – a listing of Swing look-and-feels
  2. The Popup class!
    1. Familiarize yourself with the javax.swing.Popup class
    2. Use it instead of normal modal JDialogs
      1. Don’t overuse it, think carefully about what you put in it
      2. You can’t drag a Popup or minimize it
    3. Can be used instead of ProgressMonitor’s etc.
  3. Borders
    1. Use Compound and Empty borders to pad your content
    2. Use the LineBorder class to create rounded corners
  4. Animating Card Layout
    1. This looks massively cool for toolboxes and the like
  5. Almost every Swing component supports HTML 3.2 as text content
    1. <html>Hello <b>World</b></html> can be put in a JLabel, JButton, JCheckBox, etc. etc. etc.
    2. You don’t need to use a JEditorPane or JTextPane for fancy looking content
  6. Stop thinking static / table layout
    1. You can use setVisible just like you use the “display” attribute in CSS
    2. You can add and delete components (you may need to revalidate() the Container though)
    3. Create your own LayoutManagers if all else fails
  7. ResourceBundles are your friends!
    1. They can be used to hold complex HTML content as well as simple text
    2. Use the java.text.MessageFormat to format your strings
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: