The Source for Java Technology Collaboration
User: Password:



Kirill Grouchnikov

Kirill Grouchnikov's Blog

IntelliJ IDEA 5.0 and custom look-and-feel

Posted by kirillcool on August 09, 2005 at 12:55 PM | Comments (3)

IntelliJ IDEA 5.0 is out, and since one of my projects is on the approved list, I seized an opportunity to start working with it.

While some of the features are not for me (such as JSP 2.0, J2ME and CSS support), others come in very handy (one of my favourites is an insanely fast code inspector). One of the features (that was already present before) allows you to switch look-and-feels of the application (as it is completely written in Swing). While not as user-friendly as in JFormDesigner 2.0 (navigate to a jar file that implements the desired look-and-feel and it's loaded and referenced for all future invocations), it's not impossible. Here's how you can do it (based on my Substance look-and-feel):
  1. Take the jar file of your LAF (substance.jar in my case) and put it under IDEA/lib and IDEA/jre/lib/ext directories, where IDEA is IDEA 5.0 installation directory.
  2. Create a new file under IDEA/jre/lib/ named swing.properties.
  3. Edit this file adding the following entries:
    swing.installedlafs = motif,windows,metal,substance
    swing.installedlaf.motif.name = CDE/Motif
    swing.installedlaf.motif.class = com.sun.java.swing.plaf.motif.MotifLookAndFeel
    swing.installedlaf.windows.name = Windows
    swing.installedlaf.windows.class = com.sun.java.swing.plaf.windows.WindowsLookAndFeel
    swing.installedlaf.metal.name = Metal
    swing.installedlaf.metal.class = javax.swing.plaf.metal.MetalLookAndFeel
    swing.installedlaf.substance.name = Substance
    swing.installedlaf.substance.class = org.jvnet.substance.SubstanceLookAndFeel
    
    Here, instead of substance, put your favourite LAF.
  4. Run IntelliJ IDEA 5.0
  5. Go to Settings -> IDE tab -> Appearance and click on Look and feel combobox
  6. You will see a list of bundled LAFs (Alloy and IDEA) and your newly added LAF:
  7. Choose it and press Apply
Here a few screenshots of IntelliJ IDEA 5.0 under Substance look-and-feel:


For me as a look-and-feel developer, IDEA 5.0 comes very handy:
  • It has a lot of screens and controls, so an existing bug is likely to appear sooner
  • It comes with bundled JRE 5.0, which Substance LAF requires
  • It is completely Swing-based, so it makes heavy use of LAF
However, there are some things that I wish weren't such:
  • A lot of custom widgets with custom painting (progress bar is one of them)
  • Some problems in turning the JFrame and JDialog decorations on (they come out borderless and without decorations) - probably my bug
  • Menus are drawn in pre-Ocean Metal theme, but that's also probably my bug
And the last two items bring me back to the "handy list" - bugs to solve in Substance :(

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Hi Kirill! Your tip was great! I don't use Intellij IDEA as my IDE but a friend of mine uses it and he'll be happy with such a tip. I'd like to know if you know ways to do the same kind of configuration for other IDEs such as Eclipse and Netbeans. Thank you!

    Posted by: matheus_eduardo on August 10, 2005 at 10:55 AM

  • Matheus_eduardo,
    For Netbeans see this link. It doesn't play well with stuff that doesn't inherit from Metal, i had a lot of ClassCastExceptions in NetBeans on their custom widgets that tried to cast my border objects to MetalBorders. I'll contact the NetBeans guys with the issue.
    As Eclipse does not use Swing, i think you can not change its look & fell - SWT uses native widgets.

    Posted by: kirillcool on August 10, 2005 at 12:17 PM


  • Krill's instructions are for a Windows system. Since I have a Mac they were a good starting point, but I had to figure out the actual details. So I thought I'd share what I'd learned. Thanks for the good start.

    Krill's instructions are for a Windows system. Since I have a Mac they were a good starting point, but I had to figure out the actual details. So I thought I'd share what I'd learned. Thanks for the good start.

    First, IDEA on the Mac doesn't ship with a JRE, it uses an installed one. By default it use 1.4, but my particular L&F requires 1.5, so I had to figure out how to change it. If you need to, here's how: In the app directory for IDEA (typically /Applications/IntelliJ IDEA 5.1.app) you can edit the Contents/Info.plist file, and you'll find a JMVersion key. Change the string that follows from 1.4+ to 1.5.+ and you'll run under Java 1.5.

    Whichever version y ou're using, you do need to edit swing.properties. You'll find it under /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home or somewhere like it (it depends on your version). The swing.properties file shown in Krill's hint is probably not correct for OS X. Here's the simple thing I added:

    swing.installedlafs=aqua,napkin
    swing.installedlaf.aqua.name=Aqua
    swing.installedlaf.aqua.class=apple.laf.AquaLookAndFeel
    swing.installedlaf.napkin.name=Napkin
    swing.installedlaf.napkin.class=napkin.NapkinLookAndFeel

    My look and feel is the Napkin Look & Feel. Your name will vary, of course.

    After this, I copied the napkinlaf.jar file into the application directory's lib directory (typically /Applications/IntelliJ IDEA 5.1.app/lib). And then when I started IDEA, I found Napkin listed as an available choice in the Appearance preference.

    (I'd include a snapshot, but can't as a commentator. You'll have to wait until the 1.0 release ("real soon now!") and then see it on my L&F's web site.)

    Hope this helps someone.

    Posted by: arnold on March 11, 2006 at 11:53 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds