java里面的JTabbedPane选项卡里面添加的按钮怎么实现功能啊
privateclassAddStudentInformationextendsJPanel{JPanelp1=newJPanel();JPanelp=newJPanel...
private class AddStudentInformation extends JPanel{
JPanel p1=new JPanel();
JPanel p=new JPanel();
JLabel name=new JLabel("姓 名:");
JLabel sex=new JLabel("性 别:");
JLabel birth=new JLabel("出生日期:");
JLabel ethnic=new JLabel("民 族:");
JLabel home=new JLabel("籍 贯:");
JLabel year=new JLabel("入学年份:");
JLabel major=new JLabel("专 业:");
JLabel college=new JLabel("学 院:");
JTextField txtname=new JTextField(16);
JTextField txtsex=new JTextField(16);
JTextField txtbirth=new JTextField(16);
JTextField txtethnic=new JTextField(16);
JTextField txthome=new JTextField(16);
JTextField txtyear=new JTextField(16);
JTextField txtmajor=new JTextField(16);
JTextField txtcollege=new JTextField(16);
JButton btnAdd=new JButton("添加");
JButton btnAddClear=new JButton("重置");
JButton btnAddBack=new JButton("取消");
public AddStudentInformation(){
add("Center",p1);
p1.setFont(new Font("宋体",Font.PLAIN,12));
p1.setLayout(new GridLayout(10,2));
p1.setSize(50,380);
p1.add(name); p1.add(txtname);
p1.add(sex); p1.add(txtsex);
p1.add(birth); p1.add(txtbirth);
p1.add(ethnic); p1.add(txtethnic);
p1.add(home); p1.add(txthome);
p1.add(year); p1.add(txtyear);
p1.add(major); p1.add(txtmajor);
p1.add(college); p1.add(txtcollege);
add("South",p);
p.add(btnAdd);
p.add(btnAddClear);
p.add(btnAddBack);
} 展开
JPanel p1=new JPanel();
JPanel p=new JPanel();
JLabel name=new JLabel("姓 名:");
JLabel sex=new JLabel("性 别:");
JLabel birth=new JLabel("出生日期:");
JLabel ethnic=new JLabel("民 族:");
JLabel home=new JLabel("籍 贯:");
JLabel year=new JLabel("入学年份:");
JLabel major=new JLabel("专 业:");
JLabel college=new JLabel("学 院:");
JTextField txtname=new JTextField(16);
JTextField txtsex=new JTextField(16);
JTextField txtbirth=new JTextField(16);
JTextField txtethnic=new JTextField(16);
JTextField txthome=new JTextField(16);
JTextField txtyear=new JTextField(16);
JTextField txtmajor=new JTextField(16);
JTextField txtcollege=new JTextField(16);
JButton btnAdd=new JButton("添加");
JButton btnAddClear=new JButton("重置");
JButton btnAddBack=new JButton("取消");
public AddStudentInformation(){
add("Center",p1);
p1.setFont(new Font("宋体",Font.PLAIN,12));
p1.setLayout(new GridLayout(10,2));
p1.setSize(50,380);
p1.add(name); p1.add(txtname);
p1.add(sex); p1.add(txtsex);
p1.add(birth); p1.add(txtbirth);
p1.add(ethnic); p1.add(txtethnic);
p1.add(home); p1.add(txthome);
p1.add(year); p1.add(txtyear);
p1.add(major); p1.add(txtmajor);
p1.add(college); p1.add(txtcollege);
add("South",p);
p.add(btnAdd);
p.add(btnAddClear);
p.add(btnAddBack);
} 展开
展开全部
下面是个例子 你参考一下
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.*;
import javax.swing.border.*;
public class 添加 extends JFrame implements ActionListener
{
Statement stmt;
Connection conn;
ResultSet rs,rs1;
JButton jb1=new JButton("添加");
JButton jb2=new JButton("返回");
JButton jb3=new JButton("添加");
JButton jb4=new JButton("返回");
JButton jb5=new JButton("添加");
JButton jb6=new JButton("返回");
JButton jb7=new JButton("添加");
JButton jb8=new JButton("返回");
JTextField hwtf1=new JTextField();
JTextField hwtf2=new JTextField();
JTextField hwtf3=new JTextField();
JTextField hwtf4=new JTextField();
JTextField hwtf5=new JTextField();
JTextArea hwta6=new JTextArea();
JTextField xstf1=new JTextField();
JTextField xstf2=new JTextField();
JTextField xstf3=new JTextField();
JTextField xstf4=new JTextField();
JTextField xstf5=new JTextField();
JTextField xstf6=new JTextField();
JTextField xstf7=new JTextField();
JTextField xstf8=new JTextField();
JTextField xstf9=new JTextField();
JTextField cgtf1=new JTextField();
JTextField cgtf2=new JTextField();
JTextField cgtf3=new JTextField();
JTextField cgtf4=new JTextField();
JTextField cgtf5=new JTextField();
JTextField cgtf6=new JTextField();
JTextField cgtf7=new JTextField();
JTextField cgtf8=new JTextField();
JTextField cgtf9=new JTextField();
JTextField cktf1=new JTextField();
JTextField cktf2=new JTextField();
JTextField cktf3=new JTextField();
JTextField cktf4=new JTextField();
JTextField cktf5=new JTextField();
private JTabbedPane tab=new JTabbedPane();//标签页容器
public 添加()
{
JPanel 销售=new JPanel(); JPanel a=new JPanel();JPanel b=new JPanel();JPanel c=new JPanel();JPanel d=new JPanel();
JPanel 采购=new JPanel(); JPanel e=new JPanel();JPanel f=new JPanel();JPanel g=new JPanel();JPanel h=new JPanel();
JPanel 货物=new JPanel(); JPanel i=new JPanel();JPanel j=new JPanel();JPanel k=new JPanel();JPanel l=new JPanel();
JPanel 仓库=new JPanel(); JPanel m=new JPanel();JPanel n=new JPanel();JPanel o=new JPanel();JPanel p=new JPanel();
jb1.setFont(new Font("宋体",Font.BOLD,20));
jb2.setFont(new Font("宋体",Font.BOLD,20));
jb3.setFont(new Font("宋体",Font.BOLD,20));
jb4.setFont(new Font("宋体",Font.BOLD,20));
jb5.setFont(new Font("宋体",Font.BOLD,20));
jb6.setFont(new Font("宋体",Font.BOLD,20));
jb7.setFont(new Font("宋体",Font.BOLD,20));
jb8.setFont(new Font("宋体",Font.BOLD,20));
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
jb4.addActionListener(this);
jb5.addActionListener(this);
jb6.addActionListener(this);
jb7.addActionListener(this);
jb8.addActionListener(this);
tab.add(采购,"添加采购人员");
tab.add(销售,"添加销售人员");
tab.add(货物,"添加货物");
tab.add(仓库,"货物入库");
tab.setBackground(Color.WHITE);
tab.setFont(new Font("宋体",Font.BOLD,20));
销售.setLayout(new GridLayout(4,3));
a.setLayout(new GridLayout(2,2));b.setLayout(new GridLayout(2,2));
c.setLayout(new GridLayout(2,2));d.setLayout(new FlowLayout());
采购.setLayout(new GridLayout(4,3));
e.setLayout(new GridLayout(2,2));f.setLayout(new GridLayout(2,2));
g.setLayout(new GridLayout(2,2));h.setLayout(new FlowLayout());
货物.setLayout(new GridLayout(4,0));
i.setLayout(new GridLayout(2,2));j.setLayout(new GridLayout(2,3));
k.setLayout(new GridLayout(1,1));l.setLayout(new FlowLayout());
仓库.setLayout(new GridLayout(4,3));
m.setLayout(new GridLayout(2,2));n.setLayout(new GridLayout(2,3));
o.setLayout(new FlowLayout());
tab.setBorder(new MatteBorder(new ImageIcon("美丽背景.jpg")));
getContentPane().add(tab);
this.setSize(600,480);
this.setResizable(false);
this.setTitle("仓库管理系统");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
this.setLocation(500,250);
JLabel xslb1=new JLabel("编号"); xslb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb2=new JLabel("姓名"); xslb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb3=new JLabel("性别"); xslb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb4=new JLabel("联系方式"); xslb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb5=new JLabel("货物编号"); xslb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb6=new JLabel("货物名称"); xslb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb7=new JLabel("采购数量"); xslb7.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb8=new JLabel("采购时间"); xslb8.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb9=new JLabel("采购价格"); xslb9.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb1=new JLabel("编号"); cglb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb2=new JLabel("姓名"); cglb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb3=new JLabel("性别"); cglb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb4=new JLabel("联系方式"); cglb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb5=new JLabel("货物编号"); cglb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb6=new JLabel("货物名称"); cglb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb7=new JLabel("提货数量"); cglb7.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb8=new JLabel("提货时间"); cglb8.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb9=new JLabel("出售价格"); cglb9.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb1=new JLabel("货物编号"); hwlb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb2=new JLabel("货物名称"); hwlb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb3=new JLabel("货物规格"); hwlb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb4=new JLabel("入库日期"); hwlb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb5=new JLabel("入库数量"); hwlb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb6=new JLabel("备注"); hwlb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb1=new JLabel("入库号"); cklb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb2=new JLabel("货物编号"); cklb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb3=new JLabel("货物名称"); cklb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb4=new JLabel("原有数量"); cklb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb5=new JLabel("现存数量"); cklb5.setFont(new Font("宋体",Font.BOLD,20));
cgtf1.setFont(new Font("",Font.BOLD,20));cgtf2.setFont(new Font("",Font.BOLD,20));cgtf3.setFont(new Font("",Font.BOLD,20));
cgtf4.setFont(new Font("",Font.BOLD,20));cgtf5.setFont(new Font("",Font.BOLD,20));cgtf6.setFont(new Font("",Font.BOLD,20));
cgtf7.setFont(new Font("",Font.BOLD,20));cgtf8.setFont(new Font("",Font.BOLD,20));cgtf9.setFont(new Font("",Font.BOLD,20));
xstf1.setFont(new Font("",Font.BOLD,20));xstf2.setFont(new Font("",Font.BOLD,20));xstf3.setFont(new Font("",Font.BOLD,20));
xstf4.setFont(new Font("",Font.BOLD,20));xstf5.setFont(new Font("",Font.BOLD,20));xstf6.setFont(new Font("",Font.BOLD,20));
xstf7.setFont(new Font("",Font.BOLD,20));xstf8.setFont(new Font("",Font.BOLD,20));xstf9.setFont(new Font("",Font.BOLD,20));
hwtf1.setFont(new Font("",Font.BOLD,20));hwtf2.setFont(new Font("",Font.BOLD,20));hwtf3.setFont(new Font("",Font.BOLD,20));
hwtf4.setFont(new Font("",Font.BOLD,20));hwtf5.setFont(new Font("",Font.BOLD,20));hwta6.setFont(new Font("",Font.BOLD,20));
cktf1.setFont(new Font("",Font.BOLD,20));cktf2.setFont(new Font("",Font.BOLD,20));cktf3.setFont(new Font("",Font.BOLD,20));
cktf4.setFont(new Font("",Font.BOLD,20));cktf5.setFont(new Font("",Font.BOLD,20));
a.add(cglb1);a.add(cglb2);a.add(cglb3);
a.add(cgtf1);a.add(cgtf2);a.add(cgtf3);
b.add(cglb4);b.add(cglb5);b.add(cglb6);
b.add(cgtf4);b.add(cgtf5);b.add(cgtf6);
c.add(cglb7);c.add(cglb8);c.add(cglb9);
c.add(cgtf7);c.add(cgtf8);c.add(cgtf9);
d.add(jb1);d.add(jb2);
采购.add(a);采购.add(b);采购.add(c);采购.add(d);
e.add(xslb1);e.add(xslb2);e.add(xslb3);
e.add(xstf1);e.add(xstf2);e.add(xstf3);
f.add(xslb4);f.add(xslb5);f.add(xslb6);
f.add(xstf4);f.add(xstf5);f.add(xstf6);
g.add(xslb7);g.add(xslb8);g.add(xslb9);
g.add(xstf7);g.add(xstf8);g.add(xstf9);
h.add(jb3);h.add(jb4);
销售.add(e);销售.add(f);销售.add(g);销售.add(h);
i.add(hwlb1);i.add(hwlb2);
i.add(hwtf1);i.add(hwtf2);
j.add(hwlb3);j.add(hwlb4);j.add(hwlb5);
j.add(hwtf3);j.add(hwtf4);j.add(hwtf5);
k.add(hwlb6);k.add(hwta6);
l.add(jb5);l.add(jb6);
货物.add(i);货物.add(j);货物.add(k);货物.add(l);
m.add(cklb1);m.add(cklb2);
m.add(cktf1);m.add(cktf2);
n.add(cklb3);n.add(cklb4);n.add(cklb5);
n.add(cktf3);n.add(cktf4);n.add(cktf5);
o.add(jb7);o.add(jb8);
仓库.add(m);仓库.add(n);仓库.add(o);
((JPanel)getContentPane()).setOpaque(false);
}
public static void main (String args[])
{
添加 tianjia =new 添加();
}
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.*;
import javax.swing.border.*;
public class 添加 extends JFrame implements ActionListener
{
Statement stmt;
Connection conn;
ResultSet rs,rs1;
JButton jb1=new JButton("添加");
JButton jb2=new JButton("返回");
JButton jb3=new JButton("添加");
JButton jb4=new JButton("返回");
JButton jb5=new JButton("添加");
JButton jb6=new JButton("返回");
JButton jb7=new JButton("添加");
JButton jb8=new JButton("返回");
JTextField hwtf1=new JTextField();
JTextField hwtf2=new JTextField();
JTextField hwtf3=new JTextField();
JTextField hwtf4=new JTextField();
JTextField hwtf5=new JTextField();
JTextArea hwta6=new JTextArea();
JTextField xstf1=new JTextField();
JTextField xstf2=new JTextField();
JTextField xstf3=new JTextField();
JTextField xstf4=new JTextField();
JTextField xstf5=new JTextField();
JTextField xstf6=new JTextField();
JTextField xstf7=new JTextField();
JTextField xstf8=new JTextField();
JTextField xstf9=new JTextField();
JTextField cgtf1=new JTextField();
JTextField cgtf2=new JTextField();
JTextField cgtf3=new JTextField();
JTextField cgtf4=new JTextField();
JTextField cgtf5=new JTextField();
JTextField cgtf6=new JTextField();
JTextField cgtf7=new JTextField();
JTextField cgtf8=new JTextField();
JTextField cgtf9=new JTextField();
JTextField cktf1=new JTextField();
JTextField cktf2=new JTextField();
JTextField cktf3=new JTextField();
JTextField cktf4=new JTextField();
JTextField cktf5=new JTextField();
private JTabbedPane tab=new JTabbedPane();//标签页容器
public 添加()
{
JPanel 销售=new JPanel(); JPanel a=new JPanel();JPanel b=new JPanel();JPanel c=new JPanel();JPanel d=new JPanel();
JPanel 采购=new JPanel(); JPanel e=new JPanel();JPanel f=new JPanel();JPanel g=new JPanel();JPanel h=new JPanel();
JPanel 货物=new JPanel(); JPanel i=new JPanel();JPanel j=new JPanel();JPanel k=new JPanel();JPanel l=new JPanel();
JPanel 仓库=new JPanel(); JPanel m=new JPanel();JPanel n=new JPanel();JPanel o=new JPanel();JPanel p=new JPanel();
jb1.setFont(new Font("宋体",Font.BOLD,20));
jb2.setFont(new Font("宋体",Font.BOLD,20));
jb3.setFont(new Font("宋体",Font.BOLD,20));
jb4.setFont(new Font("宋体",Font.BOLD,20));
jb5.setFont(new Font("宋体",Font.BOLD,20));
jb6.setFont(new Font("宋体",Font.BOLD,20));
jb7.setFont(new Font("宋体",Font.BOLD,20));
jb8.setFont(new Font("宋体",Font.BOLD,20));
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
jb4.addActionListener(this);
jb5.addActionListener(this);
jb6.addActionListener(this);
jb7.addActionListener(this);
jb8.addActionListener(this);
tab.add(采购,"添加采购人员");
tab.add(销售,"添加销售人员");
tab.add(货物,"添加货物");
tab.add(仓库,"货物入库");
tab.setBackground(Color.WHITE);
tab.setFont(new Font("宋体",Font.BOLD,20));
销售.setLayout(new GridLayout(4,3));
a.setLayout(new GridLayout(2,2));b.setLayout(new GridLayout(2,2));
c.setLayout(new GridLayout(2,2));d.setLayout(new FlowLayout());
采购.setLayout(new GridLayout(4,3));
e.setLayout(new GridLayout(2,2));f.setLayout(new GridLayout(2,2));
g.setLayout(new GridLayout(2,2));h.setLayout(new FlowLayout());
货物.setLayout(new GridLayout(4,0));
i.setLayout(new GridLayout(2,2));j.setLayout(new GridLayout(2,3));
k.setLayout(new GridLayout(1,1));l.setLayout(new FlowLayout());
仓库.setLayout(new GridLayout(4,3));
m.setLayout(new GridLayout(2,2));n.setLayout(new GridLayout(2,3));
o.setLayout(new FlowLayout());
tab.setBorder(new MatteBorder(new ImageIcon("美丽背景.jpg")));
getContentPane().add(tab);
this.setSize(600,480);
this.setResizable(false);
this.setTitle("仓库管理系统");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
this.setLocation(500,250);
JLabel xslb1=new JLabel("编号"); xslb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb2=new JLabel("姓名"); xslb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb3=new JLabel("性别"); xslb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb4=new JLabel("联系方式"); xslb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb5=new JLabel("货物编号"); xslb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb6=new JLabel("货物名称"); xslb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb7=new JLabel("采购数量"); xslb7.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb8=new JLabel("采购时间"); xslb8.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb9=new JLabel("采购价格"); xslb9.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb1=new JLabel("编号"); cglb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb2=new JLabel("姓名"); cglb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb3=new JLabel("性别"); cglb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb4=new JLabel("联系方式"); cglb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb5=new JLabel("货物编号"); cglb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb6=new JLabel("货物名称"); cglb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb7=new JLabel("提货数量"); cglb7.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb8=new JLabel("提货时间"); cglb8.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb9=new JLabel("出售价格"); cglb9.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb1=new JLabel("货物编号"); hwlb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb2=new JLabel("货物名称"); hwlb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb3=new JLabel("货物规格"); hwlb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb4=new JLabel("入库日期"); hwlb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb5=new JLabel("入库数量"); hwlb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb6=new JLabel("备注"); hwlb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb1=new JLabel("入库号"); cklb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb2=new JLabel("货物编号"); cklb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb3=new JLabel("货物名称"); cklb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb4=new JLabel("原有数量"); cklb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb5=new JLabel("现存数量"); cklb5.setFont(new Font("宋体",Font.BOLD,20));
cgtf1.setFont(new Font("",Font.BOLD,20));cgtf2.setFont(new Font("",Font.BOLD,20));cgtf3.setFont(new Font("",Font.BOLD,20));
cgtf4.setFont(new Font("",Font.BOLD,20));cgtf5.setFont(new Font("",Font.BOLD,20));cgtf6.setFont(new Font("",Font.BOLD,20));
cgtf7.setFont(new Font("",Font.BOLD,20));cgtf8.setFont(new Font("",Font.BOLD,20));cgtf9.setFont(new Font("",Font.BOLD,20));
xstf1.setFont(new Font("",Font.BOLD,20));xstf2.setFont(new Font("",Font.BOLD,20));xstf3.setFont(new Font("",Font.BOLD,20));
xstf4.setFont(new Font("",Font.BOLD,20));xstf5.setFont(new Font("",Font.BOLD,20));xstf6.setFont(new Font("",Font.BOLD,20));
xstf7.setFont(new Font("",Font.BOLD,20));xstf8.setFont(new Font("",Font.BOLD,20));xstf9.setFont(new Font("",Font.BOLD,20));
hwtf1.setFont(new Font("",Font.BOLD,20));hwtf2.setFont(new Font("",Font.BOLD,20));hwtf3.setFont(new Font("",Font.BOLD,20));
hwtf4.setFont(new Font("",Font.BOLD,20));hwtf5.setFont(new Font("",Font.BOLD,20));hwta6.setFont(new Font("",Font.BOLD,20));
cktf1.setFont(new Font("",Font.BOLD,20));cktf2.setFont(new Font("",Font.BOLD,20));cktf3.setFont(new Font("",Font.BOLD,20));
cktf4.setFont(new Font("",Font.BOLD,20));cktf5.setFont(new Font("",Font.BOLD,20));
a.add(cglb1);a.add(cglb2);a.add(cglb3);
a.add(cgtf1);a.add(cgtf2);a.add(cgtf3);
b.add(cglb4);b.add(cglb5);b.add(cglb6);
b.add(cgtf4);b.add(cgtf5);b.add(cgtf6);
c.add(cglb7);c.add(cglb8);c.add(cglb9);
c.add(cgtf7);c.add(cgtf8);c.add(cgtf9);
d.add(jb1);d.add(jb2);
采购.add(a);采购.add(b);采购.add(c);采购.add(d);
e.add(xslb1);e.add(xslb2);e.add(xslb3);
e.add(xstf1);e.add(xstf2);e.add(xstf3);
f.add(xslb4);f.add(xslb5);f.add(xslb6);
f.add(xstf4);f.add(xstf5);f.add(xstf6);
g.add(xslb7);g.add(xslb8);g.add(xslb9);
g.add(xstf7);g.add(xstf8);g.add(xstf9);
h.add(jb3);h.add(jb4);
销售.add(e);销售.add(f);销售.add(g);销售.add(h);
i.add(hwlb1);i.add(hwlb2);
i.add(hwtf1);i.add(hwtf2);
j.add(hwlb3);j.add(hwlb4);j.add(hwlb5);
j.add(hwtf3);j.add(hwtf4);j.add(hwtf5);
k.add(hwlb6);k.add(hwta6);
l.add(jb5);l.add(jb6);
货物.add(i);货物.add(j);货物.add(k);货物.add(l);
m.add(cklb1);m.add(cklb2);
m.add(cktf1);m.add(cktf2);
n.add(cklb3);n.add(cklb4);n.add(cklb5);
n.add(cktf3);n.add(cktf4);n.add(cktf5);
o.add(jb7);o.add(jb8);
仓库.add(m);仓库.add(n);仓库.add(o);
((JPanel)getContentPane()).setOpaque(false);
}
public static void main (String args[])
{
添加 tianjia =new 添加();
}
展开全部
下面是个例子 你参考一下
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.*;
import javax.swing.border.*;
public class 添加 extends JFrame implements ActionListener
{
Statement stmt;
Connection conn;
ResultSet rs,rs1;
JButton jb1=new JButton("添加");
JButton jb2=new JButton("返回");
JButton jb3=new JButton("添加");
JButton jb4=new JButton("返回");
JButton jb5=new JButton("添加");
JButton jb6=new JButton("返回");
JButton jb7=new JButton("添加");
JButton jb8=new JButton("返回");
JTextField hwtf1=new JTextField();
JTextField hwtf2=new JTextField();
JTextField hwtf3=new JTextField();
JTextField hwtf4=new JTextField();
JTextField hwtf5=new JTextField();
JTextArea hwta6=new JTextArea();
JTextField xstf1=new JTextField();
JTextField xstf2=new JTextField();
JTextField xstf3=new JTextField();
JTextField xstf4=new JTextField();
JTextField xstf5=new JTextField();
JTextField xstf6=new JTextField();
JTextField xstf7=new JTextField();
JTextField xstf8=new JTextField();
JTextField xstf9=new JTextField();
JTextField cgtf1=new JTextField();
JTextField cgtf2=new JTextField();
JTextField cgtf3=new JTextField();
JTextField cgtf4=new JTextField();
JTextField cgtf5=new JTextField();
JTextField cgtf6=new JTextField();
JTextField cgtf7=new JTextField();
JTextField cgtf8=new JTextField();
JTextField cgtf9=new JTextField();
JTextField cktf1=new JTextField();
JTextField cktf2=new JTextField();
JTextField cktf3=new JTextField();
JTextField cktf4=new JTextField();
JTextField cktf5=new JTextField();
private JTabbedPane tab=new JTabbedPane();//标签页容器
public 添加()
{
JPanel 销售=new JPanel(); JPanel a=new JPanel();JPanel b=new JPanel();JPanel c=new JPanel();JPanel d=new JPanel();
JPanel 采购=new JPanel(); JPanel e=new JPanel();JPanel f=new JPanel();JPanel g=new JPanel();JPanel h=new JPanel();
JPanel 货物=new JPanel(); JPanel i=new JPanel();JPanel j=new JPanel();JPanel k=new JPanel();JPanel l=new JPanel();
JPanel 仓库=new JPanel(); JPanel m=new JPanel();JPanel n=new JPanel();JPanel o=new JPanel();JPanel p=new JPanel();
jb1.setFont(new Font("宋体",Font.BOLD,20));
jb2.setFont(new Font("宋体",Font.BOLD,20));
jb3.setFont(new Font("宋体",Font.BOLD,20));
jb4.setFont(new Font("宋体",Font.BOLD,20));
jb5.setFont(new Font("宋体",Font.BOLD,20));
jb6.setFont(new Font("宋体",Font.BOLD,20));
jb7.setFont(new Font("宋体",Font.BOLD,20));
jb8.setFont(new Font("宋体",Font.BOLD,20));
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
jb4.addActionListener(this);
jb5.addActionListener(this);
jb6.addActionListener(this);
jb7.addActionListener(this);
jb8.addActionListener(this);
tab.add(采购,"添加采购人员");
tab.add(销售,"添加销售人员");
tab.add(货物,"添加货物");
tab.add(仓库,"货物入库");
tab.setBackground(Color.WHITE);
tab.setFont(new Font("宋体",Font.BOLD,20));
销售.setLayout(new GridLayout(4,3));
a.setLayout(new GridLayout(2,2));b.setLayout(new GridLayout(2,2));
c.setLayout(new GridLayout(2,2));d.setLayout(new FlowLayout());
采购.setLayout(new GridLayout(4,3));
e.setLayout(new GridLayout(2,2));f.setLayout(new GridLayout(2,2));
g.setLayout(new GridLayout(2,2));h.setLayout(new FlowLayout());
货物.setLayout(new GridLayout(4,0));
i.setLayout(new GridLayout(2,2));j.setLayout(new GridLayout(2,3));
k.setLayout(new GridLayout(1,1));l.setLayout(new FlowLayout());
仓库.setLayout(new GridLayout(4,3));
m.setLayout(new GridLayout(2,2));n.setLayout(new GridLayout(2,3));
o.setLayout(new FlowLayout());
tab.setBorder(new MatteBorder(new ImageIcon("美丽背景.jpg")));
getContentPane().add(tab);
this.setSize(600,480);
this.setResizable(false);
this.setTitle("仓库管理系统");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
this.setLocation(500,250);
JLabel xslb1=new JLabel("编号"); xslb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb2=new JLabel("姓名"); xslb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb3=new JLabel("性别"); xslb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb4=new JLabel("联系方式"); xslb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb5=new JLabel("货物编号"); xslb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb6=new JLabel("货物名称"); xslb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb7=new JLabel("采购数量"); xslb7.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb8=new JLabel("采购时间"); xslb8.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb9=new JLabel("采购价格"); xslb9.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb1=new JLabel("编号"); cglb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb2=new JLabel("姓名"); cglb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb3=new JLabel("性别"); cglb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb4=new JLabel("联系方式"); cglb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb5=new JLabel("货物编号"); cglb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb6=new JLabel("货物名称"); cglb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb7=new JLabel("提货数量"); cglb7.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb8=new JLabel("提货时间"); cglb8.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb9=new JLabel("出售价格"); cglb9.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb1=new JLabel("货物编号"); hwlb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb2=new JLabel("货物名称"); hwlb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb3=new JLabel("货物规格"); hwlb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb4=new JLabel("入库日期"); hwlb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb5=new JLabel("入库数量"); hwlb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb6=new JLabel("备注"); hwlb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb1=new JLabel("入库号"); cklb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb2=new JLabel("货物编号"); cklb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb3=new JLabel("货物名称"); cklb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb4=new JLabel("原有数量"); cklb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb5=new JLabel("现存数量"); cklb5.setFont(new Font("宋体",Font.BOLD,20));
cgtf1.setFont(new Font("",Font.BOLD,20));cgtf2.setFont(new Font("",Font.BOLD,20));cgtf3.setFont(new Font("",Font.BOLD,20));
cgtf4.setFont(new Font("",Font.BOLD,20));cgtf5.setFont(new Font("",Font.BOLD,20));cgtf6.setFont(new Font("",Font.BOLD,20));
cgtf7.setFont(new Font("",Font.BOLD,20));cgtf8.setFont(new Font("",Font.BOLD,20));cgtf9.setFont(new Font("",Font.BOLD,20));
xstf1.setFont(new Font("",Font.BOLD,20));xstf2.setFont(new Font("",Font.BOLD,20));xstf3.setFont(new Font("",Font.BOLD,20));
xstf4.setFont(new Font("",Font.BOLD,20));xstf5.setFont(new Font("",Font.BOLD,20));xstf6.setFont(new Font("",Font.BOLD,20));
xstf7.setFont(new Font("",Font.BOLD,20));xstf8.setFont(new Font("",Font.BOLD,20));xstf9.setFont(new Font("",Font.BOLD,20));
hwtf1.setFont(new Font("",Font.BOLD,20));hwtf2.setFont(new Font("",Font.BOLD,20));hwtf3.setFont(new Font("",Font.BOLD,20));
hwtf4.setFont(new Font("",Font.BOLD,20));hwtf5.setFont(new Font("",Font.BOLD,20));hwta6.setFont(new Font("",Font.BOLD,20));
cktf1.setFont(new Font("",Font.BOLD,20));cktf2.setFont(new Font("",Font.BOLD,20));cktf3.setFont(new Font("",Font.BOLD,20));
cktf4.setFont(new Font("",Font.BOLD,20));cktf5.setFont(new Font("",Font.BOLD,20));
a.add(cglb1);a.add(cglb2);a.add(cglb3);
a.add(cgtf1);a.add(cgtf2);a.add(cgtf3);
b.add(cglb4);b.add(cglb5);b.add(cglb6);
b.add(cgtf4);b.add(cgtf5);b.add(cgtf6);
c.add(cglb7);c.add(cglb8);c.add(cglb9);
c.add(cgtf7);c.add(cgtf8);c.add(cgtf9);
d.add(jb1);d.add(jb2);
采购.add(a);采购.add(b);采购.add(c);采购.add(d);
e.add(xslb1);e.add(xslb2);e.add(xslb3);
e.add(xstf1);e.add(xstf2);e.add(xstf3);
f.add(xslb4);f.add(xslb5);f.add(xslb6);
f.add(xstf4);f.add(xstf5);f.add(xstf6);
g.add(xslb7);g.add(xslb8);g.add(xslb9);
g.add(xstf7);g.add(xstf8);g.add(xstf9);
h.add(jb3);h.add(jb4);
销售.add(e);销售.add(f);销售.add(g);销售.add(h);
i.add(hwlb1);i.add(hwlb2);
i.add(hwtf1);i.add(hwtf2);
j.add(hwlb3);j.add(hwlb4);j.add(hwlb5);
j.add(hwtf3);j.add(hwtf4);j.add(hwtf5);
k.add(hwlb6);k.add(hwta6);
l.add(jb5);l.add(jb6);
货物.add(i);货物.add(j);货物.add(k);货物.add(l);
m.add(cklb1);m.add(cklb2);
m.add(cktf1);m.add(cktf2);
n.add(cklb3);n.add(cklb4);n.add(cklb5);
n.add(cktf3);n.add(cktf4);n.add(cktf5);
o.add(jb7);o.add(jb8);
仓库.add(m);仓库.add(n);仓库.add(o);
((JPanel)getContentPane()).setOpaque(false);
}
public static void main (String args[])
{
添加 tianjia =new 添加();
}
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.*;
import javax.swing.border.*;
public class 添加 extends JFrame implements ActionListener
{
Statement stmt;
Connection conn;
ResultSet rs,rs1;
JButton jb1=new JButton("添加");
JButton jb2=new JButton("返回");
JButton jb3=new JButton("添加");
JButton jb4=new JButton("返回");
JButton jb5=new JButton("添加");
JButton jb6=new JButton("返回");
JButton jb7=new JButton("添加");
JButton jb8=new JButton("返回");
JTextField hwtf1=new JTextField();
JTextField hwtf2=new JTextField();
JTextField hwtf3=new JTextField();
JTextField hwtf4=new JTextField();
JTextField hwtf5=new JTextField();
JTextArea hwta6=new JTextArea();
JTextField xstf1=new JTextField();
JTextField xstf2=new JTextField();
JTextField xstf3=new JTextField();
JTextField xstf4=new JTextField();
JTextField xstf5=new JTextField();
JTextField xstf6=new JTextField();
JTextField xstf7=new JTextField();
JTextField xstf8=new JTextField();
JTextField xstf9=new JTextField();
JTextField cgtf1=new JTextField();
JTextField cgtf2=new JTextField();
JTextField cgtf3=new JTextField();
JTextField cgtf4=new JTextField();
JTextField cgtf5=new JTextField();
JTextField cgtf6=new JTextField();
JTextField cgtf7=new JTextField();
JTextField cgtf8=new JTextField();
JTextField cgtf9=new JTextField();
JTextField cktf1=new JTextField();
JTextField cktf2=new JTextField();
JTextField cktf3=new JTextField();
JTextField cktf4=new JTextField();
JTextField cktf5=new JTextField();
private JTabbedPane tab=new JTabbedPane();//标签页容器
public 添加()
{
JPanel 销售=new JPanel(); JPanel a=new JPanel();JPanel b=new JPanel();JPanel c=new JPanel();JPanel d=new JPanel();
JPanel 采购=new JPanel(); JPanel e=new JPanel();JPanel f=new JPanel();JPanel g=new JPanel();JPanel h=new JPanel();
JPanel 货物=new JPanel(); JPanel i=new JPanel();JPanel j=new JPanel();JPanel k=new JPanel();JPanel l=new JPanel();
JPanel 仓库=new JPanel(); JPanel m=new JPanel();JPanel n=new JPanel();JPanel o=new JPanel();JPanel p=new JPanel();
jb1.setFont(new Font("宋体",Font.BOLD,20));
jb2.setFont(new Font("宋体",Font.BOLD,20));
jb3.setFont(new Font("宋体",Font.BOLD,20));
jb4.setFont(new Font("宋体",Font.BOLD,20));
jb5.setFont(new Font("宋体",Font.BOLD,20));
jb6.setFont(new Font("宋体",Font.BOLD,20));
jb7.setFont(new Font("宋体",Font.BOLD,20));
jb8.setFont(new Font("宋体",Font.BOLD,20));
jb1.addActionListener(this);
jb2.addActionListener(this);
jb3.addActionListener(this);
jb4.addActionListener(this);
jb5.addActionListener(this);
jb6.addActionListener(this);
jb7.addActionListener(this);
jb8.addActionListener(this);
tab.add(采购,"添加采购人员");
tab.add(销售,"添加销售人员");
tab.add(货物,"添加货物");
tab.add(仓库,"货物入库");
tab.setBackground(Color.WHITE);
tab.setFont(new Font("宋体",Font.BOLD,20));
销售.setLayout(new GridLayout(4,3));
a.setLayout(new GridLayout(2,2));b.setLayout(new GridLayout(2,2));
c.setLayout(new GridLayout(2,2));d.setLayout(new FlowLayout());
采购.setLayout(new GridLayout(4,3));
e.setLayout(new GridLayout(2,2));f.setLayout(new GridLayout(2,2));
g.setLayout(new GridLayout(2,2));h.setLayout(new FlowLayout());
货物.setLayout(new GridLayout(4,0));
i.setLayout(new GridLayout(2,2));j.setLayout(new GridLayout(2,3));
k.setLayout(new GridLayout(1,1));l.setLayout(new FlowLayout());
仓库.setLayout(new GridLayout(4,3));
m.setLayout(new GridLayout(2,2));n.setLayout(new GridLayout(2,3));
o.setLayout(new FlowLayout());
tab.setBorder(new MatteBorder(new ImageIcon("美丽背景.jpg")));
getContentPane().add(tab);
this.setSize(600,480);
this.setResizable(false);
this.setTitle("仓库管理系统");
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
this.setLocation(500,250);
JLabel xslb1=new JLabel("编号"); xslb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb2=new JLabel("姓名"); xslb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb3=new JLabel("性别"); xslb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb4=new JLabel("联系方式"); xslb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb5=new JLabel("货物编号"); xslb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb6=new JLabel("货物名称"); xslb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb7=new JLabel("采购数量"); xslb7.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb8=new JLabel("采购时间"); xslb8.setFont(new Font("宋体",Font.BOLD,20));
JLabel xslb9=new JLabel("采购价格"); xslb9.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb1=new JLabel("编号"); cglb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb2=new JLabel("姓名"); cglb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb3=new JLabel("性别"); cglb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb4=new JLabel("联系方式"); cglb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb5=new JLabel("货物编号"); cglb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb6=new JLabel("货物名称"); cglb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb7=new JLabel("提货数量"); cglb7.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb8=new JLabel("提货时间"); cglb8.setFont(new Font("宋体",Font.BOLD,20));
JLabel cglb9=new JLabel("出售价格"); cglb9.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb1=new JLabel("货物编号"); hwlb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb2=new JLabel("货物名称"); hwlb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb3=new JLabel("货物规格"); hwlb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb4=new JLabel("入库日期"); hwlb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb5=new JLabel("入库数量"); hwlb5.setFont(new Font("宋体",Font.BOLD,20));
JLabel hwlb6=new JLabel("备注"); hwlb6.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb1=new JLabel("入库号"); cklb1.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb2=new JLabel("货物编号"); cklb2.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb3=new JLabel("货物名称"); cklb3.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb4=new JLabel("原有数量"); cklb4.setFont(new Font("宋体",Font.BOLD,20));
JLabel cklb5=new JLabel("现存数量"); cklb5.setFont(new Font("宋体",Font.BOLD,20));
cgtf1.setFont(new Font("",Font.BOLD,20));cgtf2.setFont(new Font("",Font.BOLD,20));cgtf3.setFont(new Font("",Font.BOLD,20));
cgtf4.setFont(new Font("",Font.BOLD,20));cgtf5.setFont(new Font("",Font.BOLD,20));cgtf6.setFont(new Font("",Font.BOLD,20));
cgtf7.setFont(new Font("",Font.BOLD,20));cgtf8.setFont(new Font("",Font.BOLD,20));cgtf9.setFont(new Font("",Font.BOLD,20));
xstf1.setFont(new Font("",Font.BOLD,20));xstf2.setFont(new Font("",Font.BOLD,20));xstf3.setFont(new Font("",Font.BOLD,20));
xstf4.setFont(new Font("",Font.BOLD,20));xstf5.setFont(new Font("",Font.BOLD,20));xstf6.setFont(new Font("",Font.BOLD,20));
xstf7.setFont(new Font("",Font.BOLD,20));xstf8.setFont(new Font("",Font.BOLD,20));xstf9.setFont(new Font("",Font.BOLD,20));
hwtf1.setFont(new Font("",Font.BOLD,20));hwtf2.setFont(new Font("",Font.BOLD,20));hwtf3.setFont(new Font("",Font.BOLD,20));
hwtf4.setFont(new Font("",Font.BOLD,20));hwtf5.setFont(new Font("",Font.BOLD,20));hwta6.setFont(new Font("",Font.BOLD,20));
cktf1.setFont(new Font("",Font.BOLD,20));cktf2.setFont(new Font("",Font.BOLD,20));cktf3.setFont(new Font("",Font.BOLD,20));
cktf4.setFont(new Font("",Font.BOLD,20));cktf5.setFont(new Font("",Font.BOLD,20));
a.add(cglb1);a.add(cglb2);a.add(cglb3);
a.add(cgtf1);a.add(cgtf2);a.add(cgtf3);
b.add(cglb4);b.add(cglb5);b.add(cglb6);
b.add(cgtf4);b.add(cgtf5);b.add(cgtf6);
c.add(cglb7);c.add(cglb8);c.add(cglb9);
c.add(cgtf7);c.add(cgtf8);c.add(cgtf9);
d.add(jb1);d.add(jb2);
采购.add(a);采购.add(b);采购.add(c);采购.add(d);
e.add(xslb1);e.add(xslb2);e.add(xslb3);
e.add(xstf1);e.add(xstf2);e.add(xstf3);
f.add(xslb4);f.add(xslb5);f.add(xslb6);
f.add(xstf4);f.add(xstf5);f.add(xstf6);
g.add(xslb7);g.add(xslb8);g.add(xslb9);
g.add(xstf7);g.add(xstf8);g.add(xstf9);
h.add(jb3);h.add(jb4);
销售.add(e);销售.add(f);销售.add(g);销售.add(h);
i.add(hwlb1);i.add(hwlb2);
i.add(hwtf1);i.add(hwtf2);
j.add(hwlb3);j.add(hwlb4);j.add(hwlb5);
j.add(hwtf3);j.add(hwtf4);j.add(hwtf5);
k.add(hwlb6);k.add(hwta6);
l.add(jb5);l.add(jb6);
货物.add(i);货物.add(j);货物.add(k);货物.add(l);
m.add(cklb1);m.add(cklb2);
m.add(cktf1);m.add(cktf2);
n.add(cklb3);n.add(cklb4);n.add(cklb5);
n.add(cktf3);n.add(cktf4);n.add(cktf5);
o.add(jb7);o.add(jb8);
仓库.add(m);仓库.add(n);仓库.add(o);
((JPanel)getContentPane()).setOpaque(false);
}
public static void main (String args[])
{
添加 tianjia =new 添加();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1 先实现ActionListener接口
2 设置监听
3 实现功能
package untitled;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2009</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Frame1 extends JFrame {
JButton jButton1 = new JButton();
public Frame1() {
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception {
jButton1.setBounds(new Rectangle(73, 126, 133, 42));
jButton1.setText("jButton1");
jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));//设置监听
this.getContentPane().setLayout(null);
this.getContentPane().add(jButton1, null);
}
void jButton1_actionPerformed(ActionEvent e) {//实现功能
System.out.println("action");
}
}
class Frame1_jButton1_actionAdapter implements java.awt.event.ActionListener {//实现ActionListener接口
Frame1 adaptee;
Frame1_jButton1_actionAdapter(Frame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
2 设置监听
3 实现功能
package untitled;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2009</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Frame1 extends JFrame {
JButton jButton1 = new JButton();
public Frame1() {
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception {
jButton1.setBounds(new Rectangle(73, 126, 133, 42));
jButton1.setText("jButton1");
jButton1.addActionListener(new Frame1_jButton1_actionAdapter(this));//设置监听
this.getContentPane().setLayout(null);
this.getContentPane().add(jButton1, null);
}
void jButton1_actionPerformed(ActionEvent e) {//实现功能
System.out.println("action");
}
}
class Frame1_jButton1_actionAdapter implements java.awt.event.ActionListener {//实现ActionListener接口
Frame1 adaptee;
Frame1_jButton1_actionAdapter(Frame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询