myfiledialog.java
来自「java初学者经典小例子」· Java 代码 · 共 38 行
JAVA
38 行
import java.awt.*;
import java.awt.event.*;
public class MyFileDialog implements ActionListener {
private Frame f;
private FileDialog fd;
private Button b;
public void go() {
f = new Frame("FileDialog");
fd = new FileDialog(f, "FileDialog");
b = new Button("Launch FileDialog");
// Register listener for buttons.
b.addActionListener(this);
f.add(b, BorderLayout.CENTER);
f.pack();
f.setVisible(true);
}
// Handler for all buttons.
public void actionPerformed( ActionEvent ae) {
String buttonPressed = ae.getActionCommand();
if (buttonPressed.equals("Launch FileDialog")) {
fd.setVisible(true);
} else {
fd.setVisible(false);
}
}
public static void main (String args[]) {
MyFileDialog myFileDialog = new MyFileDialog();
myFileDialog.go();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?