File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Custom GUI look and feel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Custom GUI look and feel" Watch "Custom GUI look and feel" New topic

Custom GUI look and feel

Evan Pierce
Ranch Hand

Joined: Jan 31, 2006
Posts: 36
im trying to create a custom look and feel from my java applications. i want to beable to tell java what all my forms and buttons and check boxs, and waht not, look like. anyone know of any good tutorials on making a completly custom look to swing componets?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

I don't think I've ever seen a tutorial on building a L&F; it's not for the faint of heart, I think.

I'm going to move this to our "Swing, AWT, etc" forum, where perhaps someone will have more information.
[ July 22, 2006: Message edited by: Ernest Friedman-Hill ]

[Jess in Action][AskingGoodQuestions]
Charles Lyons
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
I did some work with PLAF (Pluggable Look and Feel) some time ago; this should still be relevant. Basically, I got started with it simply by looking through the API and trying to piece the puzzle together. To proceed you need to be confident with 2D graphics and the Swing API.

The package you'll be mainly working from is javax.swing.plaf, although you might find some of the others (javax.swing.plaf.basic etc.) useful for reference and as a guide.

Let's take the ButtonUI as an example. Essentially, the name of the game is to extend the class to add painting behaviour - all UI components on screen are only a collection of coloured pixels, so to create a new button UI you'll need to specify in the paint() method the code required to draw the button. Each time the UI is invoked, you're supplied with the original JComponent for which that UI applies. This allows you to make decisions based on whether the button is depressed, hovered over etc., and to render it as appropriate.

This is a big job, and there are a lot of factors to take into account. I think a few books on Swing/2D graphics may cover the basics, but PLAF isn't widely used so it tends to be largely ignored. My best advice is to work on one component at a time, and think about subclassing components in javax.swing.plaf.basic to get started, only overriding the methods you wish to change. You'll need a good design strategy and probably need to do some calculations/design work/measurements up-front.

Feel free to ask any further questions...

Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Some interesting links you might want to look into:

article on creating a custom LAF

article on the Synth LAF in Java 5

Quaqua, a LAF for OS X, may be interesting to study
Adam Nace
Ranch Hand

Joined: Jul 17, 2006
Posts: 117
this is not an easy topic to learn, and I've never really found a good tutorial on the topic. there are a few articles you could look into:

  • A Swing Architecture Overview - Gives you a good idea of how the PLAF architecture works
  • Creating a Custom Look and Feel - This was suggested by another responder. I found this article, once, too, when I was trying to learn to create a custom look and feel. This article is more like a case study that an instruction, so it will indicate some of the problems encountered, and the decisions made, but won't tell you how to make everything work right.
  • This Page has SOME relevant material to UI delegates
  • This Page gives you a great reference on how defaults tables can be set up and used. (hint, this will help you make your own ui components that will use a palette similar to the native operating system).
  • Painting in AWT and Swing provides some info on how the UI delegate works with painting, as well as telling you a LOT of other things you should know about paiting in swing.
  • ComponentUI provides a detailed description of what each method in a UI Delegate SHOULD do. This is about as close as you're going to get to a tutorial. You should take note of what it says that installUI should do. That method should handle creating sub-components, and should also handle creating the event listeners that will control the way the component looks.
  • You're going to want to read this and this and this to learn how to draw with Java 2D.
  • this explains how to design effective look and feels (specifically button graphics for the java look and feel, but useful in other circumstances too).
  • The Java Look And Feel Guidelines are designed to instruct EXACTLY how to emulate the java look and feel. However, there are TONES of tidbits in there on how to effectively design look and feels for cross-platform applications. If you get into compound components, definitely look into the layout and spacing guidelines.
  • If you're targeting a specific OS, then you should google for that OS's look and feel guidelines. That's important!
  • Use a color palette generator for coming up with your color palettes if you choose not to use the ones provided by the OS. Try or or

  • hope this all helps you out.

    I agree. Here's the link:
    subject: Custom GUI look and feel
    It's not a secret anymore!