Bonjour,

Je galère depuis quelques heures à essayer de passer d'une JFrame à une autre sur Java.

Cela fonctionne bien sur mes autres JFrame mais pas vers la JFrame VisuUser...

Ma class MenuGenerale où l'utilisateur arrive:
Code java : 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
 
public class MenuGeneral extends JFrame implements ActionListener
{
	/**************************** Les boutons ***********************************/
	private JButton jbAjouterDoc = new JButton("Ajouter");
	private JButton jbModifierDoc = new JButton("Modifier");
	private JButton jbSupprimerDoc = new JButton("Supprimer");
	private JButton jbAjouterUser = new JButton("Ajouter");
	private JButton jbModifierUser = new JButton("Modifier");
	private JButton jbSupprimerUser = new JButton("Supprimer");
	private JButton jbCons = new JButton("Consulter");
	private JButton jbAPropos = new JButton("A propos");
	private JButton jbQuitter = new JButton("Quitter");
	private JButton jbAide = new JButton("Aide");
 
 
	/**************************** Les menus **************************************/
 
	private JMenuBar uneBarre = new JMenuBar();
	private JMenu document = new JMenu("Documents");
	private JMenu utilisateurs = new JMenu("Utilisateurs");
	private JMenu cons = new JMenu("Consulter");
	private JMenu APropos = new JMenu("A Propos");
	private JMenu Aide = new JMenu("Aide");	
	private JMenu Quitter = new JMenu("Quitter");	
 
	private JMenuItem itemAjouterDoc = new JMenuItem("Ajouter");
	private JMenuItem itemModifierDoc = new JMenuItem("Modifier");
	private JMenuItem itemSupprimerDoc = new JMenuItem("Supprimer");
	private JMenuItem itemAjouterUser = new JMenuItem("Ajouter");
	private JMenuItem itemVueUser = new JMenuItem("Lister User");
	private JMenuItem itemModifierUser = new JMenuItem("Modifier");
	private JMenuItem itemSupprimerUser = new JMenuItem("Supprimer");
	private JMenuItem itemAide = new JMenuItem("Aide");
	private JMenuItem itemAPropos = new JMenuItem("A propos");
	private static JPanel central = new JPanel();
 
	private JPanel jpImg = new JPanel();
	private ImageIcon icone;
	private JLabel image = new JLabel(icone);
 
	public MenuGeneral ()
	{
		/***********************************Taille fenetre************************/
		super ();
		this.setBounds(200, 200, 400, 300);
		this.setResizable(false);
		this.setTitle("Gestionnaire");	
		this.setLayout(null); //aucun quadrillage
 
		this.jlExplication.setBounds(20, -10, 320, 240);
		this.add(this.jlExplication);
 
		this.jpImg.setBounds(290, 0, 100, 100);
		ImageIcon icon = new ImageIcon("src/logo.png");
	    JLabel img = new JLabel(icon);
	    jpImg.add(img);
		jpImg.setVisible(true);
		this.add(jpImg);
 
		/************************************ Construction du menu ***********************/
		this.uneBarre.add(this.document);
		this.uneBarre.add(this.utilisateurs);
		this.uneBarre.add(this.cons);
		this.uneBarre.add(this.Aide);
		this.uneBarre.add(this.APropos);
		this.uneBarre.add(this.Quitter);
		this.setJMenuBar(this.uneBarre);
 
		this.document.add(this.itemAjouterDoc);
		this.document.add(this.itemModifierDoc);
		this.document.add(this.itemSupprimerDoc);
		this.utilisateurs.add(this.itemAjouterUser);
		this.utilisateurs.add(this.itemModifierUser);
		this.utilisateurs.add(this.itemSupprimerUser);
		this.Aide.add(this.itemAide);
		this.APropos.add(this.itemAPropos);
		this.cons.add(this.itemVueUser);
 
		/********************************** Rendre les boutons menus cliquables ****************/
		this.itemAjouterDoc.addActionListener(this);
		this.itemModifierDoc.addActionListener(this);
		this.itemSupprimerDoc.addActionListener(this);
		this.itemAjouterUser.addActionListener(this);
		this.itemModifierUser.addActionListener(this);
		this.itemSupprimerUser.addActionListener(this);
		this.itemVueUser.addActionListener(this);
		this.itemAide.addActionListener(this);
		this.itemAPropos.addActionListener(this);
 
		final MenuGeneral i = this;
		this.Quitter.addMenuListener(new MenuListener() {
 
			@Override
			public void menuSelected(MenuEvent e) {
				int x = JOptionPane.showConfirmDialog(i, "Voulez vous quitter?", "Quitter", JOptionPane.OK_CANCEL_OPTION);
				if (x == 0)
				{
					dispose();	
				}
			}
 
			@Override
			public void menuDeselected(MenuEvent e) {
				// TODO Auto-generated method stub
 
			}
 
			@Override
			public void menuCanceled(MenuEvent e) {
				// TODO Auto-generated method stub
 
			}
		} );;
		this.Aide.addActionListener(this);
		this.APropos.addActionListener(this);
 
 
		this.setVisible(true);
	}
 
	public static void main(String[] args) 
	{
		MenuGeneral accueil = new MenuGeneral();
	}
 
	public void actionPerformed(ActionEvent e) 
	{
		if (e.getSource() == this.itemAjouterDoc || e.getSource() == this.jbAjouterDoc) 
		{
			this.dispose();
			new DocAjouter();
		}
		else if (e.getSource() == this.jbModifierDoc || e.getSource() == this.itemModifierDoc)
		{
			this.dispose();
			new DocModification();
		}
		else if (e.getSource() == this.jbSupprimerDoc || e.getSource() == this.itemSupprimerDoc)
		{
			this.dispose();
			new DocSuppression();
		}
		else if (e.getSource() == this.jbAjouterUser || e.getSource() == this.itemAjouterUser)
		{
			this.dispose();
			new UserAjout();
		}
		else if (e.getSource() == this.jbModifierUser || e.getSource() == this.itemModifierUser)
		{
			this.dispose();
			new UserModification();
		}
		else if (e.getSource() == this.jbSupprimerUser || e.getSource() == this.itemSupprimerUser)
		{
			this.dispose();
			new UserSuppression();
		}
 
		else if (e.getSource() == this.jbAide || e.getSource() == this.itemAide)
		{
			this.dispose();
			new Aide();
		}
		else if (e.getSource() == this.jbAPropos || e.getSource() == this.itemAPropos)
		{
			this.dispose();
			new APropos();
		}
		else if (e.getSource() == this.itemVueUser)
		{
			new VisuUser();
		}
		else if (e.getSource() == this.jbQuitter || e.getSource() == this.Quitter)
		{
			int x = JOptionPane.showConfirmDialog(this, "Voulez vous quitter?", "Quitter", JOptionPane.OK_CANCEL_OPTION);
			if (x == 0)
			{
				this.dispose();	
			}
		}
	}
}

et ma class VisuUser lorsque l'utilisateur clique sur VueUser:
Code java : 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
 
public class VisuUser extends JFrame implements ActionListener
{
	public static void main(String[] args) 
	{
	    try 
	    {
	    	String url = "jdbc:mysql://localhost:3306/db";
	    	String user = "root";
	    	String password = "";
 
	    	//selection des passdoc
	    	Connection con = DriverManager.getConnection(url, user, password);
	    	String queryString = "rqt";
	      	Statement stm = con.createStatement();
	      	ResultSet rs = stm.executeQuery(queryString);
 
	      	//calcul du nombre d'enregistrement
	      	Statement stm1 = con.createStatement();
	      	ResultSet res = stm1.executeQuery("rqt");
	      	int nbLignes=0;
	      	res.next();
	      	nbLignes = res.getInt("nbLignes");
 
	      	//création du tableau
	      	String col[] = { "" };
	      	String cont[][] = new String[nbLignes][5];
	      	int i = 0;
	      	while (rs.next()) 
	      	{
		        int id = rs.getInt("");
		        String nom = rs.getString("");
		        String prenom = rs.getString("");
		        String login = rs.getString("");
		        String type = rs.getString("");
		        cont[i][0] =;
		        cont[i][1] = ;
		        cont[i][2] = ;
		        cont[i][3] = ;
		        cont[i][4] = ;
		        i++;
	      	}
 
	      	DefaultTableModel model = new DefaultTableModel(cont, col);
	      	JTable table = new JTable(model);
	      	table.setShowGrid(true);
	      	table.setShowVerticalLines(true);
	      	JScrollPane pane = new JScrollPane(table);
	      	JFrame frame = new JFrame("Consulter Utilisateurs");
	      	JPanel panel = new JPanel();
	      	panel.add(pane);
	      	frame.add(panel);
	      	frame.setSize(500, 750);
	      	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	      	frame.setVisible(true);
	    } 
	    catch (SQLException ex) 
	    {
	    	ex.printStackTrace();
	    }
	}
 
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
 
	}
}

Je suis débutant en Java donc soyez indulgent sur mon code ^^"
Merci de votre aide