Substance L&F

I just came across this: https://substance.dev.java.net/

It is a really slick Swing look and feel implementation that looks perfect for games. Try the webstart demo: https://substance.dev.java.net/webstart/test.jnlp

& modify the themes tab & the watermark options! 8)

substance is a pretty popular theme…its pretty nice.

Shame the hightlight colours dont work well under GTK2 (ubuntu)

DP

Looks pretty nice. But why doesnt it style the jframe’s title thingy, too?

Your outer frame is always a native widget, which you can’t change.

As you can see from the screenshots on the main page, Substance supports the custom decorated frame / dialog title panes. You need to either call JFrame.setDefaultLookAndFeelDecorated(true) and JDialog.setDefaultLookAndFeelDecorated(true) before you create your first frame or run your application with -Dsubstancelaf.useDecorations VM flag.

Your outer frame is always a native widget, which you can’t change.

Nah… :slight_smile:

substancelaf.useDecorations

Why that extra flag? (And why isnt it on by default?) I mean if you set JDialog.setDefaultLookAndFeelDecorated(true) and JFrame.setDefaultLookAndFeelDecorated(true) (which is what I did), you already show that you want that extra decoration.

edit: this post is silly :wink:

I stand corrected. I thought that since there wasn’t a FrameUI, that it wouldn’t be painted by the Look and Feel.

The additional VM flag (substancelaf.useDecorations) allows using custom decorations without changing the application code. It is not on by default due to [1]. If you already call the setDefault…Decorated, than there is no need to specify this VM flag (Substance will honor the user-specified mode). In addition, the title pane is “created” not by FrameUI but by RootPaneUI (since this is the common ground for JFrame and JDialog).

Kirill

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5079688

Ye that confusion was my fault really. I used some 3rd party app for testing that… and I didnt pay much attention to the source.

http://kaioa.com/k/moepii.png

That frame icon extra menu was really an awesome idea :slight_smile:

Oh and the webstart demo isnt decorated and it doesnt seem to exit for real (leaves some zombie process behind).

I’m really impressed with the different Substance themes, they give Swing apps (& games) a lot of polish 8). I think its because dark/high-contrast colour schemes work so well.

Here’s how I’ve used the Substance look and feel in my game: http://www.freewebs.com/commanderkeith/STG.jnlp

If you want to see the different Substance themes in action, choose ‘Options’ then ‘Switch to X Theme’. (the default one I’m using is Dark Violet). To see how awesome Substance looks compared with the java default Ocean Metal L&F or the native OS L&F click ‘Switch to X Look & Feel’ in the options menu. By watching the FPS counter in the bottom right you can see the comparative performance as well.

(for those who want to actually play the game, the keys are WASD to move, E to hop in/out of tanks & mouse to aim & fire. Page Up/Down zooms & numpad +/- changes game speed. The VM options in the Options menu won’t work with WebStart, but if you download the jars (STG.jar & substance-lite.jar) you can use them to compare performance of the J2D pipelines)

A screenshot:

http://www.freewebs.com/commanderkeith/screenshot.JPG

PS: I love your work Kirill!

Substance rendering performance is a little slower than the Ocean default L&F & a lot slower than CDE/Motif, it must be due to all of the GradientPaints Substance uses (but i think its worth it). The other problem with it is that the substance-lite.jar file is pretty big- 500kb, nearly as much as my entire game+images.

Is there any way that can be slimmed down Kirill? I know its already compressed, but can stuff be left out, like watermarks,etc since I’m not using them?

Thanks,
Keith

I address this issue in the project FAQ question 5, providing a number of options to cut down the jar size. Removing watermarks (including the katakana image) will remove additional ~68KB, but will create compilation problems. You can remove “unwanted” UI delegates if your application doesn’t use the corresponding controls (TabbedPane is 32KB and TitlePane for custom decorated title panes is another 30KB). I already provide three different runtime libraries, the full version, the version with Swing color chooser and the lite version with Swing color chooser and without additional “feel” parts.The difference between the first and the last is about 380KB and i think that this is OK with the modern high-speed availability and the size of most of the desktop apps. I feel that my time is better spent on providing new features than on breaking up Substance into nano-modules - Substance already has a plugin architecture that allows to provide the lite version at little cost for the development.

Kirill

[1] https://substance.dev.java.net/docs/faq.html

By the way, i’m getting the following exception running the JNLP link under the latest Mustang (b94) - you should reconsider using internal classes such as a Curve in the sun.awt.geom package.

