home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 October
/
Chip_1997-10_cd.bin
/
tema
/
sybase
/
powerj
/
java.z
/
Button.java
< prev
next >
Wrap
Text File
|
1996-05-03
|
2KB
|
96 lines
/*
* @(#)Button.java 1.17 96/04/04 Sami Shaio
*
* Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies. Please refer to the file "copyright.html"
* for further important copyright and licensing information.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
package java.awt;
import java.awt.peer.ButtonPeer;
/**
* A class that produces a labeled button component.
*
* @version 1.17 04 Apr 1996
* @author Sami Shaio
*/
public class Button extends Component {
/**
* The string label for this button.
*/
String label;
/**
* Constructs a Button with no label.
*/
public Button() {
this("");
}
/**
* Constructs a Button with a string label.
* @param label the button label
*/
public Button(String label) {
this.label = label;
}
/**
* Creates the peer of the button. This peer allows us to
* change the look of the button without changing its functionality.
*/
public synchronized void addNotify() {
peer = getToolkit().createButton(this);
super.addNotify();
}
/**
* Gets the label of the button.
* @see #setLabel
*/
public String getLabel() {
return label;
}
/**
* Sets the button with the specified label.
* @param label the label to set the button with
* @see #getLabel
*/
public void setLabel(String label) {
this.label = label;
ButtonPeer peer = (ButtonPeer)this.peer;
if (peer != null) {
peer.setLabel(label);
}
}
/**
* Returns the parameter String of this button.
*/
protected String paramString() {
return super.paramString() + ",label=" + label;
}
/* Can this field be tabbed to? */
boolean tabbable() {
return true;
}
}