?? b.java
字號:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Win extends JFrame
{
JTable table;
Object a[][];
Object name[] = {"姓名","性別","出生日期","年級","學院","班級","班職務","部門","部職務","地址","電話"};
int i;
Container c;
public Win()
{
i=0;
c=getContentPane();
//c.add(new JScrollPane(table),BorderLayout.CENTER);
setSize(600,400);
setVisible(true);
c.validate();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void hangshu(int num)
{
a=new Object[num][11];
table =new JTable(a,name);
table.setRowHeight(20);
//table.setRowMargin(50);
table.setSelectionBackground(Color.green);
c.removeAll();
c.add(new JScrollPane(table),BorderLayout.CENTER);
validate();
}
public void input(String s0,String s1,String s2,String s3,String s4,String s5,String s6,
String s7,String s8,String s9,String s10)
{ a[i][0] =s0;
a[i][1] =s1;
a[i][2] =s2;
a[i][3] =s3;
a[i][4] =s4;
a[i][5] =s5;
a[i][6] =s6;
a[i][7] =s7;
a[i][8] =s8;
a[i][9] =s9;
a[i][10] =s10;
i++;
}
public void output()
{
for(int m = 0;m<i;m++)
{
for(int j=0;j<11;j++)
System.out.println(a[m][j]);
}
}
}
public class b
{
public static void main(String args[ ])
{
Win win=new Win();
win.hangshu(30);
win.input("劉鵬","男","1986年11月2日","06級","計算機學院","1","跟班","體育部",
"部長","呼蘭","123");
win.input("王慧玲","女","1985年11月2日","04級","軟件學院","1","學習委員","女生部",
"部長","呼蘭","123");
win.input("鄔志剛","女男","1985年11月2日","04級","軟件學院","1","班長","體育部",
"部長","呼蘭","123");
win.output();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -