JAVA 用什么做界面程序

JAVA 用什么做界面程序,第1张

Swing是一个用于开发Java应用程序用户界面的开发工具包

以抽象窗口工具包(AWT)为基础使跨平台应用程序可以使用任何可插拔的外观风格。Swing开发人员只用很少的代码就可以利用Swing丰富、灵活的功能和模块化组件来创建优雅的用户界面。

工具包中所有的包都是以swing作为名称,例如javaxswing,javaxswingevent。

java编写图形界面需要用到swing等组件,可以在eclipse中安装windowbuilder来开发窗体,自动生成窗体代码,然后自己再根据需要修改,如:

package mainFrame;

import javaawtEventQueue;

import javaawteventMouseAdapter;

import javaawteventMouseEvent;

import javaxswingImageIcon;

import javaxswingJButton;

import javaxswingJCheckBox;

import javaxswingJFrame;

import javaxswingJLabel;

import javaxswingJPanel;

import javaxswingJPasswordField;

import javaxswingJTextField;

import javaxswingSwingConstants;

import javaxswingUIManager;

import javaxswingUnsupportedLookAndFeelException;

import javaxswingborderEmptyBorder;

public class Mian_login extends JFrame {

private JPanel contentPane;

private JTextField text_LoginName;

private JPasswordField Login_password;

/

Launch the application

/

public static void main(String[] args) {

EventQueueinvokeLater(new Runnable() {

@Override

public void run() {

try {

Mian_login frame = new Mian_login();

framesetVisible(true);

} catch (Exception e) {

eprintStackTrace();

}

}

});

}

/

Create the frame

/

public Mian_login() {

setDefaultCloseOperation(JFrameEXIT_ON_CLOSE);

setBounds(500, 200, 443, 300);

setResizable(false);

setTitle("登 录");

/获取系统按钮样式/

String lookAndFeel = UIManagergetSystemLookAndFeelClassName();

try {

UIManagersetLookAndFeel(lookAndFeel);

} catch (ClassNotFoundException e1) {

e1printStackTrace();

} catch (InstantiationException e1) {

e1printStackTrace();

} catch (IllegalAccessException e1) {

e1printStackTrace();

} catch (UnsupportedLookAndFeelException e1) {

e1printStackTrace();

}

contentPane = new JPanel();

contentPanesetBorder(new EmptyBorder(5, 5, 5, 5));

setContentPane(contentPane);

contentPanesetLayout(null);

JPanel panel = new JPanel();

panelsetOpaque(false);

panelsetBounds(0, 0, 434, 272);

contentPaneadd(panel);

panelsetLayout(null);

JButton btn_Login = new JButton("\u767B\u5F55");

btn_LoginaddMouseListener(new MouseAdapter() {

@Override

public void mouseClicked(MouseEvent e) {

}

});

btn_LoginsetBounds(88, 195, 70, 23);

paneladd(btn_Login);

JButton btn_cancel = new JButton("\u53D6\u6D88");

btn_canceladdMouseListener(new MouseAdapter() {

@Override

public void mouseClicked(MouseEvent e) {

dispose();

}

});

btn_cancelsetBounds(268, 195, 70, 23);

paneladd(btn_cancel);

JLabel lblNewLabel_name = new JLabel("\u7528\u6237\u540D");

lblNewLabel_namesetHorizontalAlignment(SwingConstantsCENTER);

lblNewLabel_namesetOpaque(true);

lblNewLabel_namesetBounds(88, 48, 70, 23);

paneladd(lblNewLabel_name);

JLabel lblNewLabel_passwd = new JLabel("\u5BC6\u7801");

lblNewLabel_passwdsetHorizontalAlignment(SwingConstantsCENTER);

lblNewLabel_passwdsetOpaque(true);

lblNewLabel_passwdsetBounds(88, 102, 70, 23);

paneladd(lblNewLabel_passwd);

JCheckBox chckbx_remember = new JCheckBox("\u8BB0\u4F4F\u5BC6\u7801");

chckbx_remembersetBounds(102, 150, 84, 23);

paneladd(chckbx_remember);

text_LoginName = new JTextField();

text_LoginNamesetBounds(182, 48, 156, 23);

paneladd(text_LoginName);

text_LoginNamesetColumns(10);

Login_password = new JPasswordField();

Login_passwordsetBounds(182, 102, 156, 23);

paneladd(Login_password);

JCheckBox chckbx_AutoLogin = new JCheckBox("\u81EA\u52A8\u767B\u5F55");

chckbx_AutoLoginsetBounds(233, 150, 84, 23);

paneladd(chckbx_AutoLogin);

JLabel Label_background = new JLabel("");

Label_backgroundsetIcon(new ImageIcon("E:\\JAVA_workplace\\0002-\u754C\u9762\u8BBE\u8BA1\\images\\background3jpg"));

Label_backgroundsetBounds(0, 0, 437, 272);

contentPaneadd(Label_background);

}

}

以上就是关于JAVA 用什么做界面程序全部的内容,包括:JAVA 用什么做界面程序、怎样用java编写图形界面的Application程序、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10169205.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-06
下一篇 2023-05-06

发表评论

登录后才能评论

评论列表(0条)

保存