Bonjour,

J'aimerais pouvoir afficher seulement les colonnes où il y a des croix dans les checkbox, comment je peux faire merci d'avance

Mon programme affiche un tableau :

Nom : tableau.PNG
Affichages : 146
Taille : 10,3 Ko

J'ai crée un Panel :

Nom : Menu.PNG
Affichages : 146
Taille : 6,6 Ko

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
public class FactureTableModel extends AbstractTableModel {
 
    /**
         * 
         */
	private static final long serialVersionUID = 1L;
	private List<Entry<String, Facture>> factures;
 
    public FactureTableModel(Map<String, Facture> data) {
        this.factures = new ArrayList<Entry<String, Facture>>(data.entrySet()); // Idealement trier les "entry" pour avoir un affichage consistent
    }
 
 
    @Override
    public int getRowCount() {
        return factures.size();
    }
 
 
 
    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Entry<String, Facture> player = factures.get(rowIndex);
        switch (columnIndex) {
            case 0: return player.getValue().getNumerofacture();
            case 1: return player.getValue().getIdentifiantbeneficiaire();
            case 2: return player.getValue().getIdentetat();
            case 3: return player.getValue().getNumeroamexecutant();
 
 
        }
        return null;
    }
 
 
	@Override
	public int getColumnCount() {
 
		return 5;
	}
 
 
 
 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public void showtable (Map<String, Facture> data) throws IllegalAccessException, NoSuchFieldException{
 
			JTable table = new JTable(new FactureTableModel(data));
 
			table.getColumn("A").setHeaderValue("Numéro de facture");
			table.getColumn("B").setHeaderValue("Identifiant beneficiaire");
			table.getColumn("C").setHeaderValue("Identetat");
			table.getColumn("D").setHeaderValue("Numero am executant");
 
	        JFrame frame = new JFrame();
	        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	        JScrollPane scrollPane = new JScrollPane(table);
	        table.setFillsViewportHeight(true);
 
	        frmTnr.getContentPane().add(scrollPane, BorderLayout.CENTER);
	        frmTnr.setSize(900, 500);
	        frmTnr.setVisible(true);
 
	}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
72
73
74
75
76
public class MenuModel extends JFrame {
 
	private JPanel contentPane;
 
	/**
         * Launch the application.
         */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					MenuModel frame = new MenuModel();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
 
	/**
         * Create the frame.
         */
	public MenuModel() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
 
		JCheckBox chckbxNumeroFacture = new JCheckBox("Numero de facture");
 
		JCheckBox chckbxIdentifiantBeneficiaire = new JCheckBox("Identifiant beneficiaire");
 
		JCheckBox chckbxIdentEtat = new JCheckBox("Etat facture");
 
		JCheckBox chckbxNumeroamExecutant = new JCheckBox("Numero am executant");
 
		JButton btnAfficherTableau = new JButton("Afficher tableau");
		btnAfficherTableau.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
 
 
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPane.createSequentialGroup()
							.addComponent(chckbxNumeroFacture)
							.addPreferredGap(ComponentPlacement.RELATED, 214, Short.MAX_VALUE)
							.addComponent(btnAfficherTableau))
						.addComponent(chckbxIdentifiantBeneficiaire)
						.addComponent(chckbxIdentEtat)
						.addComponent(chckbxNumeroamExecutant)))
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
						.addComponent(chckbxNumeroFacture)
						.addComponent(btnAfficherTableau))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(chckbxIdentifiantBeneficiaire)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(chckbxIdentEtat)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(chckbxNumeroamExecutant)
					.addContainerGap(159, Short.MAX_VALUE))
		);
		contentPane.setLayout(gl_contentPane);
	}
}