📄 listing29.2.java
字号:
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
public class TextReader extends TextField {
// default constructor for this Bean. This is the constructor that an
// application builder (such as Visual Basic) would use.
public TextReader() {
this( "", 40 );
}
// custom constructor for this Bean. This is the constructor that you
// would likely use if you were doing your coding from scratch.
public TextReader( String InputText, int Width ) {
super( InputText, Width );
this.InputText = InputText;
this.Width = Width;
setEditable( true );
// update the InputText property when the enter key is
// pressed within the TextField
this.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
setInputText(getText());
}
});
}
// this Bean's properties.
protected String InputText;
protected int Width;
// getter method for the InputText property.
public synchronized String getInputText() {
return InputText;
}
// setter method for the InputText property.
public synchronized void setInputText( String newText ) {
String oldText = InputText;
InputText = newText;
setText( InputText );
// uncomment this statement after the Listing 29.4 additions are made
// changeAgent.firePropertyChange( "inputText", new String( oldText ),
// new String( newText ) );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -