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

📄 mydialog.java

📁 aglet的部分源码
💻 JAVA
字号:
package examples.mdispatcher;/* * @(#)HelloAglet.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. */import com.ibm.aglet.*;import com.ibm.aglet.event.*;import com.ibm.aglet.util.*;import com.ibm.agletx.util.SimpleItinerary;import java.lang.InterruptedException;import java.io.Externalizable;import java.io.ObjectInput;import java.io.ObjectOutput;import java.io.IOException;import java.net.*;import java.awt.*;import java.util.Enumeration;import java.awt.event.*;/* * MyDialog class is the window to be opened when the dialog required. * This is NOT a subclass of Dialog. */class MyDialog extends Frame implements ActionListener, WindowListener {	/*	 * The aglet a user interacts with.	 */	private HelloAglet aglet = null;	/*	 * UI Components	 */	private AddressChooser dest = new AddressChooser();	private TextField msg = new TextField(15);	private Button go = new Button("GO!");	private Button close = new Button("CLOSE");	/*	 * Constructs the dialog window	 * @param aglet The aglet the user interacts with.	 */	MyDialog(HelloAglet aglet) {		this.aglet = aglet;		layoutComponents();		addWindowListener(this);		dest.addActionListener(this);		msg.addActionListener(this);		go.addActionListener(this);		close.addActionListener(this);	}	/**	 * Handles the action event	 * @param ae the event to be handled	 */	public void actionPerformed(ActionEvent ae) {		if ("GO!".equals(ae.getActionCommand())) {			aglet.message = msg.getText();			aglet.goDestination(dest.getAddress());		} else if ("CLOSE".equals(ae.getActionCommand())) {			setVisible(false);		} 	}	/*	 * Layouts all components	 */	private void layoutComponents() {		msg.setText(aglet.message);		// Layouts components		GridBagLayout grid = new GridBagLayout();		GridBagConstraints cns = new GridBagConstraints();		setLayout(grid);		cns.weightx = 0.5;		cns.ipadx = cns.ipady = 5;		cns.fill = GridBagConstraints.HORIZONTAL;		cns.insets = new Insets(5, 5, 5, 5);		cns.weightx = 1.0;		cns.gridwidth = GridBagConstraints.REMAINDER;		grid.setConstraints(dest, cns);		add(dest);		cns.gridwidth = GridBagConstraints.REMAINDER;		cns.fill = GridBagConstraints.BOTH;		cns.weightx = 1.0;		cns.weighty = 1.0;		cns.gridheight = 2;		grid.setConstraints(msg, cns);		add(msg);		cns.weighty = 0.0;		cns.fill = GridBagConstraints.NONE;		cns.gridheight = 1;		Panel p = new Panel();		grid.setConstraints(p, cns);		add(p);		p.setLayout(new FlowLayout());		p.add(go);		p.add(close);	}	public void windowActivated(WindowEvent we) {}	public void windowClosed(WindowEvent we) {}	/**	 * Handles the window event	 * @param ae the event to be handled	 */	public void windowClosing(WindowEvent we) {		dispose();	}	public void windowDeactivated(WindowEvent we) {}	public void windowDeiconified(WindowEvent we) {}	public void windowIconified(WindowEvent we) {}	public void windowOpened(WindowEvent we) {}}

⌨️ 快捷键说明

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