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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package composants;
/**
*
* @author pisix
*/
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableColumn;
import maison.Maison;
import maison.Piece;
public class Fenetre extends JFrame {
private JTable tableau;
private JButton change = new JButton("Changer la taille");
private List<Maison> p;
private List<Piece> pi;
private String[] columnNames = new String[]{"Numero", "Nom_Maison", "Nombre de Piece", "Nombre de Cmposant","Temperature"};
private Object[][] data;
public Fenetre(){
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Maisons");
this.setSize(600, 140);
p=SaveXmlComposants.getListeMaison("Maisons.xml");
data = new Object[p.size()][5];
Maison pp = null;
Piece pie = null;
for (int i = 0; i < p.size(); i++) {
pp = (Maison) p.get(i);
pi=p.get(i).getListePiece();
pie =(Piece) pi.get(i);
data[i][0] = i+1;
data[i][1] = pp.getNomMaison();
data[i][2] = pp.getListePiece().size();
data[i][3]=pie.getListeComposant().size();
data[i][4]=pie.getTempInterne();
}
this.tableau = new JTable(data, columnNames );
this.getContentPane().add(this.tableau);
}
public static void main(String[] args){
Fenetre fen = new Fenetre();
fen.setVisible(true);
}
} |
Partager