Sunday 23 October 2011

Java Message Box (Alert Popup)

A simple alternative to printing out messages in the console, this code will popup a message box in Java similar to that of Javascript alert("hello").

The code can be modified to include several types of message box types such as an error icon or different button options. Have a look JOptionPane in the JavaDoc's for more information on these.

Monday 10 October 2011

Java Custom Component - Colored Progress Bar

After getting slightly bored of the standard Java components available to me I decided to spice things up a little. I wanted to be able to have a clean, colourful and customizable progress bar. I also wanted the progress bar to be able to change colour at certain values, such as when it reaches a low percent it will go red.

Essentially I extend JComponent and use paintComponent method which is called automatically by Java to draw the progress bar.