bonjour tout le monds j'ai un grang probleme je ne sais pas il vient d'où

j'ai créé une classe qui permet de generer une matrice binaire aléatoire et qui renvoi comme argument une table ( la matrice qui est transformer en une table


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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import java.awt.BorderLayout;
 
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.util.Random;
 
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
 
 
public class matrice 
 
{
	 private int[][]  mat;
     private JTable table;
	 private int a, cpt=0, nb;
	 private  int [] []adjascence;
 
	 matrice (int som, JPanel p )
	 {
		 nb=0;
 
 
		 adjascence = new int[som][som];
			for (int m =0; m<adjascence.length; m++)
			{
				adjascence[m][m]=0;
			}
 
			for (int m=0; m<=som-1; m++)
			{
 
			  for (int m1=m+1; m1<som; m1++)	
			  {
				   Random q1 = new Random();
				   a= q1.nextInt(2);
 
 
				        adjascence[m][m1] =a; 
				    	adjascence[m1][m] = a;
 
     			}
 
			  }
 
			table = new JTable();
			 table = new JTable(som+1, som+1);
			table.setTableHeader(null);
 
			table.setValueAt("  Sommet", 0, 0);
 
 
			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() );
			JScrollPane scroller = new JScrollPane( table);
			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(Color.black);
			scroller1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
			scroller1.setVisible(true);
 
			scroller.setPreferredSize(new Dimension(677,20));
			p.add(scroller, BorderLayout.SOUTH );
			p.add(scroller);
 
			scroller1.setPreferredSize(new Dimension(20,450));
			p.add(scroller1, BorderLayout.EAST);
			p.add(scroller1);
 
			table.setFont(new Font("Tahoma",Font.BOLD,12));
			table.setEnabled(false);
			table.setBorder(BorderFactory.createLineBorder(Color.red,1));
			table.setDefaultRenderer(Object.class, new CenterTableCellRenderer());
			table.setVisible(true);
 
			table = (JTable) scroller.getViewport().getView();
 
 
			table.revalidate();
			table.setBackground(Color.black);
 
			table.setBounds(0,0,675,450);
 
 
 
 
	 }
	 public  JTable getmatrice()
	 {
		 return this.table;
	 }
 
}
j'ai créer une autre classe qui va transformer la table en une matrice


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
import java.awt.BorderLayout;
 
import javax.swing.JPanel;
import javax.swing.JTable;
 
 
public class tabTomat
 
{
	private int [][] mat;
	private Object ob;
	private String val;
 
 tabTomat(JTable tab,int som)
 
 {
	 	 for (int s=0; s<=som-1; s++)
	 {
		 for (int s1=0; s1<=som-1; s1++)
	 {
		 ob=tab.getValueAt(s, s1);
		 val = ob.toString();
		 mat[s][s1]= Integer.parseInt(val);
	 }
	 }
 }
 public int [] []gettabTomat()
 {
	 return this.mat;
 }
 
}
mais quand j'ai fait l'appel des deux classes rien ne s'affiche



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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
 
public class debut extends JFrame
{
 
 
	/**
         * 
         */
	private static final long serialVersionUID = 1L;
	JButton  entrer, quitter, apropos ;
	private JPanel p;
	private JTable tab=null;
	private matrice mat;
	private tabTomat aa;
	private int [][]mm;
	private JFrame f;
 
 
 
 
	debut(String titre )
	{
		super(titre);
		setDefaultLookAndFeelDecorated(true);
		this.setContentPane(new JPanelImageBg("Image/FOND1.jpg"));
		setIconImage(new ImageIcon("Image/icone.GIF" ).getImage());
		setFont(new Font("Tahoma",Font.BOLD,12));
 
		setSize(700,500);
		this.setLocationRelativeTo(null);
		this.setResizable(false);
 
		Container contentPane = getContentPane();
		contentPane.setLayout(new FlowLayout());		
 
		JButton entrer = new JButton(new ImageIcon("Image/entrer1.gif"));
		contentPane.add(entrer);
 
		JButton apropos = new JButton(new ImageIcon("Image/apropos1.gif"));		
		contentPane.add(apropos);
 
		JButton quitter = new JButton(new ImageIcon("Image/quitter1.gif"));		
		contentPane.add(quitter);
 
		Container contentPane1= getContentPane();
		contentPane1.setLayout(new BorderLayout());
 
		entrer.setBounds(120,420,100,40);
		apropos.setBounds(290,420,120,40);
		quitter.setBounds(480,420,100,40);
 
		this.setVisible(true);
 
 
		quitter.addActionListener(new ActionListener()
		     {
			public void actionPerformed(ActionEvent e)
			{
				f = new JFrame("zzz");
				f.setBounds(100,100,700,400);
				f.setVisible(true);
				p.setLayout( new BorderLayout() );
				p.setBackground(Color.red);
				p.setBounds(200,200,300,100);
 
				mat = new matrice(4,p);
				tab= mat.getmatrice();
 
				aa = new tabTomat(tab,4);
				mm= aa.gettabTomat();
				p.add(tab);
				p.setVisible(true);
				f.add(p);
 
			}
		     });		
 
		apropos.addActionListener(new propos());
		entrer.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
			setVisible(false);	
			new prog();		
			}
 
		});
		}
	public static void main( String[] argv )
	{
		new debut ("Begin");	
	}}


où est le probleme et est ce que je peux créer une classe qui me renvoie en meme temps la table et la matrice


ce que j'ai fait est deux créer deux classes une qui me recupere la table l'autre la matrice


SVP j'ai besion de vos aide je suis bloquée