This article shares the specific code displayed on the Java Swing imitation QQ login interface for your reference. The specific content is as follows
I can do the QQ login interface I implemented earlier, and it is purely hand-made (meaning that I don’t use the drag function of NetBeans and MyEclipse).
The source code is as follows:
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; /** * Imitation QQ login interface, for learning reference only, involves the use of window centering, JPanel, and LayoutManager* @author hhzxj2008 * */ public class QQLoginView extends JFrame { /** * */ private static final long serialVersionUID = -5665975170821790753L; public QQLoginView() { initComponent(); } private void initComponent() { setTitle("User Login"); //Set LOGO URL image = QQLoginView.class.getClassLoader().getResource("ibees/qq/images/year.jpg");//The location of the image JLabel imageLogo = new JLabel(new ImageIcon(image)); add(imageLogo,BorderLayout.NORTH); //QQ number and password JPanel jp = new JPanel(); JPanel jpAccount = new JPanel(); jpAccount.add(new JLabel("Account")); JTextField userTextField = new JTextField(15); jpAccount.add(userTextField); jpAccount.add(new JLabel("User Registration")); jp.add(jpAccount); JPanel jpPass = new JPanel(); jpPass.add(new JLabel("Pass")); JPasswordField passTextField = new JPasswordField(15); jpPass.add(passTextField); jpPass.add(new JLabel("Retrieve Password")); jp.add(jpPass); //Login Settings JPanel jpstatus = new JPanel(); jpstatus.add(new JLabel("status")); JComboBox statusComboBox = new JComboBox(); statusComboBox.addItem("QI"); statusComboBox.addItem("online"); statusComboBox.addItem("invisible"); statusComboBox.addItem("offline"); jpstatus.add(statusComboBox); jpstatus.add(new JCheckBox("Remember Password")); jpstatus.add(new JCheckBox("Automatic login")); jp.add(jpstatus); add(jp); //Bottom login button JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new BorderLayout()); bottomPanel.add(new JButton("Settings"),BorderLayout.WEST); bottomPanel.add(new JButton("Login"),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); } }); } } }Effect:
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.