probleme d'affichage de JTable
bonjour tout le monde
j'ai un problème dans l'affichage de mes JTable, je veux à chaque fois que je clique sur un button une nouvelle table s'affiche dans un JPanel, mais il ne m'affiche que la premiere table créée, les nouvelles table sont créées mais pas affichées?
voici le code qui me crée la table
Code:
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
|
table = new JTable(som+1,som+1);
table.setBorder(BorderFactory.createLineBorder(Color.black,1));
table.setTableHeader(null);
for (int n=1; n<=som; n++)
{
table.setValueAt(" S"+(n-1), n, 0);
}
for (int n=1; n<=som; n++)
{ table.setValueAt(" S"+(n-1), 0, n);}
for (int n=1; n<=som; n++)
{
for (int m=1; m<=som; m++)
table.setValueAt(adjascence[n-1][m-1], n, m);
}
p.setLayout( new BorderLayout() );
p.setBackground(new Color(47,44,44));
JScrollPane scroller = new JScrollPane( table);
scroller.setBackground(new Color(47,44,44));
scroller.setBackground(Color.black);
scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scroller.setVisible(true);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
scroller.setViewportView(table);
JScrollPane scroller1 = new JScrollPane( table);
scroller1.setBackground(new Color(47,44,44));
scroller1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scroller1.setVisible(true);
p.add(scroller1);
table.setFont(new Font("Tahoma",Font.BOLD,12));
table.setEnabled(false);
table.setBorder(BorderFactory.createLineBorder(Color.black,1));
table.setVisible(true);
table.revalidate();
table.setBounds(110,111,305,250);
table.setSelectionBackground(new Color(47,44,44));
table.setSelectionForeground(Color.white); |