Note that there are some explanatory texts on larger screens.

plurals
  1. POJava swing CheckBox not selected while display Conformation Dialog
    primarykey
    data
    text
    <p>I am working on an application in which I have developed a window with three check boxes. When first and second check boxes are selected, new windows will be opened as desired. The third check box is for closing the application. When Exit check box is selected, it is showing the conformation Dialog as desired but Exit check box is not ticked.</p> <p>I could not trace out the issue here. Please help me to resolve this issue! <img src="https://i.stack.imgur.com/ZUYub.png" alt="enter image description here"></p> <p>package jcheckbox;</p> <pre><code> import java.awt.*; import java.awt.event.*; import javax.swing.*; public class InitiaaWindow extends JPanel { static JFrame frame = new JFrame("Credit Contract Validation"); private static final long serialVersionUID = 1L; JCheckBox jValidateECOUT; JCheckBox jValidateSuperDeals; JCheckBox jEXIT; JLabel jlbPicture,jlbPicture1; CheckBoxListener myListener = null; public InitiaaWindow() { myListener = new CheckBoxListener(); jValidateECOUT = new JCheckBox("ValidateECOUT"); jValidateECOUT.setMnemonic(KeyEvent.VK_C); jValidateECOUT.setSelected(false); jValidateECOUT.addItemListener(myListener); jValidateSuperDeals = new JCheckBox("ValidateSuperDeals"); jValidateSuperDeals.setMnemonic(KeyEvent.VK_G); jValidateSuperDeals.setSelected(false); jValidateSuperDeals.addItemListener(myListener); jEXIT = new JCheckBox("EXIT"); jEXIT.setMnemonic(KeyEvent.VK_G); jEXIT.setSelected(false); jEXIT.addItemListener(myListener); jlbPicture = new JLabel(new ImageIcon("src/jcheckbox/image.jpg")); jlbPicture1 = new JLabel(new ImageIcon("src/jcheckbox/image1.jpg")); JPanel jplCheckBox = new JPanel(); jplCheckBox.setLayout(new GridLayout(0, 1)); jplCheckBox.add(jValidateECOUT); jplCheckBox.add(jValidateSuperDeals); jplCheckBox.add(jEXIT); setLayout(new BorderLayout()); add(jplCheckBox, BorderLayout.WEST); add(jlbPicture1, BorderLayout.CENTER); add(jlbPicture, BorderLayout.EAST); setBorder(BorderFactory.createEmptyBorder(40,40,40,40)); } class CheckBoxListener implements ItemListener { public void itemStateChanged(ItemEvent e) { if (jValidateECOUT.isSelected()) { try { UIPack.UI.myMethod(null); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (jValidateSuperDeals.isSelected()) { try { ValidateSuperDealsUIPack.UI.ValidateSuperDealsUI(null); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else if (jEXIT.isSelected()) { int dialogButton = JOptionPane.YES_NO_OPTION; int dialogResult = JOptionPane.showConfirmDialog(null, "Would you like to close the application", "Conformation message",dialogButton); if(dialogResult==0) System.exit(1); else JOptionPane.getRootFrame().dispose(); } } } public static void main(String s[]) { frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setContentPane(new InitiaaWindow()); frame.pack(); frame.setVisible(true); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload