第一范文网 - 专业文章范例文档资料分享平台

java swt选择文件对话框

来源:用户分享 时间:2025/8/26 5:40:38 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

package com.fh.zhuanhuan;

import java.awt.FlowLayout;

import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedReader; import java.io.File;

import java.io.FileReader;

import javax.swing.Box; import javax.swing.JButton;

import javax.swing.JFileChooser; import javax.swing.JFrame;

import javax.swing.JOptionPane; import javax.swing.JPanel;

import com.fh.readfile.FileRead;

public class ZhuanHuanMain extends JFrame { /** * @param args * @author 王辉 */ private JButton bt,bt2; private Box box; private JFileChooser jc; private String filepath=\ public ZhuanHuanMain(){ this.setTitle(\经纬度转换小程序\ this.setLayout(new FlowLayout()); box=Box.createVerticalBox(); // bt2=new JButton(\选择文件名称\ box.add(bt2); bt=new JButton(\转换\ box.add(bt); bt.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {

// // // // // // // // // // //开始转化 if(filepath==null||filepath.equals(\ show(\没有选择文件\ }else{ new FileRead().readerfile(filepath); } } }); bt2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jc=new JFileChooser(); jc.showSaveDialog(null); if(jc.getSelectedFile()!=null){ filepath=jc.getSelectedFile().getAbsolutePath(); bt2.setText(\文件名称:\ }else{ show(\没有选择文件\ } } }); this.add(box); this.setResizable(false); this.setVisible(true); this.setSize(400, 120); }

public static void main(String[] args) { // TODO Auto-generated method stub File file=new File(\ try { FileReader fr=new FileReader(file); BufferedReader br=new BufferedReader(fr); String filepath=br.readLine(); System.out.println(filepath); new FileRead().readerfile(filepath); } catch (Exception e) { e.printStackTrace(); } new ZhuanHuanMain(); }

public static void show(String msg){ JOptionPane.showMessageDialog(null,msg);

}

}

搜索更多关于: java swt选择文件对话框 的文档
java swt选择文件对话框.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c48frg7jl6d9lpyv24ewg_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top