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.JPanel ; 30 import javax.swing.JTextArea ; 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 GuiAlert extends JDialog implements ActionListener 44 { 45 protected JButton okBtn; 46 47 48 GuiAlert(JFrame frame, String title, String message) 49 { 50 super(frame, title, true); 51 Container pane = getContentPane(); 52 pane.setLayout(new BorderLayout ()); 53 if (message != null) 54 { 55 pane.add(BorderLayout.CENTER, new JTextArea (message, 5, 40)); 56 } 57 JPanel buttonPnl = new JPanel (); 58 buttonPnl.add(okBtn = new JButton ("OK")); 59 okBtn.addActionListener(this); 60 pane.add(BorderLayout.SOUTH, buttonPnl); 61 addWindowListener(new WindowCloser()); 62 } 63 64 65 public void alert() 66 { 67 pack(); 68 show(); 69 } 70 71 72 public void actionPerformed(ActionEvent e) 73 { 74 this.dispose(); 75 } 76 77 78 class WindowCloser extends WindowAdapter 79 { 80 public void windowClosing(WindowEvent e) 81 { 82 GuiAlert.this.dispose(); 83 } 84 } 85 } 86 | Popular Tags |