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

📄 talkwindow.java

📁 移动Agent编程IBM开发的移动Agent编程工具Aglet 采用纯Java编写可移植性好这是用它写的一些例子用于初级入门
💻 JAVA
字号:
/* * @(#)TalkWindow.java * * 03L7246 (c) Copyright IBM Corp. 1996, 1998 * * The program is provided "as is" without any warranty express or * implied, including the warranty of non-infringement and the implied * warranties of merchantibility and fitness for a particular purpose. * IBM will not be liable for any damages suffered by you as a result * of using the Program. In no event will IBM be liable for any * special, indirect or consequential damages or lost profits even if * IBM has been advised of the possibility of their occurrence. IBM * will not be liable for any third party claims against you. */package examples.talk;import java.awt.*;import java.awt.event.*;import com.ibm.aglet.util.*;/** * @version     1.01    99/01/14 * @author      Mitsuru Oshima * @author      Yoshiaki Mima */public class TalkWindow extends Frame implements ActionListener {    TextArea text   = new TextArea();    TextField input = new TextField();    AddressChooser dest = null;    String address = "";    TalkMaster master = null;    TalkSlave slave = null;    public void actionPerformed(ActionEvent e) {        Object source = e.getSource();                if (source == input) {            String t = input.getText();            appendText( t );            if (master != null) {                if (!address.equals(dest.getAddress())) {                    master.dispatchSlave( address = dest.getAddress() );                }                master.sendText( t );            } else if (slave != null) {                slave.sendText( t );            }            input.setText("");        }    }    public TalkWindow(TalkMaster master) {        super("Talk");        this.master = master;        setLayout(new BorderLayout(5,5));        dest = new AddressChooser();        add("North", dest);        add("Center", text);        add("South", input);        text.setEditable(false);        input.addActionListener(this);        addWindowListener(new WindowAdapter() {            public void windowClosing(WindowEvent e) {                hide();            }        });    }    public TalkWindow(TalkSlave slave) {        super("Talk");        this.slave = slave;        setLayout(new BorderLayout());        add("Center", text);        add("South", input);        text.setEditable(false);        input.addActionListener(this);    }    public void appendText(String str) {        text.appendText( str + "\r\n");    }}

⌨️ 快捷键说明

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