📄 myqq.java
字号:
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import java.awt.GridBagConstraints;
import java.awt.event.*;
import java.awt.Color;
import javax.swing.BorderFactory;
import java.awt.Insets;
import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
public class MyQQ extends JFrame implements ActionListener{
private static final long serialVersionUID = 1L;
private JPanel jp_FirstScreen = null;
private JPanel jp_LEFT = null;
private JPanel jp_RIGHT = null;
private JPanel FirstScreen = null;
private JButton btn_Login = null;
private JButton btn_Reg = null;
private JButton btn_SetAddr = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
private JLabel jLabel4 = null;
public Login login=null;
/**
* @param owner
*/
public MyQQ() {
super();
initialize();
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
MyQQ thisClass = new MyQQ();
thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//thisClass.setVisible(true);
}
}
);
}
private void initialize() {
//Function.setCenter(this);
// new ChatWindow().setVisible(true);
this.setVisible(true);
this.setSize(391, 298);
this.setTitle("登录");
this.setName("欢迎使用");
this.setBackground(Color.white);
this.setContentPane(getJp_FirstScreen());
}
/**
* This method initializes jp_FirstScreen
*
* @return javax.swing.JPanel
*/
private JPanel getJp_FirstScreen() {
if (jp_FirstScreen == null) {
jp_FirstScreen = new JPanel();
jp_FirstScreen.setLayout(new BorderLayout());
jp_FirstScreen.setBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 1));
jp_FirstScreen.add(getFirstScreen(), BorderLayout.CENTER);
}
return jp_FirstScreen;
}
/**
* This method initializes jp_LEFT
*
* @return javax.swing.JPanel
*/
private JPanel getJp_LEFT() {
if (jp_LEFT == null) {
jLabel3 = new JLabel();
jLabel3.setText("");
jLabel3.setPreferredSize(new Dimension(130, 200));
jLabel3.setIcon(new ImageIcon(getClass().getResource("/QQ.png")));
jp_LEFT = new JPanel();
jp_LEFT.setLayout(new GridBagLayout());
jp_LEFT.setBackground(Color.white);
jp_LEFT.add(jLabel3, new GridBagConstraints());
}
return jp_LEFT;
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==btn_Login)
{
FirstScreen.setVisible(false);
login=new Login(FirstScreen,this);
this.add(login);
}
else if(e.getSource()==btn_SetAddr)
{
FirstScreen.setVisible(false);
this.add(new SetAddr(FirstScreen));
}
}
/**
* This method initializes jp_RIGHT
*
* @return javax.swing.JPanel
*/
private JPanel getJp_RIGHT() {
if (jp_RIGHT == null) {
GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
gridBagConstraints5.gridx = 2;
gridBagConstraints5.gridy = 2;
jLabel2 = new JLabel();
jLabel2.setText("网络设置");
GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
gridBagConstraints4.gridx = 1;
gridBagConstraints4.gridy = 2;
jLabel1 = new JLabel();
jLabel1.setText("注册");
GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
gridBagConstraints3.gridx = 0;
gridBagConstraints3.gridy = 2;
jLabel = new JLabel();
jLabel.setText("登录");
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
gridBagConstraints2.gridx = 2;
gridBagConstraints2.gridy = 1;
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.gridx = 1;
gridBagConstraints1.insets = new Insets(0, 0, 0, 10);
gridBagConstraints1.gridy = 1;
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.insets = new Insets(0, 0, 0, 10);
gridBagConstraints.gridy = 1;
jp_RIGHT = new JPanel();
jp_RIGHT.setLayout(new GridBagLayout());
jp_RIGHT.setBackground(Color.white);
jp_RIGHT.add(getBtn_Login(), gridBagConstraints);
jp_RIGHT.add(getBtn_Reg(), gridBagConstraints1);
jp_RIGHT.add(getBtn_SetAddr(), gridBagConstraints2);
jp_RIGHT.add(jLabel, gridBagConstraints3);
jp_RIGHT.add(jLabel1, gridBagConstraints4);
jp_RIGHT.add(jLabel2, gridBagConstraints5);
}
return jp_RIGHT;
}
/**
* This method initializes FirstScreen
*
* @return javax.swing.JPanel
*/
private JPanel getFirstScreen() {
if (FirstScreen == null) {
jLabel4 = new JLabel();
jLabel4.setText("");
jLabel4.setIcon(new ImageIcon(getClass().getResource("/top.PNG")));
FirstScreen = new JPanel();
FirstScreen.setLayout(new BorderLayout());
FirstScreen.add(getJp_LEFT(), BorderLayout.WEST);
FirstScreen.add(getJp_RIGHT(), BorderLayout.CENTER);
FirstScreen.add(jLabel4, BorderLayout.NORTH);
}
return FirstScreen;
}
/**
* This method initializes btn_Login
*
* @return javax.swing.JButton
*/
private JButton getBtn_Login() {
if (btn_Login == null) {
btn_Login = new JButton();
btn_Login.addActionListener(this);
btn_Login.setIcon(new ImageIcon(getClass().getResource("/login.png")));
btn_Login.setPreferredSize(new Dimension(60, 60));
}
return btn_Login;
}
/**
* This method initializes btn_Reg
*
* @return javax.swing.JButton
*/
private JButton getBtn_Reg() {
if (btn_Reg == null) {
btn_Reg = new JButton();
btn_Reg.setIcon(new ImageIcon(getClass().getResource("/reg.png")));
btn_Reg.setPreferredSize(new Dimension(60, 60));
}
return btn_Reg;
}
/**
* This method initializes btn_SetAddr
*
* @return javax.swing.JButton
*/
private JButton getBtn_SetAddr() {
if (btn_SetAddr == null) {
btn_SetAddr = new JButton();
btn_SetAddr.setIcon(new ImageIcon(getClass().getResource("/findpass.png")));
btn_SetAddr.setPreferredSize(new Dimension(60, 60));
btn_SetAddr.addActionListener(this);
}
return btn_SetAddr;
}
} // @jve:decl-index=0:visual-constraint="10,10"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -