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

📄 dialogmessage.java

📁 利用JAVA编写的群体机器人局部通讯完成一定得队形控制
💻 JAVA
字号:
/* * DialogMessage.java */package	EDU.gatech.cc.is.util;import java.lang.System;import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * A class for displaying a simple message to the user. * <P> * Copyright (c)2000 Tucker Balch * * @author Tucker Balch * @version $Revision: 1.2 $ */public class DialogMessage extends JDialog implements ActionListener{	private TextArea ta;	private JButton ok;	private JFrame parent;	/**	 * Pop up a dialog message box.	 * @param parent Frame, the parent of the box.	 * @param title  String, what to put in the title bar.	 * @param msg    String, what to say.	 */    public DialogMessage(JFrame par, String title, String msg)    {        super(par, title);		this.getContentPane().setLayout(null);		setModal(true);		setSize(410,285);		parent = par;		// compute position		Point p = parent.getLocation();		Dimension d = parent.getSize();		int desiredx = (d.width-400)/2;		int desiredy = (d.height-260)/2;		setLocation(desiredx+p.x, desiredy+p.y);		ta = new TextArea("",7,60, TextArea.SCROLLBARS_NONE);		ta.setEditable(false);		ta.setText(msg);        getContentPane().add(ta);		ta.setBounds(getInsets().left, getInsets().top,				400-getInsets().right-getInsets().left,				200-getInsets().top-getInsets().bottom);        ok = new JButton("OK");		ok.setBounds(170,210,60,30);        ok.addActionListener(this);        this.getContentPane().add(ok);                         //this.pack();//commentted by yym for correct display.        this.show();      }	/**	 * Intercept addNotify	 */	public void addNotify()		{		super.addNotify();		// do these again after the dialog box is really there.		ta.setBounds(getInsets().left,			getInsets().top,			400-getInsets().right-getInsets().left,			200-getInsets().top-getInsets().bottom);		ok.setBounds(170,210,60,30);		// compute position		Point p = parent.getLocation();		Dimension d = parent.getSize();		int desiredx = (d.width-400)/2;		int desiredy = (d.height-200)/2;		setLocation(desiredx+p.x, desiredy+p.y);		}	/**	 * Handle the OK button push.	 */    public void actionPerformed(ActionEvent e)     {		setModal(false);        dispose();      }}

⌨️ 快捷键说明

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