Look And Feel (Java 6)

I just switched my program from Java 1.42 to Java 6 because I wanted to take advantage of Substance Look and Feel (is 5.0 and up only). After sorting out a few things it didn’t like in my code I got everything up and running and then plugged in Substance, but it didn’t go together very well -

a) There was terrible flicker (I suppose substance doesn’t like direct rendering)
b) It drew it’s own button images behind mine
c) I got deadlocks on comboBoxes (never seen that before)
d) Other more minor stuff

So I decided to just change the gui stuff by myself with UIManager since just changing a few imageIcons and colors for the objects I’m using (JComboBox, JFormattedTextField, ScrollBar, JSpinner JColorChooser and a few others) will give me the results I need. I’ve had a few problems so far -

  1. Java 6 draws this annoying light blue border around my comboboxes and I’ve tried everything but can’t get rid of it
  2. I’ve created a color chooser with only the first panel (the palette array thing) and can’t get it to make it transparent

		AbstractColorChooserPanel panels[] = colorChooser.getChooserPanels();
		panels[0].setOpaque(false);
		panels[0].setBackground(new Color(0f,0f,0f,0f));
		AbstractColorChooserPanel panels2[] = {panels[0]};
		colorChooser.setChooserPanels(panels2);

And


		UIManager.put("ColorChooser.background ", new Color(0f,0f,0f,0f));

  1. Having trouble changing the color of the scrollbar including buttons and the color of the arrows on the buttons

That’s about all I can think of for now. Thanks

Yeah, borders don’t get drawn where you expect. It is difficult to track down. Try Liquid LNF, I liked it much better than substance.

https://liquidlnf.dev.java.net/

I’d suggest to use the system look and feel, it’s what everybody is used to.
Unless of course you want some really funky-looking, game-specific GUI, but I think neither Substance or Liquid are that too (although Substance can be tweaked to look a bit more ‘game-ish’).

Thanks for the replies so far. I looked at liquid, and although there was no flicker it did have a lot of the same problems as substance and seemed to be a lot less “tweakable” as Erikd says.

So I’m probably gonna keep struggling with the default look and feel, but does anyone know how to customise scrollbars and make the colorchooser transparent?

You can’t make top level windows transparent.

Hi,
Does the default metal look and feel work?

Your problems sound like general threading problems and may have little to do with Substance except that it uses animations which are done on the Event Dispatch Thread which can conflict with your direct rendering thread. Swing is not very user-friendly for gamers due to the EDT :(.

The flicker would be due to Substance animations which are executed on the Event Dispatch Thread and therefore aren’t sync’ed to your direct rendering thread. You need to use a synchronized EventQueue to solve this… check out this link: http://www.java-gaming.org/forums/index.php?topic=15140.0. Your deadlocked JComboBox sounds like the same thing - you can’t paint it in your rendering thread when it is modified in the EDT without sync’ing those 2 threads.

If you let Kirill, the maker of Substance, know your problem he is likely to be very helpful. Just make a test case to let him narrow down the bug if there is one at all.

Best wishes,
Keith

PS:

I haven’t tried it, but you might be interested to know that on windows and Mac transparent windows can be used: http://www.curious-creature.org/2007/04/10/translucent-swing-windows-on-mac-os-x/

CaptainJester

JColorChooser isn’t a top level container is it? I’m displaying it in a jpanel that I’ve "decorated " to fit in with the look of my game and NOT in a JDialog which might be what you are talking about.

CommanderKeith

I’m pretty sure I’m not gonna use substance or liquid (although I might check out ) for the look and feel I really just need the swing components to be of dark colors (and in some cases translucent) that’s why I initially thought substance would be a good idea (but clearly it wasn’t). I’ve now come to terms with the fact that I’m just gonna have to change the colors of them where i can.

If you’re getting lock up problems you may also have some faults in your implementation!

Hi,

If you’re willing to give Substance another chance, i’d be more than happy to work with you on the problems that you have found. For each one, we can start with a small test application that illustrates an incorrect behavior and get to the root of the problem. Feel free to contact me directly at kirillcool [@at@] yahoo [.dot.] com

Note that in general, Substance is much less forgiving on EDT violations, mostly due to its internal threads used for animations and other purposes. So, an application that doesn’t respect EDT rules, can run under other LAFs (until it hits a very rare deadlock), but will freeze under Substance. Up until now, there has been only one real bug in Substance in this area. In all the other cases, it has been the application code behaving “badly”. There are a few techniques that you can use (AOP, a custom repaint manager) to check EDT violations - see [1] for a possible solution.

Last thing - Substance uses its own APIs to use custom themes on per-control basis. Mostly, this is done to provide a consistent gradient implementation which can’t be done using only one color (which is why i ignore the background color set on a button, for example). Of course, this will tie your application to a particular LAF - which you may or may not like.

In the future, if you have Substance-specific questions, it’s much better to ask on project forums and mailing lists and not on external forums (which i rarely check).

Thanks
Kirill (Substance developer)

[1] http://weblogs.java.net/blog/alexfromsun/archive/2006/02/debugging_swing.html