各位大哥帮我看看一个界面的问题.
import javax.swing.*;import java.awt.*;
import java.awt.event.*;
class student
{
private JFrame frame = new JFrame("student manage system");
private JPanel imagePanel ;
private ImageIcon background;
public static void main(String[] args)
{
new student();
}
public student()
{
background = new ImageIcon("image.jpg");
JLabel label = new JLabel(background);
JLabel IDlabel=new JLabel("ID");
JTextField ID=new JTextField(12);
JLabel PWlabel=new JLabel("password");
JPasswordField PW=new JPasswordField(6);
JButton OK=new JButton("OK");
JPanel panel=new JPanel();
label.setBounds(0,0,background.getIconWidth(),background.getIconHeight());
imagePanel = (JPanel)frame.getContentPane();
imagePanel.setOpaque(false);
imagePanel.setLayout(new GridLayout(5,1));
imagePanel.add(label);
panel.add(IDlabel);
panel.add(ID);
panel.add(PWlabel);
panel.add(PW);
panel.add(OK);
panel.setLocation(background.getIconWidth()/2,background.getIconHeight()/2);
imagePanel.add(panel);
frame.getLayeredPane().setLayout(null);
frame.getLayeredPane().add(label,new Integer(Integer.MIN_VALUE));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(background.getIconWidth(),background.getIconHeight());
frame.setVisible(true);
}
}
如何将 输入 放到中间?