1 24 25 package org.objectweb.clif.console.lib.gui; 26 27 import javax.swing.*; 28 import java.awt.event.ActionListener ; 29 import java.awt.event.ActionEvent ; 30 import java.awt.event.WindowAdapter ; 31 import java.awt.event.WindowEvent ; 32 import java.awt.*; 33 34 35 39 public class GUIInitDialog extends JDialog implements ActionListener 40 { 41 static protected int last_id = 0; 42 protected JButton okBtn; 43 protected JTextField idFld; 44 protected String value = null; 45 46 47 GUIInitDialog(JFrame frame) 48 { 49 super(frame, "Please enter test unique identifier", true); 50 Container pane = getContentPane(); 51 pane.setLayout(new BorderLayout()); 52 pane.add(BorderLayout.NORTH, new JLabel("new test id:")); 53 pane.add(BorderLayout.CENTER, idFld = new JTextField("test#" + last_id, 20)); 54 pane.add(BorderLayout.SOUTH, okBtn = new JButton("OK")); 55 okBtn.addActionListener(this); 56 this.addWindowListener(new WindowCloser()); 57 } 58 59 60 public String ask() 61 { 62 pack(); 63 show(); 64 return value; 65 } 66 67 68 public void actionPerformed(ActionEvent e) 69 { 70 if (e.getSource() == okBtn) 71 { 72 ++last_id; 73 value = idFld.getText(); 74 } 75 this.dispose(); 76 } 77 78 class WindowCloser extends WindowAdapter 79 { 80 public void windowClosing(WindowEvent e) 81 { 82 GUIInitDialog.this.dispose(); 83 } 84 } 85 } 86 | Popular Tags |