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

📄 filechooseutil.java

📁 掌握 JDBC 驱动程序的加载方法和JDBC-ODBC桥URL的形式; 掌握使用JDBC连接数据库的步骤; 掌握使用JDBC发送SQL语句的基本步骤; 掌握使用JDBC处理SQL查询结果集
💻 JAVA
字号:
package cn.edu.csu.oo.gui.project.view.panel;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class FileChooseUtil implements ActionListener{
  private JButton openBtn;
  private JButton saveBtn;
  private JPanel panel;
  private JFileChooser choose = new JFileChooser();
  private JFrame f;
  public FileChooseUtil(){
    openBtn = new JButton("打开文件");
    saveBtn = new JButton("保存文件");
    panel = new JPanel();
    panel.add(openBtn);
    panel.add(saveBtn);
    openBtn.addActionListener(this);
    saveBtn.addActionListener(this);
    f = new JFrame();
    f.add(panel);
    f.setSize(300,300);
    f.setVisible(true);
  }
  public void actionPerformed(ActionEvent e){
    if(e.getActionCommand().equals("打开文件")){
//      choose.addChoosableFileFilter(new ChooseFileFilter("xls"));
      choose.showOpenDialog(f);
    }else if(e.getActionCommand().equals("保存文件")){
//      choose.addChoosableFileFilter(new ChooseFileFilter("xls"));
      choose.showSaveDialog(f);
    }
  }
  /**
   * @param args
   */
  public static void main(String[] args) {
    new FileChooseUtil();
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -