
Almost every “web 2.0″ application have a cool linear gradient background instead of the plain old boring single color solid background. Adding a gradient background to your application is very simple with only a few lines of additional code. In the example program, I am using Java2D and the GradientPaint class to draw the linear gradient background.
Below is the program that I used to create the image above. We override the paintComponent of the JPanel (or any JComponent) and fill the background with a gradient paint. The begin and end colors for the gradient paint are derived from the component’s background color using the brighter and darker variations.
Using the power of Java2D, I was able to create more advance and stylish borders. Using a combination of a round rectangle and a triangle shape, I created the callout border shown on the left. This is also very similar to the balloon tips on the Windows OS. Decorate a JLabel with a callout border and you got an awesome tooltip replacement.