Exception in thread “Thread-8” java.lang.NoSuchMethodError: sun.awt.geom.Curve.crossingsForPath(Ljava/awt/geom/PathIterator;DD)I
at net.slavebot.tankgame.KPolygon.contains(KPolygon.java:286)
at net.slavebot.tankgame.KPolygon.intersects(KPolygon.java:345)
at net.slavebot.tankgame.vehicle.VehiclePart.tentativeHitTestVehicleParts(VehiclePart.java:251)
at net.slavebot.tankgame.vehicle.VehiclePart.tentativeHitTestVehiclePartsForCurrent(VehiclePart.java:234)
at net.slavebot.tankgame.vehicle.VehiclePart.tentativeHitTestVehiclePartsForAll(VehiclePart.java:221)
at net.slavebot.tankgame.vehicle.Vehicle.tentativeHitTestVehicle(Vehicle.java:82)
at net.slavebot.tankgame.Scenario.canPlace(Scenario.java:256)
at net.slavebot.tankgame.Scenario.placeNear(Scenario.java:220)
at net.slavebot.tankgame.Scenario.addVehicle(Scenario.java:196)
at net.slavebot.tankgame.Player.respawn(Player.java:345)
at net.slavebot.tankgame.ParallaxStarMap.addNetworkPlayer(ParallaxStarMap.java:217)
at net.slavebot.tankgame.ParallaxStarMap.(ParallaxStarMap.java:73)
at net.slavebot.tankgame.TFrame$2.run(TFrame.java:140)
at java.lang.Thread.run(Unknown Source)

Thanks for your help & alerting me to that bug, I’ll fix it tomorrow. By the way I’ve been trying out the mixed themes and they’re impressive. Congrats on your work, there isn’t a better looking L&F than Substance.

OK my code’s fixed and works with the latest Mustang b95. There’s also an openGL Web Start version of the game I posted at www.freewebs.com/commanderkeith/STGOpenGL.jnlp as well as the default one.

Kirill, there’s a problem with the substance-lite.jar when using the latest Mustang build.

When I try to create an instance of InitialMenu (my sub-class of JInternalFrame) with Substance as the L&F I get this exception, with any other L&F there’s no problem, & with the full substance.jar there’s no problem.

Exception in thread “Thread-5” java.lang.NoClassDefFoundError: com/sun/java/swing/SwingUtilities2
at org.jvnet.substance.SubstanceInternalFrameTitlePane$SubstanceTitlePaneLayout.minimumLayoutSize(SubstanceInternalFrameTitlePane.java:485)
at java.awt.Container.minimumSize(Container.java:1668)
at java.awt.Container.getMinimumSize(Container.java:1653)
at javax.swing.JComponent.getMinimumSize(JComponent.java:1689)
at java.awt.BorderLayout.minimumLayoutSize(BorderLayout.java:646)
at org.jvnet.substance.SubstanceDesktopIconUI.getMinimumSize(SubstanceDesktopIconUI.java:172)
at org.jvnet.substance.SubstanceDesktopIconUI.getPreferredSize(SubstanceDesktopIconUI.java:159)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1607)
at javax.swing.JInternalFrame$JDesktopIcon.updateUI(JInternalFrame.java:2217)
at javax.swing.JInternalFrame$JDesktopIcon.(JInternalFrame.java:2146)
at javax.swing.JInternalFrame.(JInternalFrame.java:332)
at javax.swing.JInternalFrame.(JInternalFrame.java:251)
at net.slavebot.tankgame.menu.InitialMenu.(InitialMenu.java:26)
at net.slavebot.tankgame.TFrame$2.run(TFrame.java:222)
at java.lang.Thread.run(Thread.java:619)

For now I’m using the full substance.jar file, so you can still try the web start link. If you have any queries about the above error then I’d be glad to help.

Thanks,
Keith

Many thanks for reporting this issue. Can’t believe that SwingUtilities2 snuck into 3.0 :frowning: This has been fixed - you’re welcome to take the latest drop of Substance 3.0 and test it.

Isn’t it a bad idea using com.sun* classes? Non-portable, for sure…
AFAIK SwingUtilities2 (now sun.swing.SwingUtilities2) is not a public/supported interface.

Thanks,
Dmitri

[edited: typo]

Ah, I misunderstood your comment. It was left in version 3 by accident, it seems.
Sorry.

Dmitri

Dmitri,

The usage of SwingUtilities2 was removed - it was by mistake. Indeed it’s highly unrecommended to use this class, especially since it was moved to another package in JDK 6.0