例。如何将以下程序打包成。可执行的jar文件。
程序源码如下。
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
class HuaMiao extends JFrame
implements ActionListener{
GridLayout GridLayout1=new GridLayout(4,2);
JLabel JLabel1=new JLabel("时");
JLabel JLabel2=new JLabel("分");
JLabel JLabel3=new JLabel("秒");
JButton JButton1=new JButton("显示");
JTextField JTextField1=new JTextField(10);
JTextField JTextField2=new JTextField(10);
JTextField JTextField3=new JTextField(10);
JTextField JTextField4=new JTextField(20);
HuaMiao(){
super("化秒程序");
setSize(200,350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().setLayout(GridLayout1);
this.getContentPane().add(JLabel1);
this.getContentPane().add(JTextField1);
this.getContentPane().add(JLabel2);
this.getContentPane().add(JTextField2);
this.getContentPane().add(JLabel3);
this.getContentPane().add(JTextField3);
this.getContentPane().add(JButton1);
this.getContentPane().add(JTextField4);
JButton1.addActionListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent e){
String hour,fen,miao;
Object b=e.getSource();
if(b==JButton1){
hour=JTextField1.getText();
fen=JTextField2.getText();
miao=JTextField3.getText();
double hour1=Double.parseDouble(hour);
double fen1=Double.parseDouble(fen);
double miao1=Double.parseDouble(miao);
double a=hour1*3600+fen1*60+miao1;
Double b1=new Double(a);
JTextField4.setText(b1.toString());
}
}
public static void main(String [] args){
HuaMiao HuaMiao=new HuaMiao();
}
}