java swing qq_Java Swing仿QQ登录界面效果

本文实例为大家分享了Java Swing仿QQ登录界面展示的具体代码,供大家参考,具体内容如下

闲来无事将早些时候已实现的QQ登录界面再实现了一遍,纯手工打造(意思是没有用NetBeans、MyEclipse的拖动功能)。

源代码如下:

package ibees.qq;

import java.awt.BorderLayout;

import java.net.URL;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JCheckBox;

import javax.swing.JComboBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JPasswordField;

import javax.swing.JTextField;

/**

* 仿QQ登录界面,仅供学习参考,涉及到的有窗口居中、JPanel、LayoutManager的使用

* @author hhzxj2008

* */

public class QQLoginView extends JFrame {

/**

*

*/

private static final long serialVersionUID = -5665975170821790753L;

public QQLoginView() {

initComponent();

}

private void initComponent() {

setTitle("用户登录");

//设置LOGO

URL image = QQLoginView.class.getClassLoader().getResource("ibees/qq/images/year.jpg");//图片的位置

JLabel imageLogo = new JLabel(new ImageIcon(image));

add(imageLogo,BorderLayout.NORTH);

//QQ号和密码

JPanel jp = new JPanel();

JPanel jpAccount = new JPanel();

jpAccount.add(new JLabel("帐号"));

JTextField userTextField = new JTextField(15);

jpAccount.add(userTextField);

jpAccount.add(new JLabel("用户注册"));

jp.add(jpAccount);

JPanel jpPass = new JPanel();

jpPass.add(new JLabel("密码"));

JPasswordField passTextField = new JPasswordField(15);

jpPass.add(passTextField);

jpPass.add(new JLabel("找回密码"));

jp.add(jpPass);

//登录设置

JPanel jpstatus = new JPanel();

jpstatus.add(new JLabel("状态"));

JComboBox statusComboBox = new JComboBox();

statusComboBox.addItem("Q我");

statusComboBox.addItem("在线");

statusComboBox.addItem("隐身");

statusComboBox.addItem("离线");

jpstatus.add(statusComboBox);

jpstatus.add(new JCheckBox("记住密码"));

jpstatus.add(new JCheckBox("自动登录"));

jp.add(jpstatus);

add(jp);

//底部登录按钮

JPanel bottomPanel = new JPanel();

bottomPanel.setLayout(new BorderLayout());

bottomPanel.add(new JButton("设置"),BorderLayout.WEST);

bottomPanel.add(new JButton("登录"),BorderLayout.EAST);

add(bottomPanel,BorderLayout.SOUTH);

setSize(324,230);

setDefaultCloseOperation(EXIT_ON_CLOSE);

setLocationRelativeTo(null);

}

/**

* @param args

*/

public static void main(String[] args) {

java.awt.EventQueue.invokeLater(new Runnable(){

@Override

public void run() {

new QQLoginView().setVisible(true);

}

});

}

}

效果:

2dc7296b4998ac6b3a81567a29aacf0d.png

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值