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);
}
}