Changeset 2944 in osm for applications
- Timestamp:
- 2007-05-19T23:48:54+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/MetaAction.java
r2936 r2944 6 6 import java.awt.BorderLayout; 7 7 import java.awt.event.ActionEvent; 8 import java.awt.event.KeyEvent; 9 import java.awt.event.KeyListener; 8 10 import java.beans.PropertyChangeEvent; 9 11 import java.beans.PropertyChangeListener; … … 19 21 import javax.swing.JLabel; 20 22 import javax.swing.JOptionPane; 23 import javax.swing.JTextField; 21 24 22 import at.dallermassl.josm.plugin.surveyor.action.DialogClosingThread; 25 import test.DialogClosingThread; 26 23 27 24 28 import livegps.LiveGpsData; … … 111 115 System.out.println("Surveyor: no gps data available!"); 112 116 } 113 } 114 115 public void openDialog(JFrame frame) { 116 final JOptionPane optionPane = new JOptionPane("The only way to close this dialog is by\n" 117 + "pressing one of the following buttons.\n" + "Do you understand?", 118 JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); 119 120 final JDialog dialog = new JDialog(frame, "Click a button", true); 121 dialog.setContentPane(optionPane); 122 optionPane.addPropertyChangeListener(new PropertyChangeListener() { 123 public void propertyChange(PropertyChangeEvent e) { 124 String prop = e.getPropertyName(); 125 126 if (dialog.isVisible() && (e.getSource() == optionPane) 127 && (prop.equals(JOptionPane.VALUE_PROPERTY))) { 128 // If you were going to check something 129 // before closing the window, you'd do 130 // it here. 131 dialog.setVisible(false); 132 } 133 } 134 }); 135 Thread closer = new DialogClosingThread(dialog); 136 closer.start(); 137 dialog.pack(); 138 dialog.setVisible(true); 139 140 141 System.out.println("value: " + optionPane.getValue().getClass()); 142 143 // int value = ((Integer) optionPane.getValue()).intValue(); 144 // if (value == JOptionPane.YES_OPTION) { 145 // System.out.println("yes"); 146 // } else if (value == JOptionPane.NO_OPTION) { 147 // System.out.println("no"); 148 // } 149 117 JFrame frame = SurveyorPlugin.getSurveyorFrame(); 118 if(frame != null && frame.isVisible()) { 119 frame.toFront(); 120 } 150 121 } 151 122 … … 156 127 this.gpsDataSource = gpsDataSource; 157 128 } 158 159 public static void main(String[] args) {160 //1. Create the frame.161 JFrame frame = new JFrame("FrameDemo");162 163 //2. Optional: What happens when the frame closes?164 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);165 166 //3. Create components and put them in the frame.167 //...create emptyLabel...168 frame.getContentPane().add(new JLabel("test"), BorderLayout.CENTER);169 170 //4. Size the frame.171 frame.pack();172 frame.setSize(600,400);173 frame.setLocation(0,0);174 175 //5. Show it.176 frame.setVisible(true);177 System.out.println("after visible");178 new MetaAction().openDialog(frame);179 }180 181 129 }
Note:
See TracChangeset
for help on using the changeset viewer.