1 package jimm.datavision.gui; 2 import jimm.util.I18N; 3 import java.awt.Frame ; 4 import java.awt.Dimension ; 5 import java.awt.BorderLayout ; 6 import java.awt.event.ActionListener ; 7 import java.awt.event.ActionEvent ; 8 import javax.swing.*; 9 10 15 public class StatusDialog extends JDialog { 16 17 protected JLabel label; 18 protected boolean cancelled; 19 20 27 public StatusDialog(Frame parent, String title, boolean displayCancelButton, 28 String initialString) 29 { 30 super(parent, title, false); 31 32 JPanel panel = new JPanel(); 33 panel.setLayout(new BorderLayout ()); 34 panel.add(label = new JLabel(), BorderLayout.CENTER); 35 label.setHorizontalAlignment(SwingConstants.CENTER); 36 37 if (displayCancelButton) { 38 JPanel buttonPanel = new JPanel(); 39 JButton button = new JButton(I18N.get("GUI.cancel")); 40 buttonPanel.add(button); 41 button.addActionListener(new ActionListener () { 42 public void actionPerformed(ActionEvent e) { 43 cancelled = true; 44 update(I18N.get("StatusDialog.cancelling")); 45 } 46 }); 47 panel.add(buttonPanel, BorderLayout.SOUTH); 48 } 49 50 if (initialString != null) 51 label.setText(initialString); 52 53 panel.setPreferredSize(new Dimension (300, 100)); 54 getContentPane().add(panel); 55 56 pack(); 57 setVisible(true); 58 } 59 60 public boolean isCancelled() { return cancelled; } 61 62 public void update(String message) { 63 label.setText(message); 64 } 65 66 } 67 | Popular Tags |