Help with Synth

I am trying to create a look and feel for a small example program to replicate a problem I am having with the synth look and feel with a much larger application.

I am having trouble setting the border for menu items when they are moused over. When I use the imagePainter, and have the method specified as "menuItemBorder", it will not show up. When I leave method out completely it will output the following exception:

Uncaught error fetching image:

java.lang.NullPointerException

at sun.awt.image.URLImageSource.getConnection(URLImageSource.java:97)

at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:107)

at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:240)

at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)

at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)

I need to run this from the command line.

Can anyone help me?

This is urgent!!!

THANK YOU!

The source code I am using is below:

<synth>

<!--

***************************************

BASE STYLE FOR ALL COMPONENTS

***************************************-->

- <!-- Style that all regions will use

-->

- <style id="all">

<opaque value="TRUE" />

<font name="Tahoma" size="11" />

- <state>

<color value="#333333" type="BACKGROUND" />

<color value="#FFFFFF" type="FOREGROUND" />

</state>

</style>

<bind style="all" type="region" key=".*" />

<!--

***************************************

Button

***************************************-->

<style id="button">

<state>

<imagePainter method="buttonBackground" path="button2.png" sourceInsets="5 5 5 5" paintCenter="true"/>

<font name="Tahoma" size="11"/>

<color type="TEXT_FOREGROUND" value="WHITE"/>

</state>

<state value="MOUSE_OVER">

<imagePainter method="buttonBackground" path="button2_over.png" sourceInsets="5 5 5 5" paintCenter="true"/>

</state>

</style>

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

<!--

***************************************

Panel

***************************************-->

<style id="panel">

<state>

<imagePainter path="titleBarBackground.png" sourceInsets="5 5 5 5" paintCenter="false"/>

<font name="Tahoma" size="20"/>

<color type="TEXT_FOREGROUND" value="WHITE"/>

</state>

</style>

<bind style="panel" type="region" key="Panel"/>

<!--

***************************************

Menu

***************************************-->

<style id="menu">

<font name="Tahoma" size="11"/>

<insets top="5" left="5" right="5" bottom="5"/>

<state value="MOUSE_OVER">

<imagePainterpath="border_rollover.png" sourceInsets="1 1 1 1" paintCenter="false"/>

</state>

</style>

<bind style="menu" type="region" key="MenuItem"/>

<bind style="menu" type="region" key="Menu"/>

</synth>

-

The class file is:

package test;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.plaf.synth.SynthLookAndFeel;

import javax.swing.JMenu;

import javax.swing.JMenuItem;

import javax.swing.JMenuBar;

import javax.swing.KeyStroke;

public class Tester {

JFrame jtfMainFrame;

JButton jbnButton1, jbnButton2;

JTextField jtfInput;

JPanel jplPanel;

JMenuBar mainMenuBar;

JMenu menu1;

JMenuItem item1;

public Tester() {

jtfMainFrame = new JFrame("Which Button Demo");

jtfMainFrame.setSize(50, 50);

jbnButton1 = new JButton("Button 1");

jbnButton2 = new JButton("Button 2");

jtfInput = new JTextField(20);

jplPanel = new JPanel();

mainMenuBar = new JMenuBar();

menu1 = new JMenu("Menu 1");

menu1.setMnemonic(KeyEvent.VK_MULTIPLY);

mainMenuBar.add(menu1);

item1 = new JMenuItem("Menu item 1", KeyEvent.VK_T);

item1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1, ActionEvent.ALT_MASK));

//item1.addActionListener(this);

menu1.add(item1);

jbnButton1.setMnemonic(KeyEvent.VK_I);//Set ShortCut Keys

jbnButton1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

jtfInput.setText("Button 1!");

}

});

jbnButton2.setMnemonic(KeyEvent.VK_I);

jbnButton2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

jtfInput.setText("Button 2!");

}

});

jplPanel.setLayout(new FlowLayout());

jplPanel.add(jtfInput);

jplPanel.add(jbnButton1);

jplPanel.add(jbnButton2);

jplPanel.add(mainMenuBar);

jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);

jtfMainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

jtfMainFrame.pack();

jtfMainFrame.setVisible(true);

}

public static void main(String[] args) {

SynthLookAndFeel lookAndFeel = new SynthLookAndFeel();

try {

// SynthLookAndFeel load() method throws a checked exception

// (java.text.ParseException) so it must be handled

lookAndFeel.load(Tester.class.getResourceAsStream("testSynth.xml"), Tester.class);

UIManager.setLookAndFeel(lookAndFeel);

}catch (Exception e) {

System.err.println("Couldn't get specified look and feel (" + lookAndFeel + "), for some reason.");

System.err.println("Using the default look and feel.");

e.printStackTrace();

}

Tester application = new Tester();

}

}

Message was edited by:

pooky136

Message was edited by:

pooky136

[6106 byte] By [pooky136a] at [2007-11-27 7:14:45]
# 1
Figured it out! http://forum.java.sun.com/thread.jspa?forumID=57&threadID=758234
pooky136a at 2007-7-12 19:05:00 > top of Java-index,Desktop,Core GUI APIs...
# 2
Next Problem:Does anyone know how to override the l&f of the system window bar using synth. I have tried everything from toolBar to InternalPane... Nothing seems to work..... Any Suggestions?
pooky136a at 2007-7-12 19:05:00 > top of Java-index,Desktop,Core GUI APIs...