1 3 package org.jgroups.demos.wb; 4 5 6 import java.awt.*; 7 import java.awt.event.ActionEvent ; 8 import java.awt.event.ActionListener ; 9 10 11 12 public class MessageDialog extends Dialog implements ActionListener { 13 private final TextArea text=new TextArea(""); 14 private final Font default_font=new Font("Helvetica",Font.PLAIN,12); 15 16 17 public MessageDialog(Frame parent, String sender, String msg) { 18 super(parent, "Msg from " + sender); 19 20 Button ok=new Button("OK"); 21 22 setLayout(new BorderLayout()); 23 setBackground(Color.white); 24 25 ok.setFont(default_font); 26 text.setFont(default_font); 27 text.setEditable(false); 28 text.setText(msg); 29 30 ok.addActionListener(this); 31 32 add("Center", text); 33 add("South", ok); 34 35 setSize(300, 150); 36 37 Point my_loc=parent.getLocation(); 38 my_loc.x+=50; 39 my_loc.y+=150; 40 setLocation(my_loc); 41 Toolkit.getDefaultToolkit().beep(); 42 show(); 43 } 44 45 46 public void actionPerformed(ActionEvent e) { 47 dispose(); 48 } 49 50 51 } 52 | Popular Tags |