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

📄 newlabel.java

📁 《java事件处理指南》一书的代码,好东西
💻 JAVA
字号:
import javax.swing.*;import java.awt.*;import java.beans.*;public class NewLabel extends JLabel implements PropertyChangeListener{   private FontColor fontColor;   public NewLabel(String str, FontColor fc)   {      super(str);      fontColor = fc;      setForeground(fontColor.getColor());/*  When a NewLabel object is created, its FontColor object       *//*  registers a PropertyChangeListener.  When the Color           *//*  object associated with the FontColor object is changed, the   *//*  FontColor object will fire a PropertyChangeEvent that will    *//*  be sent to this listener.                                     */      fontColor.addPropertyChangeListener(this);   }   public FontColor getFontColor()   {      return fontColor;   }   public void setFontColor(FontColor fc)   {      fontColor = fc;   }/*  The NewLabel class serves as a PropertyChangeListener and thus  *//*  provides an implementation of the propertyChange() method.  If  *//*  the PropertyChangeEvent was due to a change in the "color"      *//*  property, the text color of the NewLabel is changed.            */   public void propertyChange(PropertyChangeEvent event)   {      if ( event.getPropertyName().equals("color") )      {         setForeground( (Color)event.getNewValue() );      }   }}

⌨️ 快捷键说明

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