October 2005 Archives

Halloween Comes to Bath

| No Comments | No TrackBacks
~ Halloween ~ I'm suddenly finding myself very busy as always - along with being tired. (The trains have been unreliable, and it's almost as bad as being stuck in traffic, but at least it is less stressful...) Where are all the trick-or-treaters in Bath? I *did* see a jack-o-lantern the other evening. No ghosts, though!

Over the past couple of months, I have been creating my own custom Java look-and-feel (LAF) using Synth. By default, Synth applies the style to an element (JButton, JLabel, JFrame) throughout the application. However, it is often necessary to have an additional style type for an element in the application. For example, I wanted to have a default style for the main application window as well as a different style for the 'wizard'. Most of the elements in the main application used the default font and J-object styles, but I wanted the wizard to have a gradient background colour and section header fonts that were different to the rest of the application.

 

To create a new style, include a new style in the Synth XML document, as displayed below.

 

- <style id="WizardBg">
  <object id="background" class="com.ssl.cctv.tvbs.oif.gui.swing.skin.BackgroundPainter" />
- <object class="javax.swing.plaf.ColorUIResource" id="startColor">
  <int>108</int>
  <int>171</int>
  <int>221</int>
  </object>
  <defaultsProperty key="Panel.startBackground" type="idref" value="startColor" />
- <object class="javax.swing.plaf.ColorUIResource" id="endColor">
  <int>184</int>
  <int>196</int>
  <int>197</int>
  </object>
  <defaultsProperty key="Panel.endBackground" type="idref" value="endColor" />
  <painter method="panelBackground" idref="background" />
  </style>
  <bind style="WizardBg" type="name" key="wizardPanel" />

 

In the 'bind' tag, the type should be defined as 'name' to specify that all elements accepting this style will be bound through the name attribute instead of 'region' which allows all elements of a certain type to be bound to the style. The 'key' attribute in the 'bind' tag will be the name of the element as defined in the Java code. To apply this style to the element, use the myobject.setName("myname") attribute in the Java code. In this example above, the name of the element will be the 'key' attribute in the 'bind' tag: 'wizardPanel'.

 

If you're a web developer, think of this as a little bit like CSS where you define a style of an element (a font or a DIV) and reference it.

 

Finally, ensure that all styles with 'named' bindings are located at the end of the XML document so that this style is not overwritten by the default style.

Juice Vodka Bath and Shower

| No Comments | No TrackBacks

I was looking at some gifts for the holidays in BHS and spotted some really nice bath products - shower gels that look like small bottles of Vodka. These came in different 'flavours' and came in packs of three. I got the green and a set of pink ones. These will look great in a bathroom on the side of a bath. I only have a dirty shared bathroom where I currently am without a bath, so I'll keep these until I've moved into a nicer place where I can use them.

juicevodkashower.jpg

Java Look-and-Feel with 'Synth'

| No Comments | No TrackBacks

I have been experimenting with developing a custom look-and-feel for a large-scale Java project that I am working on. The custom look-and-feel is in Synth, which loads an XML file defining the styles (and images) for each defined element. Essentially, it really acts like a skin on top of the existing Java Swing interface. Documentation on this is pretty scarce and not in-depth, and I have picked up a lot of inconsistencies and bugs on the way.

In theory, each component consists of different states, such as DEFAULT, MOUSE_OVER, DISABLED, PRESSED, FOCUSED, SELECTED, and ENABLED. (To use more than one state for a style, use the AND keyword between them.) Insets are defined to determine how much space is needed on each side of the element; sourceInsets are used to prevent the area from being stretched. The 'bind style' element is provided to set the defined style. (To determine the key, programmers need to look at Java documentation, which is appended to the end of this entry.) An example of a button element Synth style is below:

<style id="buttonStyle">

   <insets top="15" left="20" right="20" bottom="15"/>

   <state>

      <imagePainter method="buttonBackground" path="images/button.png" sourceInsets="10 10 10 10"/>

   </state>

</style>

<bind style="buttonStyle" type="region" key="button"/>


Another important note is that each Java Swing element may inherit attributes from other Java Swing elements. For example, a JList is also made up of a JLabel. This opens up several annoying inconsistencies that I have had to work through with little documentation. The more complex the Swing component, the more likely it inherits from several different Swing components, which will need to be restyled. A range of different components can also be used per component, depending on the state of the component. 

Another issue with Synth is that once you use it, you need to create a style for every element. Some of these are very in-depth and require a lot of graphical design work. So, if you just want to change all of your buttons to be a certain colour and theme, Synth is not for you. 

Overall, I like the idea of being able to change the visual aspect to suit the branding of the application and to avoid the use of the ugly Java themes. I've also created custom elements to take on their own brand, much like the way web developers do with CSS. For example, the 'wizard' areas of the application I am developing contain a different theme with a background colour, and the headings are the same style. I simply code the application to use this style when the Swing elements are set up.

