日期:2014-05-20  浏览次数:20779 次

如何看JButton源代码?
如何看JButton源代码?需要下载什么,到哪里下载?

------解决方案--------------------
你安装JDK的时候选择安装源代码就可以了,在jdk目录下就有一个src.zip的压缩文件,里面就有。
下面是我jdk1.5的源代码
/*
* @(#)JButton.java 1.97 03/12/19
*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.swing;

import java.util.EventListener;

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;

import javax.swing.plaf.*;
import javax.swing.event.*;
import javax.accessibility.*;

import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;


/**
* An implementation of a "push " button.
* See <a href= "http://java.sun.com/docs/books/tutorial/uiswing/components/button.html "> How to Use Buttons, Check Boxes, and Radio Buttons </a>
* in <em> The Java Tutorial </em>
* for information and examples of using buttons.
* <p>
* <strong> Warning: </strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans <sup> <font size= "-2 "> TM </font> </sup>
* has been added to the <code> java.beans </code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @beaninfo
* attribute: isContainer false
* description: An implementation of a \ "push\ " button.
*
* @version 1.97 12/19/03
* @author Jeff Dinkins
*/
public class JButton extends AbstractButton implements Accessible {

/**
* @see #getUIClassID
* @see #readObject
*/
private static final String uiClassID = "ButtonUI ";

/**
* Creates a button with no set text or icon.
*/
public JButton() {
this(null, null);
}

/**
* Creates a button with an icon.
*
* @param icon the Icon image to display on the button
*/
public JButton(Icon icon) {
this(null, icon);
}

/**
* Creates a button with text.
*
* @param text the text of the button
*/
public JButton(String text) {
this(text, null);
}

/**
* Creates a button where properties are taken from the
* <code> Action </code> supplied.
*
* @param a the <code> Action </code> used to specify the new button
*
* @since 1.3
*/
public JButton(Action a) {
this();
setAction(a);
}

/**
* Creates a button with initial text and an icon.
*
* @param text the text of the button
* @param icon the Icon image to display on the button
*/
public JButton(String text, Icon icon) {
// Create the model
setModel(new DefaultButtonModel());

// initialize
init(text, icon);
}

/**
* Resets the UI property to a value from the current look and
* feel.
*
* @see JComponent#updateUI
*/
public void updateUI() {
setUI((ButtonUI)UIManager.getUI(this));