1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
| package p005;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
*
* @author Jeffrey
*/
public class Fenetre extends JFrame implements ActionListener {
private JPanel pan = new JPanel();
private JButton button1 = new JButton("Utiliser la coupe miniere par defaut");
private JButton button2 = new JButton("Autre coupe miniere");
private String chemin;
private int choix;
private boolean sortie=false;
public void Fenetre() {
this.setTitle("Traitement supervisé pour le géoréférencement de coupes minières scannées");
this.setSize(300, 300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
button1.addActionListener(this);
button2.addActionListener(this);
this.setLayout(new GridLayout(2, 1));
this.getContentPane().add(button1);
this.getContentPane().add(button2);
this.setVisible(true);
do{
}while(sortie==false);
sortie=false;
switch (choix) {
case 1 :
chemin = "c://im/test_.tif";
break;
case 2 :
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
}
else {
chemin = "c://im.test_.tif";
}
break;
}
}
public void actionPerformed(ActionEvent e) {
if ( e.getSource() == button1) {
choix = 1;
sortie = true;
}
if (e.getSource() == button2) {
choix = 2;
sortie = true;
}
}
} |
Partager