In my opinion, there is a major problem with the use of Synth. Not so long ago and before CSS was used, websites suffered from the similar problem. The problem with Synth is that most programmers cannot create good graphics, and most graphical artists cannot program. This is one area where, I believe, Synth has failed. Because of this, there are very few good designs based on the Synth look-and-feel. The introduction of CSS for web development made creating good designs easily and without the need for programming and nesting tables. There are also several tools that enable web designs to be quickly implemented into CSS, and there's nothing similar in the world of Java. 
 
Another issue with Synth is the lack of documentation. There is limited documentation on the Java Sun website, and the documentation is incomplete. Resources that do exist and will provide some help with developing styles in Synth are listed below.
 

Synth Component Properties: http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/synth/doc-files/componentProperties.html

Synth File Format:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/synth/doc-files/synthFileFormat.html

Synth: The Region Class:
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/synth/Region.html

Disappointment with Trains

| No Comments | No TrackBacks
I got soaked walking back home from the train station tonight. (My shoes won't be dry for the morning!) I don't know what has been wrong with the trains in the past six weeks. Delays. Cancellations. It just isn't good when you wake up to get on the 8:00 train and it's delayed, so you miss your connection and have to wait at train station for 20 minutes for your second train. The Aardman's warehouse in Bristol, which is near the train tracks going into the station from Bath Spa, was still smoking this morning from the fire on Monday. It is a pity.

Java Application Aesthetics

| No Comments | No TrackBacks

I am currently working on a large-scale Java project as the User Interface Programmer in charge of the graphical user interface. In Java, the layout and aesthetics of an application is known as look-and-feel (LAF). I have had some time on my hands so instead of using the standard Java LAF, I have decided to create my own custom LAF based on the client's branding.

 

A few developers (including those at Sun) have developed new LAFs for users who want to get away from the default Java LAF. Two of these popular LAFs are known as 'Metal' and 'Ocean', and there are other ones based on the Windows or Mac operating system LAF. For what I had in mind, these LAFs are not much better than the default Java LAF and could not be tweaked to create the LAF that I wanted to use. In order to get a unique non-Java-looking application, I would need to create my own custom LAF.

 

In my search to find a relevant LAF to use, I came across a new framework which allows developers to create their own LAFs. This custom look-and-feel framework in Java is known as Synth, and code for the framework is written to load an XML file defining the styles (and images) for each defined element (JButton, JLabel, JFrame, etc). Essentially, the Synth framework acts as a skin for the existing Java Swing interface.

 

Although the Synth LAF framework seems to be a useful way to create a custom LAF, there is a lack of detailed documentation and examples to get started. I also think that in order to create a custom LAF using Synth, the developer must also have graphic design skills. Perhaps it is for this reason that few examples of LAFs created with Synth exist.

 

Although there is a lack of examples and documentation on the subject, I plan to continue learning about Synth to see how far I get with my custom LAF. If it all fails and there are too many bugs to finish before the project officially kicks off, then I will simply go back to using the default LAF or one of the other popular ones.

Autumn Days

| No Comments | No TrackBacks
~Autumn Days ~ The leaves are starting to change their colours even more as the mornings and nights get colder. The squirrels are still busy packing away nuts/buckeyes from the trees lining the park and burying them in the ground. Amazingly, a patch of flowers in front of the Royal Crescent looks as beautiful as ever, yet unharmed by the frost and cold.

Night Out in Bristol

| No Comments | No TrackBacks
Went to a large club in Bristol last night. Packed with students. I did not enjoy waiting in the queue just to get inside. (It was a 2.5 hour wait.) I've been to better places. I don't enjoy crowds. Give me a gathering with a few close friends anyday, minus loud and smokey places. A smaller venue or a pub would have been nice, even if it did not offer 'themed' drinking rooms.

Friends Visit

| No Comments | No TrackBacks

I have just had a 'house-warming' party / get-together with a couple of friends over the weekend here in Bath. It was nice, and the weather was nice for the time of year it is. I am settling in. 

Archives

Recent Comments

  • jenn: Thank you. read more
  • Murge: Amazing post. read more
  • Herbert: good post. site read more
  • Frank Quake: Hey, This is great when you said that I had read more
  • Chappy: You mention peptides here? I have had first hand experience read more
  • jenn: Thanks! I love the work. I have got more recent read more
  • Fanakapan: Thanks for the write up. This was some of my read more
  • jenn: Yes.... but that's only for the islands. Mostar and Montenegro read more
  • jenn: Hello, the code is not mine to hand out. I'll read more
  • pantich: More info about the best day trips from Dubrovnik can read more
OpenID accepted here Learn more about OpenID