Specific build Tools
(1)
(2)
(3)
(4)
Source:
Example.java
[Java]View Plaincopyprint?
- Package Org.qiailin.jframe;
- Import Java.awt.Container;
- Import Java.awt.Point;
- Import Java.awt.Toolkit;
- Import java.awt.event.ActionEvent;
- Import Java.awt.event.ActionListener;
- Import Java.io.File;
- Import Javax.swing.JButton;
- Import Javax.swing.JFileChooser;
- Import Javax.swing.JFrame;
- Import Javax.swing.JLabel;
- Import Javax.swing.JOptionPane;
- Import Javax.swing.JTabbedPane;
- Import Javax.swing.JTextField;
- /**
- * Because see a lot of friends in the trial temporary time to write a simple case source stacking up, need to see, because the time rush to do rough January 4, 2011 23:22:31
- *
- * @author Paint Arryn QQ 172794299 e-mail [email protected]
- *
- */
- Public class jexample implements ActionListener {
- JFrame frame = new JFrame ("Lacquer Arryn-example"); //Frame layout
- JTabbedPane Tabpane = new JTabbedPane (); //Tab Layout
- Container con = new Container (); //
- JLabel Label1 = new JLabel ("file directory");
- JLabel Label2 = new JLabel ("Select File");
- JTextField Text1 = new JTextField (); path of the//TextField directory
- JTextField Text2 = new JTextField (); //path to file
- JButton button1 = new JButton ("..."); //Select
- JButton button2 = new JButton ("..."); //Select
- JFileChooser JFC = new jfilechooser (); //File selector
- JButton Button3 = new JButton ("OK"); //
- Jexample () {
- Jfc.setcurrentdirectory (new file ("d://"));//The initial directory of the file selector is set to D-Disk
- Double lx = Toolkit.getdefaulttoolkit (). Getscreensize (). GetWidth ();
- Double ly = Toolkit.getdefaulttoolkit (). Getscreensize (). GetHeight ();
- Frame.setlocation (new point ((int) (LX/ 2)- (int) (ly/ 2)- ()); //Set window where it appears
- Frame.setsize (280, ); //Set window size
- Frame.setcontentpane (Tabpane); //Set layout
- Label1.setbounds (ten , ten , +);
- Text1.setbounds ( the Ten , the );
- Button1.setbounds ( all, ten , +);
- Label2.setbounds (ten , A. );
- Text2.setbounds ( +--) );
- Button2.setbounds ( a);
- Button3.setbounds ( A. );
- Button1.addactionlistener (this); //Add event handling
- Button2.addactionlistener (this); //Add event handling
- Button3.addactionlistener (this); //Add event handling
- Con.add (Label1);
- Con.add (Text1);
- Con.add (button1);
- Con.add (Label2);
- Con.add (TEXT2);
- Con.add (button2);
- Con.add (Button3);
- Frame.setvisible (true); //Window visible
- Frame.setdefaultcloseoperation (Jframe.exit_on_close); //Enable to close the window and end the program
- Tabpane.add ("1 Panel", con); //Add layout 1
- }
- /**
- * Method of time monitoring
- */
- Public void actionperformed (ActionEvent e) {
- //TODO auto-generated method stub
- if (E.getsource (). Equals (button1)) { //What is the button that determines the trigger method
- Jfc.setfileselectionmode (1); //settings can only be selected to folder
- int state = jfc.showopendialog (null); //This sentence is the trigger statement that opens the file selector interface
- if (state = = 1) {
- return ;
- } Else {
- File f = jfc.getselectedfile (); //F for the selected directory
- Text1.settext (F.getabsolutepath ());
- }
- }
- //Bind to selection file, select File Event
- if (E.getsource (). Equals (Button2)) {
- Jfc.setfileselectionmode (0); //settings can only be selected to file
- int state = jfc.showopendialog (null); //This sentence is the trigger statement that opens the file selector interface
- if (state = = 1) {
- return ; //Revoke return
- } Else {
- File f = jfc.getselectedfile (); //F for the selected file
- Text2.settext (F.getabsolutepath ());
- }
- }
- if (E.getsource (). Equals (Button3)) {
- //Pop-up dialog can change the parameters inside the concrete depends on everyone to see, the time is very short
- Joptionpane.showmessagedialog (null, "Popup Instance of the dialog box, welcome you--Paint Irene! ", " hint ", 2);
- }
- }
- Public static void main (string[] args) {
- New jexample ();
- }
- }
This step takes note of the class that selects the Main method
Simple export is OK, packaging can be used Ant and Maven, of course, here does not introduce interested can go to see
Interested can go to download
Of course, if you have friends who want to get your jar files out of Java, you can generate EXE files where you can use exe4j
Of course here exe4j believe that everyone will use it will not use the words can go to Google.