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
| import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
@SuppressWarnings("serial")
public class ShowTable extends JFrame {
public ShowTable() {
super();
createAndShowGUI();
}
private void createAndShowGUI() {
Object[][] donnees = {
{"Swing", "Astral", "standard", Color.red, Boolean.TRUE},
{"Swing", "Mistral", "standard", Color.yellow, Boolean.FALSE},
{"Gin", "Oasis", "standard", Color.blue, Boolean.FALSE},
{"Gin", "boomerang", "compétition", Color.green, Boolean.TRUE},
{"Advance", "Omega", "performance", Color.cyan, Boolean.TRUE},
} ;
String[] titreColonnes = { "marque","modèle", "homologation",
"couleur", "vérifiée ?"};
JTable table = new JTable(donnees, titreColonnes);
this.setContentPane(new JScrollPane(table));
this.pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public static void main(String[] args) {
new ShowTable();
}
} |
Partager