This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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?
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 / AmazonAmazon UK )
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!