/* * testCode.java * * Created on 2 juin 2006, 12:09 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package ihm; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.ScrollPaneConstants; /** * * @author CompactNC6000 */ public class testCode extends JFrame{ JTable table; XrdIServerTypeTableModel model; Object [][] data; //String[] columnNames = {"Server name", "Data", "Redirector", "Supervisor"}; /** Creates a new instance of testCode */ public testCode() { data = new Object[1][4]; JCheckBox j1 = new JCheckBox("a"); j1.setSelected(true); j1.addActionListener(new ChangeEtat(1)); JCheckBox j2 = new JCheckBox("b"); j2.setSelected(false); j2.addActionListener(new ChangeEtat(2)); JCheckBox j3 = new JCheckBox("c"); j3.setSelected(false); j3.addActionListener(new ChangeEtat(3)); data[0][0] = "essai"; data[0][1] = j1; data[0][2] = j2; data[0][3] = j3; model = new XrdIServerTypeTableModel(data); // Creation of the table with the check boxes table = new JTable(model); JScrollPane scrollPane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //JScrollPane scrollPane = new JScrollPane(table); //table.setPreferredScrollableViewportSize(new Dimension(500, 70)); this.addWindowListener(new WindowAdapter(){ public void actionPerformed(ActionEvent e) { System.exit(0); } }); this.add(scrollPane); this.pack(); this.setVisible(true); } //Classe interne class ChangeEtat implements ActionListener { private int nb; public ChangeEtat(int nbCheckBox){ nb = nbCheckBox; } public void actionPerformed(ActionEvent e) { int ligne = table.getSelectedRow(); model.changeLigne(ligne,nb); model.fireTableDataChanged(); table.repaint(); } } public static void main (String [] args){ testCode t = new testCode(); } }