Salut.

J'ai un petit soucis d'affichage sous Eclipse. J'ai deux classes ("meteorologie" et "Identification") faisant parties du package "stat_meteo". Pour simplifier, ma classe meteorologie contient un Jpanel dans lequel se trouve un autre JPanel "jPUtilisateur" et un JTabbedPane "jTPOngletConfig". Ma classe Identification a elle entre autre un "public String droit".

J'instancie dans le main se trouvant dans ma classe meteorologie un objet Identification. Je fais un setVisible pour les deux, et les deux s'affichent.
le problème vient après. Je souhaite que ce soit soit "jTPOngletConfig", soit "jPUtilisateur" qui soit visible, et uniquement après la saisie du mot de passe contenue dans une base Mysql (utilisation de mysql-connector).

Voici ma classe Identification :

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
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
package stat_meteo;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import javax.swing.JTextField;
import java.awt.Point;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.*;
 
import javax.swing.JPasswordField;
import javax.swing.JButton;
 
public class Identification extends JFrame {
 
	private static final long serialVersionUID = 1L;
 
	private JPanel jContentPane = null;
 
	private JLabel jLEnterId = null;
 
	private JTextField jTFEnter_log = null;
 
	private JPasswordField jPFPass = null;
 
	public JButton jBIdentification = null;
 
	String sLog = null;
	String sPass = null;
	public String droit = null;
	Statement stmt = null;
	int ligne;
 
	private JLabel jLNom = null;
 
	private JLabel jLPass = null;
 
	/**
         * This is the default constructor
         */
	public Identification() {
		super();
		initialize();
		try {
			// tenter de récupérer le driver Mysql
			Class.forName("com.mysql.jdbc.Driver").newInstance();    
			System.out.println("Chargement du pilote Mysql réussi");
		}
		catch(Exception ee) {
		   System.err.print("Erreur de chargement du pilote : ");
		   System.err.println(ee.getMessage());
		}
	}
 
	/**
         * This method initializes this
         * 
         * @return void
         */
	private void initialize() {
		this.setSize(356, 293);
		this.setContentPane(getJContentPane());
		this.setTitle("Identification");
	}
 
	/**
         * This method initializes jContentPane
         * 
         * @return javax.swing.JPanel
         */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLPass = new JLabel();
			jLPass.setText("Pass :");
			jLPass.setSize(new Dimension(43, 23));
			jLPass.setLocation(new Point(30, 135));
			jLNom = new JLabel();
			jLNom.setText("User name :");
			jLNom.setSize(new Dimension(70, 23));
			jLNom.setLocation(new Point(30, 90));
			jLEnterId = new JLabel();
			jLEnterId.setBounds(new Rectangle(75, 45, 196, 23));
			jLEnterId.setText("Entrez vos identifiants :");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(jLEnterId, null);
			jContentPane.add(getJTFEnter_log(), null);
			jContentPane.add(getJPFPass(), null);
			jContentPane.add(getJBIdentification(), null);
			jContentPane.add(jLNom, null);
			jContentPane.add(jLPass, null);
		}
		return jContentPane;
	}
 
	/**
         * This method initializes jTFEnter_log 
         *      
         * @return javax.swing.JTextField       
         */
	private JTextField getJTFEnter_log() {
		if (jTFEnter_log == null) {
			jTFEnter_log = new JTextField();
			jTFEnter_log.setSize(new Dimension(196, 23));
			jTFEnter_log.setLocation(new Point(105, 90));
		}
		return jTFEnter_log;
	}
 
	/**
         * This method initializes jPFPass      
         *      
         * @return javax.swing.JPasswordField   
         */
	private JPasswordField getJPFPass() {
		if (jPFPass == null) {
			jPFPass = new JPasswordField();
			jPFPass.setBounds(new Rectangle(105, 135, 196, 23));
		}
		return jPFPass;
	}
 
	/**
         * This method initializes jBIdentification     
         *      
         * @return javax.swing.JButton  
         */
	private JButton getJBIdentification() {
		if (jBIdentification == null) {
			jBIdentification = new JButton();
			jBIdentification.setBounds(new Rectangle(105, 180, 135, 32));
			jBIdentification.setText("S'identifier");
			jBIdentification.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					sLog = jTFEnter_log.getText();
					sPass = new String(jPFPass.getPassword());
					try{
						Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/meteo?user="+sLog+"&password="+sPass+"");
						String sql = "SELECT nom,pass,droits FROM utilisateurs WHERE nom='"+sLog+"' AND pass='"+sPass+"';";
						stmt = conn.createStatement();
						ResultSet RSet = stmt.executeQuery(sql);
						RSet.last();			//Saut sur la derniere rangée...
						ligne = RSet.getRow();	//récupération du nombre de résultat
						System.out.println("droit : "+droit);
						if(ligne!=0){
							RSet.first();
							droit = RSet.getString(3);
							System.out.println("droit : "+droit);	//affichage des droits de cet user
						}
						conn.close();
					}
					catch(SQLException ex){
						System.out.println("SQLException: " + ex.getMessage());
						System.out.println(ligne);
						System.out.println(droit);
					}
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
				}
			});
		}
		return jBIdentification;
	}
 
}  //  @jve:decl-index=0:visual-constraint="10,10"
Voici mon main (généré en partie par Eclipse) :

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
public static void main(String[] args) {
		// TODO Raccord de méthode auto-généré
		
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				meteorologie thisClass = new meteorologie();
				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				thisClass.setVisible(true);
				Identification Ident_fen;
				Ident_fen = new Identification();
				Ident_fen.setVisible(true);
				while(Ident_fen.droit==null){
					
				}
				if(Ident_fen.droit=="admin"){
					jTPOngletConfig.setVisible(true);
				}
				if(Ident_fen.droit=="user"){
					jPUtilisateur.setVisible(true);
				}
			}
		});		
	}

J'ai mis en rouge ce qui me pose problème. Depuis que j'ai mis ce test, la seule chose qui s'affiche, ce sont les cadres de mes classes, pas leurs contenues. Du coup l'identification, n'est même pas possible. Je ne vois pas comment regler ce soucis.

Merci d'avance