⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textreader.java

📁 java 完全探索的随书源码
💻 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 aslike 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 );      changeAgent.firePropertyChange( "inputText", new String( oldText ),                                      new String( newText ) );   }   // these two methods allow this Bean to have bound properties.   public void addPropertyChangeListener( PropertyChangeListener l ) {      changeAgent.addPropertyChangeListener( l );   }   public void removePropertyChangeListener( PropertyChangeListener l ) {      changeAgent.removePropertyChangeListener( l );   }   protected PropertyChangeSupport changeAgent =     new PropertyChangeSupport( this );  // setter method for the Columns property.   public synchronized void setWidth( int newWidth )   throws PropertyVetoException {      int oldWidth = Width;      vetoAgent.fireVetoableChange( "width", new Integer( oldWidth ),                                    new Integer( newWidth ) );      // no one vetoed, so change the property.      Width = newWidth;      setColumns( Width );      Component p = getParent();      if ( p != null ) {         p.invalidate();         p.doLayout();      }      changeAgent.firePropertyChange( "width", new Integer( oldWidth ),                                      new Integer( newWidth ) );   }   // getter method for the Columns property.   public synchronized int getWidth() {      return Width;   }   // these two methods allow this Bean to have constrained properties.   public void addVetoableChangeListener( VetoableChangeListener l ) {      vetoAgent.addVetoableChangeListener( l );   }   public void removeVetoableChangeListener( VetoableChangeListener l ) {      vetoAgent.removeVetoableChangeListener( l );   }   protected VetoableChangeSupport vetoAgent =     new VetoableChangeSupport( this );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -