温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Java Swing仿QQ登录界面效果的实现方法

发布时间:2020-07-27 09:54:35 来源:亿速云 阅读:258 作者:小猪 栏目:编程语言

这篇文章主要讲解了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); 
     
   } 
    
  }); 
   
 } 
} 

效果:

Java Swing仿QQ登录界面效果的实现方法

看完上述内容,是不是对Java Swing仿QQ登录界面效果的实现方法有进一步的了解,如果还想学习更多内容,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI