import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class weixin extends JFrame implements ActionListener{
JLabel jl1,jl2,jl3;
JLabel label;
JTextField jtf;
JPasswordField jpf;
JButton jb1,jb2;
ImageIcon background;
JPanel jp1,jp2,jp3,jp4;
JPanel myPanel;
public weixin(){
jl1=new JLabel("账号:");
jl2=new JLabel("密码:");
jtf=new JTextField(16);
jpf=new JPasswordField(16);
jb1=new JButton("登录");
jb2=new JButton("取消");
jp1=new JPanel();
jp2=new JPanel();
jp3=new JPanel();
background = new ImageIcon("images/1.jpg");
label = new JLabel(background);
label.setBounds(0, 0, background.getIconWidth(), background.getIconHeight());
myPanel = (JPanel)this.getContentPane();
myPanel.setOpaque(false);
myPanel.setLayout(new FlowLayout());
this.getLayeredPane().setLayout(null);
jp1.add(jl1);
jp1.add(jtf);
jp2.add(jl2);
jp2.add(jpf);
jp3.add(jb1);
jp3.add(jb2);
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));
jb1.addActionListener(this);
jb2.addActionListener(this);
this.setTitle("登录界面");
this.setSize(692,1227);
this.setLocation(300,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
new weixin();
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==jb1) {
String name="123456";
String psw="111111";
String j1=jtf.getText();
String p1=jpf.getText();
if(name.equals(j1)&&psw.equals(p1)) {
JOptionPane.showMessageDialog(this, "登陆成功");
}else {
JOptionPane.showMessageDialog(this, "登陆失败");
}
}else if(e.getSource()==jb2) {
this.setVisible(false);
}
}
}
class test extends JPanel{
}
```java

组件都是可以设置相对位置。