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

📄 stringdialog.java

📁 sifi-0.1.6.tar.gz 出自http://www.ifi.unizh.ch/ikm/SINUS/firewall/ 一个linux的防火墙工具。
💻 JAVA
字号:
/* ----------------------------------------------------------------------   The SINUS Firewall -- a TCP/IP packet filter for Linux   Written within the SINUS project at the University of Zurich,   SWITCH, Telekurs Payserv AG, ETH Zurich.   originally based on the sf Firewall Software (C) 1996 by Robert   Muchsel and Roland Schmid.   This program is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2 of the License, or   (at your option) any later version.   This program is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with this program; if not, write to the Free Software   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   SINUS Firewall resources:   SINUS Homepage: http://www.ifi.unizh.ch/ikm/SINUS/   Firewall Homepage: http://www.ifi.unizh.ch/ikm/SINUS/firewall.html   Frequently asked questions: http://www.ifi.unizh.ch/ikm/SINUS/sf_faq.html   Mailing list for comments, questions, bug reports: firewall@ifi.unizh.ch   ----------------------------------------------------------------------  */package sfclasses;import java.awt.*;import java.awt.event.*;/** * Dialog Box to input a string<br> * The dialog box contains a text input field to enter a string, an OK * button and a Cancel button. It is a subclass of Frame because when * deriving it from Dialog, it does not work correctly with Netscape. * @version 1.0 26 Jan 1997 * @author Roland E. Schmid */public class StringDialog	extends Frame	implements ActionListener {    public StringDialog( Frame parent, String message) {      setTitle("Enter text");      build(message);    }    /**     * Initialize dialog box<br>     * After creating and showing the dialog, call getAnswer() or getString()     * to wait until the user closes has finished.     * @param parent Parent frame     * @param title Window title string     * @param message Prompt string     */  public StringDialog( Frame parent, String title, String message) {    setTitle(title);    build(message);  }  private void build(String message) {	GridBagLayout gb = new GridBagLayout();	setLayout( gb );	GridBagConstraints gbc = new GridBagConstraints();	gbc.insets = new Insets( 5, 5, 5, 5 );		Label label = new Label(message);		Utils.add_component(this, label, gb, gbc, 0, 0, 1, 1, 0, 0);		text = new TextField(50);		text.addActionListener(this);		Utils.add_component(this, text, gb, gbc, 1, 0, 1, 1, 100, 0);		Panel buttonPanel = new Panel();		buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));		buttonPanel.add(okButton = new Button("OK"));		okButton.addActionListener(this);		buttonPanel.add(cancelButton = new Button("CANCEL"));		cancelButton.addActionListener(this);		Utils.add_component(this, buttonPanel, gb, gbc, 0, 1, 2, 1, 100, 0);    pack();	}    /**      * Event handler.     */  public void actionPerformed(ActionEvent ae) {	Object source = ae.getSource();		if (source == okButton) {		    click(OK);		    return;		}		if (source == cancelButton) {		    click(CANCEL);		    return;		}    if (source == text) {      click(OK);    	return;		}		} // actionPerformed    private synchronized void click(int val)	{	answer = val;	clicked = true;	notify();	setVisible(false);	dispose();	}/** * Get the answer.* @return OK if the user pressed return or pushed the OK button,* Cancel if the user pushed the Cancel button. Do not call this* method from an event handler.*/public synchronized int getAnswer() {	while (!clicked) {	  try {		wait();		}	  catch (InterruptedException ignore) {}	}	return answer;} // getAnswer/*** Get the string the user has entered. Do not call this method * from an event handler.* @return Entered string or null if the user has selected Cancel*/public synchronized String getString() {	while (!clicked) {	  try {		 wait();		}	  catch ( InterruptedException ignore ) {}	}  if (answer == OK)    return text.getText().trim();  else    return null;}private Button okButton;private Button cancelButton;private TextField text;private int answer;private boolean clicked = false;public static final int OK = 0;public static final int CANCEL = 1;}

⌨️ 快捷键说明

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