java.util.Properties; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFileChooser...public void actionPerformed(ActionEvent e) { if(e.getSource().equals(button_1)) { JFileChooser...chooser = new JFileChooser(); // 只许选择文件夹 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY...field_1.setText(dirName); } }else if(e.getSource().equals(button_2)) { JFileChooser...chooser = new JFileChooser(); // 只许选择文件夹 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY
public FileReadThread(EditFrame test ) { this.test = test; } @Override public void run() { JFileChooser...chooser = new JFileChooser("d:/"); chooser.setFileFilter(new FileFilter() {// 定义文件过滤器,仅显示文件夹和txt文本...Auto-generated catch block e.printStackTrace(); } } public Save(EditFrame area) { this.area = area; JFileChooser...chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(".")); chooser.setFileFilter(...= JFileChooser.APPROVE_OPTION) return; File f = chooser.getSelectedFile(); area.setSaveFileRoot
然后,可以使用JFileChooser类来创建一个文件选择对话框,并将其与按钮关联起来。当用户点击按钮时,可以通过JFileChooser选择文件,并将文件路径显示在文本框中。...java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFileChooser...button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser...fileChooser = new JFileChooser(); int result = fileChooser.showOpenDialog(frame);...if (result == JFileChooser.APPROVE_OPTION) { String filePath = fileChooser.getSelectedFile
java.util.Enumeration; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFileChooser...; JFileChooser jfc = new JFileChooser(); int result = jfc.showOpenDialog(this);...int num=0; File file = null; File desDir = null; if(result == JFileChooser.APPROVE_OPTION...; JFileChooser jfc = new JFileChooser(); int result = jfc.showOpenDialog(this);...File file = null; File desDir = null; String fileName = null; if(result==JFileChooser.APPROVE_OPTION
import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; import javax.swing.JFileChooser...(i == JOptionPane.OK_OPTION) { // 那么传输ok给发送端示意可以接收 output.write(“ok”.getBytes()); output.flush(); JFileChooser...jf = new JFileChooser(); // 存储到本地路径的夹子 jf.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); jf.showOpenDialog...); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser...jf = new JFileChooser(); jf.setFileSelectionMode(JFileChooser.FILES_ONLY); jf.showOpenDialog(SocketFileJFrame.this
目录 为组件设置边框 使用JToolBar创建工具条 JColorChooser和JFileChooser JColorChooser JFileChooser JOptionPane 基本概述 四种对话框演示...Swing提供了JColorChooser和JFileChooser这两种对话框,可以很方便的完成颜色的选择和本地文件的选择。... JFileChooser 的功能与AWT中的 FileDialog 基本相似,也是用于生成"打开文件"、"保存文件 "对话框。...JFileChooser使用步骤: 创建JFileChooser对象: JFileChooser chooser = new JFileChooser("D:\\a");//指定默认打开的本地磁盘路径..."); //创建打开文件对话框 JFileChooser chooser = new JFileChooser("."); //创建菜单条 JMenuBar jmb
result.png"))); } size = 1024*size;//1024 表示千字节再乘以size,获取的size得到实际的大小 } } JFileChooser...chooser = new JFileChooser(); // 只许选择文件 chooser.setFileSelectionMode(JFileChooser.FILES_ONLY...如果输入的文件大小大于源文件,要求重新输入 if(file_source.length() { showWarningInfo(); } JFileChooser...chooser = new JFileChooser(); // 只许选择文件夹 chooser.setFileSelectionMode(...JFileChooser.DIRECTORIES_ONLY); // 不允许同时选中多个文件夹 chooser.setMultiSelectionEnabled
public class Editor extends JFrame { public JTextPane textPane = new JTextPane(); //文本窗格d,编辑窗口 public JFileChooser...filechooser = new JFileChooser(); //文件选择器 public Editor() { super("简记"); Action[] actions=...actionPerformed(ActionEvent e) { int i=filechooser.showOpenDialog(Editor.this); //显示打开文件对话框 if(i==JFileChooser.APPROVE_OPTION...void actionPerformed(ActionEvent e) { int i=filechooser.showSaveDialog(Editor.this); if(i==JFileChooser.APPROVE_OPTION
java.io.FileWriter; import java.io.IOException; import javax.swing.JColorChooser; import javax.swing.JFileChooser...menuFileOpen.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser...chooser = new JFileChooser(); chooser.showOpenDialog(editer); File file = chooser.getSelectedFile...menuFileSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser...chooser = new JFileChooser(); chooser.showOpenDialog(editer); File file = chooser.getSelectedFile
第三步: 接下来我们需要获取到dimens原始文件,这里我们通过JFileChooser来获取文件,这里我们的类型是JFileChooser.FILES_ONLY只支持文件。...代码如下: 重点都已注释: JFileChooser jfc = new JFileChooser(); //只支持文件 jfc.setFileSelectionMode...(JFileChooser.FILES_ONLY); jfc.showDialog(new JLabel(), "选择"); File file = jfc.getSelectedFile
java.util.Scanner; 21 import javax.swing.ImageIcon; 22 import javax.swing.JButton; 23 import javax.swing.JFileChooser...text.setText(null); 96 } 97 else if(e.getSource()==button1){ 98 JFileChooser...chooser = new JFileChooser(); 99 chooser.setCurrentDirectory(new File("D:/")); //默认路径为D...盘 100 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);//文件选择模式,只读 101
OpenButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser...fc =new JFileChooser();//这个对象就是我们点击打开文件,出来的文件选择器 fc.setCurrentDirectory(new File("."))...;//指定当前默认目录 fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);//可以选择只打开文件或者文件夹...fc.setMultiSelectionEnabled(false);//是否允许多选文件 int i =fc.showOpenDialog(getContentPane()); if(i==JFileChooser.APPROVE_OPTION
path * @return */ public static String getDirPath(String filename, File path) { JFileChooser...parseDir = new JFileChooser(); parseDir.setCurrentDirectory(path); parseDir.setAcceptAllFileFilterUsed...parseDir.setSelectedFile(new File(filename)); int result = parseDir.showSaveDialog(null); if (result == JFileChooser.APPROVE_OPTION
import java.util.Collections; import java.util.List; import javax.swing.JButton; import javax.swing.JFileChooser...btnSelectFolder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser...fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY...int result = fileChooser.showOpenDialog(FolderSizeCalculator.this); if (result == JFileChooser.APPROVE_OPTION
be automatically scaled to 28*28 grayscale */ public static String fileChose(){ JFileChooser...fc = new JFileChooser(); int ret = fc.showOpenDialog(null); if (ret == JFileChooser.APPROVE_OPTION
list; private String[] arrs = {}; private String dbName ="xml"; public ImportFrame(){ JFileChooser...fileChooser=new JFileChooser("打开文件"); int isOpen=fileChooser.showOpenDialog(null);...fileChooser.setDialogTitle("打开文件"); if(isOpen==JFileChooser.APPROVE_OPTION){ filePath...fileChooser=new JFileChooser("打开文件"); int isOpen=fileChooser.showOpenDialog(null);...fileChooser.setDialogTitle("打开文件"); if(isOpen==JFileChooser.APPROVE_OPTION){ filePath
import java.net.URI; import java.net.URISyntaxException; import javax.swing.JButton; import javax.swing.JFileChooser...private JTextField text = null; // 显示文件地址的TextField private JButton b = null; // 浏览文件的按钮 private JFileChooser...com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception ex) { ex.printStackTrace(); } fc = new JFileChooser
cn.hncu.myJuniitApp; import java.awt.Dimension; import java.awt.Toolkit; import java.io.File; import javax.swing.JFileChooser...className); } private void btnFileNameActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser...jfc = new JFileChooser(); //打开文件选择对话框 int result = jfc.showOpenDialog(this);...File file=null; if(result==JFileChooser.APPROVE_OPTION){//选择了文件 file=jfc.getSelectedFile
java.awt.event.ActionListener; import java.io.File; import javax.swing.JButton; import javax.swing.JFileChooser...Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub JFileChooser...jfc = new JFileChooser(); //设置只能选中文件夹 jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY
领取专属 10元无门槛券
手把手带您无忧上云