1 23 24 package org.objectweb.clif.console.lib.gui; 25 26 import javax.swing.JDialog ; 27 import javax.swing.JButton ; 28 import javax.swing.JFrame ; 29 import javax.swing.JLabel ; 30 import javax.swing.JPanel ; 31 import java.awt.event.ActionListener ; 32 import java.awt.event.ActionEvent ; 33 import java.awt.event.WindowAdapter ; 34 import java.awt.event.WindowEvent ; 35 import java.awt.Container ; 36 import java.awt.BorderLayout ; 37 38 39 43 public class GuiClearConfirm extends JDialog implements ActionListener 44 { 45 protected JButton okBtn, cancelBtn; 46 protected boolean value = false; 47 48 49 GuiClearConfirm(JFrame frame) 50 { 51 super(frame, "Test plan reset", true); 52 Container pane = getContentPane(); 53 pane.setLayout(new BorderLayout ()); 54 pane.add(BorderLayout.CENTER, new JLabel ("Current test plan will be discarded")); 55 JPanel buttonPnl = new JPanel (); 56 buttonPnl.add(okBtn = new JButton ("OK")); 57 okBtn.addActionListener(this); 58 buttonPnl.add(cancelBtn = new JButton ("cancel")); 59 cancelBtn.addActionListener(this); 60 pane.add(BorderLayout.SOUTH, buttonPnl); 61 addWindowListener(new WindowCloser()); 62 } 63 64 65 public boolean ask() 66 { 67 pack(); 68 show(); 69 return value; 70 } 71 72 73 public void actionPerformed(ActionEvent e) 74 { 75 if (e.getSource() == okBtn) 76 { 77 value = true; 78 } 79 this.dispose(); 80 } 81 82 83 class WindowCloser extends WindowAdapter 84 { 85 public void windowClosing(WindowEvent e) 86 { 87 GuiClearConfirm.this.dispose(); 88 } 89 } 90 } 91 | Popular Tags |