When a window appears, there are two JRadioButton. Depending on which button is selected, the variable thing should be set to true or false. But no matter which button I press, lol turns out to be false. What's the matter?

public class tnn extends JDialog { private final JPanel contentPanel = new JPanel(); private final ButtonGroup buttonGroup = new ButtonGroup(); public boolean lol; /** * Launch the application. */ /** * Create the dialog. */ public tnn(erer owner) { super(owner, true); setTitle("\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438"); setBounds(100, 100, 377, 356); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(null); JLabel label = new JLabel("\u041A\u0435\u043C \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0433\u0440\u0430\u0442\u044C?"); label.setBounds(109, 22, 123, 28); contentPanel.add(label); JRadioButton krestik = new JRadioButton("\u0422\u0430\u0439\u0445\u044D\u0439"); buttonGroup.add(krestik); krestik.setBounds(54, 64, 109, 23); contentPanel.add(krestik); JRadioButton nolik = new JRadioButton("\u0423\u043C\u0430\u0440\u0443"); buttonGroup.add(nolik); nolik.setBounds(211, 64, 109, 23); contentPanel.add(nolik); JLabel label_1 = new JLabel(""); label_1.setIcon(new ImageIcon(tnn.class.getResource("/images/10.png"))); label_1.setBounds(36, 104, 99, 147); contentPanel.add(label_1); JLabel label_2 = new JLabel(""); label_2.setIcon(new ImageIcon(tnn.class.getResource("/images/20.png"))); label_2.setBounds(196, 123, 99, 117); contentPanel.add(label_2); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(krestik.isSelected()){ lol = true; } else lol = false; setVisible(false); dispose(); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); JButton cancelButton = new JButton("\u041E\u0442\u043C\u0435\u043D\u0430"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } public boolean isLol() { return lol; } 

}

  • Put 2 breakpoint and check, not? - Qwertiy
  • More like a decompile - GenCloud

0