Eclipse + Java + windowbuilder visual programming __ algorithm

Source: Internet
Author: User

Eclipse is really a good thing, you can write all kinds of languages on it, but a fatal problem is the interface design.

Of course you can use the code hand to play the interface, but unfortunately I was used vs and Xcode, must use the visual programming environment, so I will go to eclipse to install some visual plug-ins.

For writing Java programs, I chose Windowbuilder, a GUI plug-in that could develop SWT and swing.


Installation Tutorial: http://blog.csdn.net/aminfo/article/details/7731189, you can choose to download the installation package online or online installation.

Using Tutorial: http://wenku.baidu.com/view/9d71a809b52acfc789ebc9ba.html, describes how to create a new Java Project that contains a visual interface.


Windowbuilder provides a lot of plug-ins, also includes swing and swt, what people like to look at a person's preferences, online there are a lot of comparisons between them, do not know what to say = =

I prefer swing, which is good for cross-platform performance. Swing is generally a control that starts with J, such as JButton.

You should also write some more about the way the controls are used in the future.


The following image is the visual interface of Eclipse under Mac:

Lower left corner source/design can switch code and visual interface




Here is the generated code, which is very simple and understandable:

Package com.

OM.TESTJAVAWB;

Import Java.awt.EventQueue;
Import Javax.swing.JFrame;

Import Javax.swing.JButton;
Import Java.awt.BorderLayout;

Import javax.swing.SwingConstants;
Import Java.awt.event.MouseAdapter;
Import java.awt.event.MouseEvent;
Import Javax.swing.JPanel;
Import Javax.swing.JLabel;
Import Javax.swing.JComboBox;
Import javax.swing.JList;
Import Javax.swing.border.LineBorder;

Import Java.awt.Color;

	public class MyFrame {private JFrame frame;

	Private Mysecondframe frame2 = new Mysecondframe ();
	 /** * Launch the application. */public static void main (string[] args) {Eventqueue.invokelater (new Runnable () {public void run () {TR
					y {myframe window = new MyFrame ();
				Window.frame.setVisible (TRUE);
				catch (Exception e) {e.printstacktrace ();
	}
			}
		});
	 }/** * Create the application.
	* * Public MyFrame () {initialize ();
	 }/** * Initialize the contents of the frame.
* private void Initialize ()	{frame = new JFrame ();
		Frame.setbounds (100, 100, 450, 300);
		Frame.setdefaultcloseoperation (Jframe.exit_on_close);

		Frame.getcontentpane (). setlayout (New BorderLayout (0, 0));
		JPanel panel = new JPanel ();
		Panel.setborder (New Lineborder (new Color (0, 0, 0));
		Frame.getcontentpane (). Add (Panel, borderlayout.west);

		Panel.setlayout (New BorderLayout (0, 0));
		JButton Btnnewbutton = new JButton ("top button");

		Panel.add (Btnnewbutton, Borderlayout.north);
		Final JLabel labelshow = new JLabel ("");
		Labelshow.sethorizontalalignment (Swingconstants.center);
		
		Panel.add (Labelshow, Borderlayout.center);
		JLabel Lbldown = new JLabel ("Down");
		Lbldown.sethorizontalalignment (Swingconstants.center);
		
		Panel.add (Lbldown, Borderlayout.south);
		JLabel lblleft = new JLabel ("left");
		Lblleft.sethorizontalalignment (Swingconstants.center);
		
		Panel.add (Lblleft, borderlayout.west);
		JLabel lblright = new JLabel ("right");
	Lblright.sethorizontalalignment (Swingconstants.center);	Panel.add (Lblright, borderlayout.east);
		JLabel labeltitle = new JLabel ("Test window Builder");
		Labeltitle.sethorizontalalignment (Swingconstants.center);
		
		Frame.getcontentpane (). Add (Labeltitle, Borderlayout.north);
		JComboBox ComboBox = new JComboBox ();
		
		Frame.getcontentpane (). Add (ComboBox, borderlayout.center);
		JLabel lblright_1 = new JLabel ("right");
		
		Frame.getcontentpane (). Add (lblright_1, borderlayout.east);
		JLabel Lblbyoldme = new JLabel ("by Old Me Mory");
		Lblbyoldme.sethorizontalalignment (Swingconstants.right);

		Frame.getcontentpane (). Add (Lblbyoldme, Borderlayout.south); Btnnewbutton.addmouselistener (New Mouseadapter () {@Override public void mouseclicked (MouseEvent e) {label
				Show.settext ("click button");
				Frame2.show ();
			Frame2.frame.setVisible (TRUE);

	}
		});
 }

}


This is the interface for generating jar files to run under Mac OS X:




This is the same interface that the jar file runs under Win7:




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.