用java 怎么做出这个窗口
2个回答
展开全部
分那么多块不知何用?类似界面可供参考:
import java.awt.*;
import javax.swing.*;
import java.awt.GridLayout;
@SuppressWarnings("serial")
public class LoginIFrame extends JFrame {
public static void main(String[] args) {
JFrame jf = new JFrame("员工添加");
JPanel jpanel = new JPanel();
jf.setContentPane(jpanel);
// 设置窗口在屏幕中居中显示
double width = Toolkit.getDefaultToolkit().getScreenSize().getWidth();
double height = Toolkit.getDefaultToolkit().getScreenSize().getHeight();
int x = (int) (width - 300) / 2;
int y = (int) (height - 250) / 2;
jf.setBounds(x, y, 300, 200);
// 添加标签组件
GridLayout gird = new GridLayout(4, 0);
JPanel jpanel1 = new JPanel();
JPanel jpanel2 = new JPanel();
JPanel jpanel3 = new JPanel();
JPanel jpanel4 = new JPanel();
jpanel.setLayout(gird);
jpanel.add(jpanel1);
jpanel.add(jpanel2);
jpanel.add(jpanel3);
jpanel.add(jpanel4);
JLabel no = new JLabel("编号:");
JTextField notext = new JTextField(10);
JLabel name = new JLabel("姓名:");
JTextField nametext = new JTextField(10);
JLabel sex = new JLabel("姓别:");
JTextField sextext = new JTextField(10);
JButton add = new JButton("添加");
JButton close = new JButton("关闭");
jpanel1.add(no);
jpanel1.add(notext);
jpanel2.add(name);
jpanel2.add(nametext);
jpanel3.add(sex);
jpanel3.add(sextext);
jpanel4.add(add);
jpanel4.add(close);
jf.getLayeredPane().setLayout(null);
jpanel.setOpaque(false);
jpanel1.setOpaque(false);
jpanel2.setOpaque(false);
jpanel3.setOpaque(false);
jf.setVisible(true);
}
}
效果如下:
满意请采纳!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询