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

📄 swingpanel.java

📁 无限传感器网络的模拟结果的图形查看环境
💻 JAVA
字号:
package iface;import iface.VisualiserPanelObserver;//import com.sun.java.swing.JPanel;
import javax.swing.JPanel;import java.awt.Graphics;/**   SwingPanel provides an implementation of the visualiserpanel interface for   the Swing class library. It does it by interitance, rather than by reference   which would be possible as well..*/class SwingPanel extends JPanel implements VisualiserPanel {    private VisualiserPanelObserver m_observer;    /**       The constructor will forward to the Swing JPanel constructor    */    public SwingPanel() {      super();      m_observer=null;    }    /**       Return the width of this panel.       @return width    */    public int getWidth() {      return super.getWidth();    }    /**       Return the height of this panel.       @return height    */    public int getHeight() {      return super.getHeight();    }    /**       Attach an observer to this panel. Only one observer may be attach in       this implementation.    */    public void attach(VisualiserPanelObserver observer) {      if (m_observer==null) {	m_observer=observer;	m_observer.attach(this);      }    }    /**       Detach an observer.    */    public void detach(VisualiserPanelObserver observer) {      if (m_observer==observer)      m_observer=null;    }    /**       Override the JPanel paintcomponent method to forward to our observer    */    public void paintComponent(Graphics g) {      if (m_observer!=null)      m_observer.paint(g);    }     /**       Forward any repaint calls to the swing repaint function.    */    public void re_paint() {      this.repaint();    }}

⌨️ 快捷键说明

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