import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Display implements ActionListener{ JButton jb = new JButton("OK"); JRadioButton jrb = new JRadioButton("OK"); public Display() { JFrame frm = new JFrame("test"); frm.getContentPane().setLayout(new FlowLayout()); jb.addActionListener(this); frm.getContentPane().add(jb,null); frm.getContentPane().add(jrb,null); frm.pack(); frm.show(); } public void actionPerformed(ActionEvent e){ if(e.getSource().equals(jb) && jrb.isSelected()) System.out.println("ok"); } public static void main(String [] args) { //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { new Display(); } }); } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question