Aller au contenu
View in the app

A better way to browse. Learn more.

Next

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[JAVA]Interface graphique

Featured Replies

Posté(e)

Salut,

j'ai crée une classe permettant de cocher des noms.

Je voudrais savoir comment faire pour n'avoir le droit de cocher qu'un nom à la fois.

Avec ma classe actuelle, je peux cocher tous les noms

import javax.swing.*;

public class CheckBoxTest {  
public static void main(String[] args) {  
JFrame frame = new JFrame(); 
JPanel panel = new JPanel(); 
JCheckBox b1 = new JCheckBox("Pierre"); 
JCheckBox b2 = new JCheckBox("Paul"); 
JCheckBox b3 = new JCheckBox("Jacques"); 
JCheckBox b4 = new JCheckBox("Andre"); 
frame.setTitle("CheckBoxTest"); 
frame.setSize(400,300); 
frame.setVisible(true); 
panel.add(b1); 
panel.add(b2); 
panel.add(b3); 
panel.add(b4);
frame.getContentPane().add(panel); 
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
} 
}

Merci

Modifié par Premium

Posté(e)

Il existe un JRadioButton qui fait que tu ne peux en cocher qu'un

Sinon dans tes evenements, tu comptes combien de cases sont cochées et si ce chiffre et >=1 alors tu empeches d'en cocher d'autres avant d'avoir décoché celle qui est cochée.

AU fait, si tu utilises java1.5 frame.getContentPane().add(panel); s'ecrit frame.add(panel);

Posté(e)

Sinon regarde du côté de la classe ButtonGroup

ButtonGroup g = new ButtonGroup();
g.add(b1);
g.add(b2);
...

Modifié par magnig

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.