1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
public class Tab extends Frame
{
Tab()
{
Object[][] data ={
{"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml", "Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true)},
{"Philip", "Milne", "Pool", new Integer(10), new Boolean(false)}
};
String[] nomsColonnes = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};
JTable table = new JTable(data, nomsColonnes);
JScrollPane sp = new JScrollPane(table);
// Si on veut définir la taille de la zone
// daffichage :
table.setPreferredScrollableViewportSize(
new Dimension(500, 70));
JPanel P=new JPanel();
P.add(table);
add(P);
setVisible(true);
pack();
this.addWindowListener(new C());
}
class C extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
dispose();
}
}
public static void main(String[]args)
{
Tab t=new Tab();
}
} |
Partager