Bug #5725 » MainClass.java
1 |
package org.kepler.util; |
---|---|
2 |
|
3 |
import java.awt.Button; |
4 |
import java.awt.FileDialog; |
5 |
import java.awt.Frame; |
6 |
import java.awt.event.ActionEvent; |
7 |
import java.awt.event.ActionListener; |
8 |
|
9 |
public class MainClass extends Frame { |
10 |
FileDialog fd; |
11 |
|
12 |
MainClass() { |
13 |
super("MainClass"); |
14 |
setSize(200, 200); |
15 |
|
16 |
fd = new FileDialog(new Frame(), "title", FileDialog.SAVE); |
17 |
|
18 |
Button b; |
19 |
add(b = new Button("Browse...")); // Create and add a Button |
20 |
|
21 |
b.addActionListener(new ActionListener() { |
22 |
public void actionPerformed(ActionEvent e) { |
23 |
fd.setVisible(true); |
24 |
String fn = fd.getFile(); |
25 |
if (fn == null){ |
26 |
System.out.println("You cancelled the choice"); |
27 |
}
|
28 |
else{ |
29 |
System.out.println("You chose " + fn); |
30 |
}
|
31 |
}
|
32 |
});
|
33 |
}
|
34 |
|
35 |
public static void main(String[] a) { |
36 |
new MainClass().setVisible(true); |
37 |
}
|
38 |
}
|