• Post Reply Bookmark Topic Watch Topic
  • New 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Custom GUI look and feel

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 http://slayeroffice.com/tools/color_palette/ or http://www.colorschemer.com/online.html or http://colorblender.com/



  • hope this all helps you out.

    -Adam
     
    You can't have everything. Where would you put it?
    free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
    reply
      Bookmark Topic Watch Topic
    • New Topic