开发者

How do I open an included java class(for example JButton) in IntelliJ IDEA 10?

开发者 https://www.devze.com 2023-03-11 06:14 出处:网络
I want to be able to open up the JButton class and see the code inside it. The reason is because I want to override开发者_如何学编程 one of the methods, but I want to make sure I include all the funct

I want to be able to open up the JButton class and see the code inside it. The reason is because I want to override开发者_如何学编程 one of the methods, but I want to make sure I include all the functionality that that method normally has. Also, it'd be a good way to learn. I know I can do it when I've had errors by clicking on the class in the error messages. But any ideas on how to bring it up normally?


Go To | Class (Ctrl+N), type JButton (Include non-project classes checkbox will be enabled automatically if no such classes are found in your project).

If you already have JButton usage in your code, you can navigate to its source using Ctrl+B while the caret is on it.

Of course you need sources attached to the JSDK, but it should be fine by default (as JSDK installation has sources on most platforms). If you are on Mac, you will have to download them separately and attach to the JSDK configuration in File | Project Structure | SDKs.


If you have sources just press Ctrl+B on JButton, if you have no, download sources, add to configuration of project and press the same combination


Download the Java Source code here: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Also don't forget about the super keyword which you can use to interact with the extended class


You need to download the Java source code. If you're using Java 1.6, for example, you can go here to get it. Unzip it somewhere on your local disk.

When I need to look at the source code of a Java class I then navigate to the source class and drag it into my IDE.

If you want to ensure you get all the functionality of the original method, call the original method as part of your method. Using super gives you a reference to the overridden method, e.g. super.overridden();. Don't just copy the Java source into your method.

0

精彩评论

暂无评论...
验证码 换一张
取 消