1 43 44 package org.jfree.ui; 45 46 import java.awt.Dialog ; 47 import java.awt.Frame ; 48 import java.awt.event.ActionEvent ; 49 import java.awt.event.ActionListener ; 50 import java.util.ResourceBundle ; 51 52 import javax.swing.BorderFactory ; 53 import javax.swing.JButton ; 54 import javax.swing.JDialog ; 55 import javax.swing.JPanel ; 56 57 62 public class StandardDialog extends JDialog implements ActionListener { 63 64 65 private boolean cancelled; 66 67 68 protected static final ResourceBundle localizationResources = 69 ResourceBundle.getBundle("org.jfree.ui.LocalizationBundle"); 70 71 78 public StandardDialog(final Frame owner, final String title, final boolean modal) { 79 super(owner, title, modal); 80 this.cancelled = false; 81 } 82 83 90 public StandardDialog(final Dialog owner, final String title, final boolean modal) { 91 super(owner, title, modal); 92 this.cancelled = false; 93 } 94 95 100 public boolean isCancelled() { 101 return this.cancelled; 102 } 103 104 109 public void actionPerformed(final ActionEvent event) { 110 final String command = event.getActionCommand(); 111 if (command.equals("helpButton")) { 112 } 114 else if (command.equals("okButton")) { 115 this.cancelled = false; 116 setVisible(false); 117 } 118 else if (command.equals("cancelButton")) { 119 this.cancelled = true; 120 setVisible(false); 121 } 122 } 123 124 130 protected JPanel createButtonPanel() { 131 132 final L1R2ButtonPanel buttons = new L1R2ButtonPanel(localizationResources.getString("Help"), 133 localizationResources.getString("OK"), 134 localizationResources.getString("Cancel")); 135 136 final JButton helpButton = buttons.getLeftButton(); 137 helpButton.setActionCommand("helpButton"); 138 helpButton.addActionListener(this); 139 140 final JButton okButton = buttons.getRightButton1(); 141 okButton.setActionCommand("okButton"); 142 okButton.addActionListener(this); 143 144 final JButton cancelButton = buttons.getRightButton2(); 145 cancelButton.setActionCommand("cancelButton"); 146 cancelButton.addActionListener(this); 147 148 buttons.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0)); 149 return buttons; 150 } 151 152 } 153 | Popular Tags |