Java語言編寫簡單的QQ登入介面
阿新 • • 發佈:2019-01-22
import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.Label; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; public class QQ { public static void main(String[] args) { JFrame frame=new JFrame("QQ"); JPanel jp=new JPanel(); jp.setLayout(new BorderLayout()); jp.add(new JLabel("登入介面",JLabel.CENTER),BorderLayout.NORTH); JPanel jp2=new JPanel(); JTextField text=new JTextField(); JPasswordField pass=new JPasswordField(); jp2.setLayout(new GridLayout(2,2,8,8)); jp2.add(new JLabel("UserName",JLabel.CENTER)); jp2.add(text); text.setHorizontalAlignment(JTextField.CENTER); jp2.add(new JLabel("Password",JLabel.CENTER)); jp2.add(pass); pass.setHorizontalAlignment(JTextField.CENTER); jp.add(jp2,BorderLayout.CENTER); JPanel jp1=new JPanel(); jp1.add(new JButton("登入")); jp1.add(new JButton("註冊")); jp1.add(new JButton("取消")); jp.add(jp1,BorderLayout.SOUTH); frame.setContentPane(jp); frame.pack(); frame.setVisible(true); } }
<img src="https://img-blog.csdn.net/20150713203141853" alt="" />