package work2;

import java.awt.BorderLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.WindowConstants; class MyJframe extends JFrame{
JPanel Panel;
JLabel ID,Name,Price,Birth;
JTextField J1;
JTextArea J2,J3,J4;
JButton button1,button2; public MyJframe (){
setLayout(new BorderLayout());
init();
setTitle("查询窗口");
setBounds(,,,);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
public void init(){
Panel=new JPanel();
Panel.setLayout(null);//把面板布局设置为空 //商品编号及文本框
ID=new JLabel("商品编号:");
ID.setBounds(,,,);
J1=new JTextField();
J1.setBounds(, , , );
Panel.add(ID);
Panel.add(J1); //查询按钮
button1=new JButton("查询");
button1.setBounds(,,,);
Panel.add(button1); //清除按钮
button2=new JButton("清除界面字符");
button2.setBounds(,,,);
Panel.add(button2); //添加商品名称
Name=new JLabel("商品名称:");
Name.setBounds(,,,);
J2=new JTextArea();
J2.setBounds(,,,);
Panel.add(Name);
Panel.add(J2); //添加价格信息
Price=new JLabel("价 格:");
Price.setBounds(,,,);
J3=new JTextArea();
J3.setBounds(,,,);
Panel.add(Price);
Panel.add(J3); //添加出厂日期
Birth=new JLabel("出厂日期:");
Birth.setBounds(,,,);
J4=new JTextArea();
J4.setBounds(,,,);
Panel.add(Birth);
Panel.add(J4); add(Panel);
}
}
public class Interface{
public static void main(String[] args){
new MyJframe();
}
}

所得界面:

关于一个查询的JAVA界面,希望对你有启发-LMLPHP

05-26 08:33