首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

怎么看JButton源代码

2011-12-25 
如何看JButton源代码?如何看JButton源代码?需要下载什么,到哪里下载?[解决办法]你安装JDK的时候选择安装源

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

[解决办法]
你安装JDK的时候选择安装源代码就可以了,在jdk目录下就有一个src.zip的压缩文件,里面就有。
下面是我jdk1.5的源代码
/*
* @(#)JButton.java1.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));


}


/**
* Returns a string that specifies the name of the L&F class
* that renders this component.
*
* @return the string "ButtonUI "
* @see JComponent#getUIClassID
* @see UIDefaults#getUI
* @beaninfo
* expert: true
* description: A string that specifies the name of the L&F class.
*/
public String getUIClassID() {
return uiClassID;
}


/**
* Gets the value of the <code> defaultButton </code> property,
* which if <code> true </code> means that this button is the current
* default button for its <code> JRootPane </code> .
* Most look and feels render the default button
* differently, and may potentially provide bindings
* to access the default button.
*
* @return the value of the <code> defaultButton </code> property
* @see JRootPane#setDefaultButton
* @see #isDefaultCapable
* @beaninfo
* description: Whether or not this button is the default button
*/
public boolean isDefaultButton() {
JRootPane root = SwingUtilities.getRootPane(this);
if (root != null) {
return root.getDefaultButton() == this;
}
return false;
}

热点排行