views:

483

answers:

6

I am working on my MacBook at home, running Leopard, with the latest JDK 1.6 from Apple installed. In IDE, I'd like to browse source code for com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel, but IDE cannot find it. Another example I'd like to browse is com.sun.java.swing.plaf.nimbus.ButtonPainter.

What JAR or ZIP do I need to add to my IDEA project in order to browse com.sun..nimbus. classes inside IDE I'm only interested in Leopard, because this works fine on Windows with Sun's JDk.

I know the Nimbus classes are available, because my app runs with the Nimbus Look and Feel.

+1  A: 

Unfortunately, the source for these libraries is not often distributed. If you want to inspect the code, you could download a decompiler and decompile the jars in your install.

Here is a link to wikipedia that has a few follow-up links for download sites for JAD, a decompiler that will do the job.

akf
A: 

The Source code comes when you install the JDK. Look into the JDK Directory for src.zip.

Most Java packages are there, I am sure Swing will be there too.

Geek
Often com.sun.* are not in the available source as they are not part of the JDK.
Alex Miller
A: 

The source code for the JDK can be obtained (under varying licenses) at OpenJDK. I'm not sure how you'd go about integrating it with IntelliJ, however.

Falaina
+2  A: 

The Nimbus classes are here in my 1.6 Mac installation:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Classes/classes.jar

and I would jad them if you need the source. I use JadClipse to view jad'ed source inside Eclipse. It's not perfect of course, but serves in a pinch.

You can also get JDK 1.6 source here:

If you extract it, you can find the Nimbus source down under Work/j2se/src/share/classes/com/sun/java/swing/plaf/nimbus

So could theoretically hook that up to the classes.jar and maybe get something to work too.

Alex Miller
Jad don't lend well to the new byte code constructions in Java 6.
Thorbjørn Ravn Andersen
A: 

Best bet is, as others have pointed out, to decompile the code.

However, everyone else has suggested JAD, I don't like it much. JD-GUI is a MUCH better decompiler as it can look into jars and link sources so you can inspect the code much easier. I've sifted through some rather complex code with this easily.

http://java.decompiler.free.fr/

JR Boyens
A: 

On the Mac, the sources to the JDK aren't bundled by default.

You'll need to download the XCode stuff from the Apple Developer Network - there's an installable package in that download for the JDK sources. Whether it contains the com.* stuff or not is a different question ;-)

StephMW