Java Reference
In-Depth Information
/** Construct the object with given label, textfield size,
* and "Extra" component
* @param label The text to display
* @param numChars The size of the text area
* @param extra A third component such as a cancel button;
* may be null, in which case only the label and textfield exist.
*/
public
public LabelText ( String label , int
int numChars , JComponent extra ) {
super
super ();
setLayout ( new
new BoxLayout ( this
this , BoxLayout . X_AXIS ));
theLabel = new
new JLabel ( label );
add ( theLabel );
theTextField = new
new JTextField ( numChars );
add ( theTextField );
iif ( extra != null
null ) {
add ( extra );
}
}
/** Get the label's horizontal alignment */
public
public int
int getLabelAlignment () {
return
return theLabel . getHorizontalAlignment ();
}
/** Set the label's horizontal alignment */
public
public void
int align ) {
theLabel . setHorizontalAlignment ( align );
void setLabelAlignment ( int
}
/** Get the text displayed in the text field */
public
public String getText () {
return
return theTextField . getText ();
}
/** Set the text displayed in the text field */
public
public void
void setText ( String text ) {
theTextField . setText ( text );
}
/** Get the text displayed in the label */
public
public String getLabel () {
return
return theLabel . getText ();
}
/** Set the text displayed in the label */
public
public void
void setLabel ( String text ) {
Search WWH ::




Custom Search