日期:2014-05-20  浏览次数:20649 次

大神帮帮忙将这个代码打包成一个.jar或者一个.exe可执行文件
package test1;

import java.io.*;   


import java.awt.*;   
import javax.swing.*;   
import java.awt.event.*;   
 class hh implements ActionListener{   
 TruncateString a=new TruncateString();
String str1="";
 String str2="";
    JFrame frame=new JFrame("文件选择器实例");   
    JTabbedPane tabPane=new JTabbedPane();//选项卡布局   
    Container con=new Container();//布局1   
    Container con1=new Container();//布局2 
   
    JLabel label2=new JLabel("判断条件");   
    JLabel label1=new JLabel("选择文件");   
   
    JTextField text1=new JTextField();   
    JTextField text2=new JTextField();   
    JButton button1=new JButton("...");   
    JButton button2=new JButton("ok");   
    JFileChooser jfc=new JFileChooser();//文件选择器   
    hh(){   
        jfc.setCurrentDirectory(new File("d:\\"));//文件选择器的初始目录定为d盘   
        //下面两行是取得屏幕的高度和宽度   
        double lx=Toolkit.getDefaultToolkit().getScreenSize().getWidth();   
        double ly=Toolkit.getDefaultToolkit().getScreenSize().getHeight();   
        frame.setLocation(new Point((int)(lx/2)-150,(int)(ly/2)-150));//设定窗口出现位置   
        frame.setSize(300,150);//设定窗口大小   
        frame.setContentPane(tabPane);//设置布局   
       //下面设定标签等的出现位置和高宽   
        label1.setBounds(10,10,70,20);   
        label2.setBounds(10,30,100,20);   
        text2.setBounds(80,10,120,20);   
        text1.setBounds(80,30,120,20);   
        button1.setBounds(210,10,50,20);   
       button2.setBounds(210,30,50,20);   
           
        button1.addActionListener(this);//添加事件处理   
        button2.addActionListener(this);//添加事件处理   
        
        con.add(label2);  
        con.add(label1);   
        con.add(text1);   
        con.add(text2);   
        con.add(button1);   
        con.add(button2);   
        con.add(jfc);   
        tabPane.add("目录/文件选择",con);//添加布局1   
        //tabPane.add("暂无内容",con1);//添加布局2   
        frame.setVisible(true);//窗口可见   
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//使能关闭窗口,结束程序   
    }                                
    public void actionPerformed(ActionEvent e) {//事件处理   
    
        if(e.getSource().equals(button2)){
         try{
          str2=text1.getText();
          str2= str2.trim();//去掉多余空格和首尾括号
          
          BufferedWriter br1 = new BufferedWriter(new FileWriter("d:/d.txt"));
          
          
        
          File file = new File(str1);

          StringBuilder sb = new StringBuilder();
          String s ="";
         

BufferedReader br = new BufferedReader(new FileReader(file));