安装windowbuilder来实现java的可视化编程

安装windowbuilder来实现java的可视化编程

直接在线安装的windowbuilder

一.找到对应版本的windowbuilder

打开这个链接:http://www.eclipse.org/windowbuilder/download.php

显示eclipse的版本号和对应的插件链接

eclipse的版本号可以在eclipse的help中查看,然后复制你对应版本号后面的link连接

二.在eclipse在线更新

打开eclipse–>help–>Install New Software

在location中粘贴刚才复制的链接,确定,等待加载插件信息

然后显示了插件,全选然后一直Next安装就行了,安装结束会提示你重启eclipse,重启完成就成功了。

三.使用方法

new–>Project 然后选择下图

然后像正常创建java工程一样,创建工程
然后在新建的工程的src里,new --> Other
在这里插入图片描述

示例代码:(自己用windowbuilder写的学生管理系统的一个门户页面,有错请指正)

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Color;
import java.awt.Component;

import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JPasswordField;
import javax.swing.JPopupMenu;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;

import java.awt.Choice;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Scanner;
import java.awt.event.ActionEvent;
import javax.swing.JComboBox;
import javax.swing.JScrollBar;
import java.awt.Label;
import javax.swing.Box;
import javax.swing.JFormattedTextField;
import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;

public class student extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JPasswordField passwordField;
	private Component panel;
	public JPanel pnluser;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					student frame = new student();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public student() {
		
		
			
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(360, 120, 1051, 720);
		setLocationRelativeTo(null);
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu mnNewMenu = new JMenu("菜单(M)");
		menuBar.add(mnNewMenu);
		
		JMenuItem menuItem = new JMenuItem("退出");
		menuItem.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		mnNewMenu.add(menuItem);
		contentPane = new JPanel();
		contentPane.setToolTipText("学生管理系统");
		contentPane.setBackground(new Color(127, 255, 212));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		setTitle("学生管理系统");
		contentPane.setLayout(null);
		
		JLabel label1 = new JLabel("      学生管理系统");
		label1.setForeground(new Color(255, 99, 71));
		label1.setFont(new Font("华文新魏", Font.BOLD, 84));
		label1.setBounds(82, 13, 756, 197);
		contentPane.add(label1);

		//用户名
		
				JLabel label_1 = new JLabel("用户名:");
				label_1.setForeground(new Color(255, 255, 255));
				JLabel label_2 = new JLabel("密   码:");
				label_2.setForeground(new Color(255, 255, 255));
				label_1.setFont(new Font("华文楷体", Font.BOLD, 30));
				label_2.setFont(new Font("华文楷体", Font.BOLD, 30));
				label_2.setBounds(579, 338, 147, 35);
				contentPane.add(label_2);
				label_1.setBounds(579, 267, 147, 35);
				contentPane.add(label_1);
				textField = new JTextField("");
				
				passwordField = new JPasswordField("");
				
				textField.setBounds(726, 269, 236, 35);
				contentPane.add(textField);
				textField.setFont(new Font("华文楷体", Font.BOLD, 23));
				textField.setColumns(10);
				passwordField.setBounds(726, 340, 236, 35);
				contentPane.add(passwordField);
				passwordField.setFont(new Font("华文楷体", Font.BOLD, 23));				
		
		JButton button = new JButton("登陆");
		button.setBackground(new Color(102, 204, 255));
		button.setFont(new Font("宋体", Font.PLAIN, 27));
		button.addActionListener(new ActionListener() {
			//private String[] args;

			public void actionPerformed(ActionEvent e) {
				String name = textField.getText();
				String pwd = String.valueOf(passwordField.getPassword());
				if(name.equals("")){
					JOptionPane.showMessageDialog(null,"账号不能为空","错误",JOptionPane.ERROR_MESSAGE);
					return;
				}
					else if (pwd.equals("")){
							JOptionPane.showMessageDialog(null,"密码不能为空","错误",JOptionPane.ERROR_MESSAGE);
							return;
				}
					else if(name.equals("12197405209")&&pwd.equals("111111")||name.equals("admin")&&pwd.equals("000000")){
						
						
						JOptionPane.showMessageDialog(null,"登陆成功","通知",JOptionPane.OK_CANCEL_OPTION);
						M1 m1 = new M1();
						m1.setVisible(true);;
						dispose();//释放资源
				}
					else{
						JOptionPane.showMessageDialog(null,"账号或密码错误","错误",JOptionPane.ERROR_MESSAGE);
						textField.setText("");
						passwordField.setText("");
							return;
				}
			}
		});
		button.setBounds(672, 489, 121, 42);
		contentPane.add(button);
		
		
		JButton button_1 = new JButton("退出");
		button_1.setBackground(new Color(102, 204, 255));
		button_1.setFont(new Font("宋体", Font.PLAIN, 27));
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);;
			}
		});
		button_1.setBounds(849, 489, 113, 42);
		contentPane.add(button_1);
		
		JLabel label_3 = new JLabel("\u25C6请输入正确的用户名和密码!!!");
		label_3.setForeground(new Color(255, 0, 0));
		label_3.setFont(new Font("华文楷体", Font.BOLD, 30));
		label_3.setBounds(214, 414, 552, 42);
		contentPane.add(label_3);
		
		JButton button_2 = new JButton("重置");
		button_2.setBackground(new Color(255, 102, 255));
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				textField.setText("");
				passwordField.setText("");
			}
		});
		button_2.setFont(new Font("宋体", Font.PLAIN, 27));
		button_2.setBounds(849, 544, 113, 35);
		contentPane.add(button_2);
		
		Label label = new Label("\u25C6最终解释权归百梦空间工作室所有。");
		label.setBackground(new Color(255, 255, 255));
		label.setFont(new Font("Microsoft JhengHei UI", Font.BOLD, 17));
		label.setBounds(601, 622, 301, 25);
		contentPane.add(label);
		
		JLabel label_4 = new JLabel("");
		label_4.setIcon(new ImageIcon(student.class.getResource("/\u5B66\u751F\u7BA1\u7406\u7CFB\u7EDF/photo/u=2445272083,1656948159&fm=193.jpg")));
		label_4.setBounds(-199, 0, 1240, 657);
		contentPane.add(label_4);
		
		JLabel label_5 = new JLabel("");
		label_5.setIcon(new ImageIcon("D:\\Users\\\u6211\u7684\u684C\u9762\\\u5DE5\u4F5C\u5BA4\\uugai.com_1587526859223.jpg"));
		label_5.setBounds(0, 35, 260, 109);
		contentPane.add(label_5);
	}
}

我是自学的这个插件,希望可以帮到你们。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值