1 24 25 26 package org.objectweb.clif.analyser.lib.gui; 27 28 import javax.swing.*; 29 import java.awt.event.ActionListener ; 30 import java.awt.event.ActionEvent ; 31 import java.awt.event.WindowAdapter ; 32 import java.awt.event.WindowEvent ; 33 import java.awt.*; 34 35 36 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 GuiInitDialog(JFrame frame,String dialogType) 61 { 62 super(frame, "Chose an option", true); 63 64 if(dialogType.equals("option")) 65 { 66 Container pane = getContentPane(); 67 pane.setLayout(new BorderLayout()); 68 String [] option = new String [4]; 69 option[0] = "1 - hit per second"; 70 option[1] = "2 - hit per ten seconds"; 71 option[2] = "3 - hit per minute"; 72 option[3] = "4 - response time"; 73 pane.add(BorderLayout.NORTH, new JList(option)); 74 pane.add(BorderLayout.CENTER, idFld = new JTextField("4", 20)); 75 pane.add(BorderLayout.SOUTH, okBtn = new JButton("OK")); 76 okBtn.addActionListener(this); 77 this.addWindowListener(new WindowCloser()); 78 } 79 } 80 81 GuiInitDialog(JFrame frame,int inutile) 82 { 83 super(frame, "Enter the rule's name that you want to start/stop", true); 84 Container pane = getContentPane(); 85 pane.setLayout(new BorderLayout()); 86 pane.add(BorderLayout.NORTH, new JLabel("")); 87 pane.add(BorderLayout.CENTER, idFld = new JTextField("", 20)); 88 pane.add(BorderLayout.SOUTH, okBtn = new JButton("OK")); 89 okBtn.addActionListener(this); 90 this.addWindowListener(new WindowCloser()); 91 } 92 93 94 public String ask() 95 { 96 pack(); 97 show(); 98 return value; 99 } 100 101 102 public void actionPerformed(ActionEvent e) 103 { 104 if (e.getSource() == okBtn) 105 { 106 ++last_id; 107 value = idFld.getText(); 108 } 109 this.dispose(); 110 } 111 112 class WindowCloser extends WindowAdapter 113 { 114 public void windowClosing(WindowEvent e) 115 { 116 GuiInitDialog.this.dispose(); 117 } 118 } 119 } 120 | Popular Tags |