import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.*;
class bg implements ActionListener
{ JFrame jf;
JTable jt_yi,jt_two,jt_san,jt_si,jt_wu;
JScrollPane jsp_yi,jsp_two,jsp_san,jsp_si,jsp_wu;
JButton jb_js;
bg()
{ jf=new JFrame("表格");
jt_yi=new JTable();
jt_two=new JTable(10,5);
Object tableDate[][]=new Object[4][3];
tableDate[0][0]="张三"; tableDate[0][1]="男"; tableDate[0][2]=12;
tableDate[1][0]="王五"; tableDate[1][1]="男"; tableDate[1][2]=15;
tableDate[2][0]="王维"; tableDate[2][1]="男"; tableDate[2][2]=18;
tableDate[3][0]="李佳"; tableDate[3][1]="女"; tableDate[3][2]=21;
String name[]={"姓名","性别","年龄"};
jt_san=new JTable(tableDate,name);
Vector myrow=new Vector(5);
Vector mycol=new Vector(5);
mycol.add("姓名"); mycol.add("手机号"); mycol.add("服务商");
Vector x=new Vector();
x.add("张飞"); x.add(123344323); x.add("移动");
myrow.add(x);
x=new Vector();
x.add("关羽"); x.add(222124323); x.add("移动");
myrow.add(x);
x=new Vector();
x.add("曹操"); x.add(12366664); x.add("电信");
myrow.add(x);
x=new Vector();
x.add("周瑜"); x.add(44656243); x.add("移动");
myrow.add(x);
x=new Vector();
x.add("赵云"); x.add(1567674323); x.add("联通");
myrow.add(x);
jt_si=new JTable(myrow,mycol);
Integer xy[][]=new Integer[4][5];
xy[0][0]=32; xy[0][1]=800; xy[0][2]=200; xy[0][3]=20; xy[0][4]=0;
xy[1][0]=45; xy[1][1]=700; xy[1][2]=200; xy[1][3]=20; xy[1][4]=0;
xy[2][0]=12; xy[2][1]=800; xy[2][2]=100; xy[2][3]=10; xy[2][4]=0;
xy[3][0]=23; xy[3][1]=1000; xy[3][2]=80; xy[3][3]=20; xy[3][4]=0;
//xy[4][0]=78; xy[4][1]=800; xy[4][2]=90; xy[4][3]=20; xy[4][4]=0;
// xy[5][0]=78; xy[5][1]=800; xy[5][2]=90; xy[5][3]=20; xy[5][4]=0;
// xy[6][0]=78; xy[6][1]=800; xy[6][2]=90; xy[6][3]=20; xy[6][4]=0;
String name1[]={"编号","基本工资","本月奖金","本月扣款","应发工资"};
jt_wu=new JTable(xy,name1);
jsp_yi=new JScrollPane(jt_yi);
jsp_two=new JScrollPane(jt_two);
jsp_san=new JScrollPane(jt_san);
jsp_si=new JScrollPane(jt_si);
jsp_wu=new JScrollPane(jt_wu);
jb_js=new JButton("计算");
Container co=jf.getContentPane();
JPanel pp=new JPanel();
co.add(pp);
pp.setLayout(null);
pp.add(jsp_yi);pp.add(jsp_two);
pp.add(jsp_san);pp.add(jsp_si);
pp.add(jsp_wu);pp.add(jb_js);
jf.setSize(900,800);
jf.setLocation(100,100);
jf.setVisible (true);
jsp_yi.setBounds(10,10,400,150);
jsp_two.setBounds(450,10,400,150);
jsp_san.setBounds(10,200,400,150);
jsp_si.setBounds(450,200,400,150);
jsp_wu.setBounds(10,400,400,150);
jb_js.setBounds(450,450,80,50);
jt_san.setFont(new Font("宋体",Font.PLAIN,18));
jt_si.setFont(new Font("黑体",Font.PLAIN,22));
jt_wu.setFont(new Font("楷体",Font.PLAIN,26));
jsp_wu.setBorder(BorderFactory.createLineBorder(Color.red));
jt_si.setRowHeight(26);
System.out.println("行高="+jt_wu.getRowHeight() +"间距="+jt_wu.getRowMargin());
jt_wu.setRowHeight(50);
jt_wu.setRowMargin(15);
jt_wu.setSelectionForeground(Color.blue);
// jt_wu.setShowGrid(false);
jb_js.addActionListener(this);
}
public void actionPerformed(ActionEvent ee)
{ Object xx,yy,zz;
int zhi,mn;
for (mn=0;mn<jt_wu.getRowCount();mn++)
{ xx=jt_wu.getValueAt(mn,1);
yy=jt_wu.getValueAt(mn,2);
zz=jt_wu.getValueAt(mn,3);
zhi=(Integer)xx+(Integer)yy-(Integer)zz;
jt_wu.setValueAt(zhi, mn, 4 );
}
jt_wu.editCellAt(1,1);
System.out.println(jt_wu.getColumnName(1));
}
}
public class biaoge
{public static void main(String[] args)
{ new bg();
}
}