jogl glCanvas and synth

Can anyonbe tell me if a jogl GLCanvas added to a JPanel (in the center) will interfere with the synth skin borders for the JPanel.

I’m trying to get the border to be drawn but when I add the GLCanvas to the center the border nor its insets get used.

The Synth L&F is horribly broken. After some investigation I have concluded that it cannot be used to make a complete working L&F. You are likely running into one of the many Synth bugs.

I know that there are bugs but Sun has recently hird a guy to work on these and develop a full demo and a lot of the bugs have been fixed. Are you sure this is a synth bug or something that jogl does to disable the painting of borders.

I did some tests and it seems that the border is being drawn but the sizing of the GLCanvas is such that it fill up the whole panel right to the edge, over drawing the border. I need to be able to reduce the maximum size of the canvas but setMaximum size, setSize and setPreferredSize don’t work. I can’t extend the GLCanvas so I’m lost. How can I reduce the maximum size of the canvas so it dosen’t draw on top of the border.

Hi John,

I too have been working w/ Synth, but have a much more basic problem than you do. I keep getting the error below about not supplying an InputStream, even though I have supplied one.


Unable to find theme configuration
Exception: You must supply an InputStream;, Class and StyleFactory
java.lang.IllegalArgumentException: You must supply an InputStream;, Class and S
tyleFactory
at javax.swing.plaf.synth.SynthParser.parse(Unknown Source)
at javax.swing.plaf.synth.SynthLookAndFeel.load(Unknown Source)
at gov.nasa.jsc.console.MyClass$2.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

The InputStream is null and my only guess is that it can’t find my XML file. I have the file ‘MyClass’ in a jar and the XML is not in the jar. Does the code below look right? Do I have to do something else to get a resource stream if ‘MyClass’ is in a jar or should I be able to grab the resource stream as is?

Any help much appreciated.

— synth code

Runnable runner = new Runnable() {
public void run() {
try {
SynthLookAndFeel synth = new SynthLookAndFeel();

		Class aClass = MyClass.class;
		InputStream is = aClass.getResourceAsStream("bin"
			+ System.getProperty("file.separator") + "mylaf.xml");
		
		if (is == null) {
			System.err.println("Unable to find theme configuration");
		}
		          
		synth.load(is, aClass);
	        
		UIManager.setLookAndFeel(synth);
	} catch (ParseException pe) {
		System.err.println("Unable to load theme configuration");			
	} catch (UnsupportedLookAndFeelException ulafe) {
    			System.err.println("Unable to change look and feel");
	} catch (Exception e) {
		System.err.println("Exception: " + e.getMessage());
		e.printStackTrace();
	}
}

};

EventQueue.invokeLater(runner);

When you use ClassLoader#getResourceAsStream, the class loader searches for the file you requested using an implementation specific search algorithm. For the default classloader this means it’s going to search in the classpath. So to make your code work you have to have a file bin/mylaf.xml somewhere in the classpath. You can do this by adding bin/mylaf.xml to a jar that is already in your classpath or by adding the directory containing bin/mylaf.xml to the classpath.

Man, I’ve tried so many combinations. I have the xml file within the jar where ‘MyClass’ is at the top level and the jar is in my bin directory. No matter what I try, it won’t pick it up. I can leave the xml in every directory, several locations in the classpath, and it won’t find it. I keep getting the same error.

  • \bin
    | - myJar.jar
    |- com\abc\MyClass.class
    |- mylaf.xml

InputStream is = aClass.getResourceAsStream(“mylaf.xml”);

java -classpath .\bin\myJar.jar com.abc.MyClass

(and various combinations w/ leading ‘’'s and file placements)

Am I missing something?

This sounds similar to a problem which is now described in the JOGL user’s guide where the GLCanvas grows unboundedly in some situations. The workaround (and correct solution as far as I’ve been able to determine) is to place the GLCanvas in a JPanel with preferred size (0, 0). Does that solve your problem?

I set the preferredSize of the panel to (0,0) and the GLCanvas still covers the complete panel area. I try also setting the maimumSize to some intermediate value (100,100) but it takes the full size of the panel.

I have the panel inside another panel layed out with GridBagLayout with the panel filled in both directions. I don’t know if this is an issue.

for the synth definition file, if you use a classes loader then place the .xml file in the same directory as the class. i.e.

try
{
  SynthLookAndFeel laf = new SynthLookAndFeel();
  laf.load(someClass.getResourceAsStream("synth.xml"), someClass);
  UIManager.setLookAndFeel(laf);
}
catch (Exception ex)
{
  ex.printStackTrace();
}

where synth.xml is in the same directory as someClass.java

Hope that works for you.

Ugh, thanks, that’s what it was. I placed the xml several dirs down in the same dir as the main class and that fixed it.

Thanks again.

Ok I have it working now. I need to put the GLCanvas in a panel where the GLCanvas takes up all the room (for whatever reason). Now I put this insode another panel and I can now set the insets abd background etc of this panel without any problems.

I use the synth paintPanelBackground instead of the paintPanelBorder to draw a border, because I have a problem getting the synth paintBorder to work everytime, but this is a synth problem that I think is being remedied. So now I have skins with jogl. Whooopiiiiii