⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myfiledialog.java

📁 java图形编程实例
💻 JAVA
字号:
//MyFileDialog.java
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");

    //注册动作监听
    b.addActionListener(this);

    f.add(b, BorderLayout.CENTER);
		f.pack();
    f.setVisible(true);
  }

  // 所有按钮的句柄
  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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -