Bonjour,
j'aimerai cacher certaint element dans un gridLyaout qui n'apparaitrait qu'au clic sur un JRadioButton.






sur cette image je voudrais cacher la ligne discount: et celle d'en dessous
soit 2 JLabel et 4 JTextfiled.

poru cela je les est bein definit a setVisible(true);

et dans mon actionLIstener qque voici :
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
 
public void actionPerformed (ActionEvent evt) {
		/*on active l'affichage des champs spectifiques au discount */
		reduction = true;
		//definir le code pour le choix du syteme monetaire de la reduction
		Object obj = evt.getSource();
		JRadioButton o = (JRadioButton) obj;
 
		System.out.println("on est dans action" );
		euroValueData.setVisible(true);     
		livreValueData.setVisible(true);    
		dollarsValueData.setVisible(true);		
		euroEquivalence.setVisible(true);    
		livreEquivalence.setVisible(true);  
		dollardEquivalance.setVisible(true);
		discount.setText("Discount :");
		this.updateUI();
 
 
 
	}
pour le rafraichissement j'ai utilise "this.updateUI();" je ne sais aps si c'est la bonne methode non plus.


Et j'obtient une belle erreur :
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
 
on est dans action
true
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at CadrePrincipal.actionPerformed(CadrePrincipal.java:174)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.JToggleButton$ToggleButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
qui pointe sur mon premier setVisible(true)

voilu