mardi 25 avril 2017

set only 1 checkbox selected in java

I'm trying to handle two events i.e. openfile and newfile with checkbox as setting only 1checkbox checked at a time. Minimal Code

new File

private void newfileActionPerformed(java.awt.event.ActionEvent evt) {                                        
    textArea.setText("");
    newfile.setSelected(true);
    setTitle(filename);
}

openFile

private void openfileActionPerformed(java.awt.event.ActionEvent evt) {

    openfile.setSelected(true);

    FileDialog filedialog = new FileDialog(textEditorGui.this, "Open File", FileDialog.LOAD);
    filedialog.setVisible(true);

    if(filedialog.getFile() != null)
    {
        filename = filedialog.getDirectory() + filedialog.getFile();
        setTitle(filename);
    }

I've tried setting if else control as counter to check if the checkbox is selected, but It is not working. It's partially working, in this case the checkbox is getting checked but the openfile is not working.

I've tried setting if else control in both blocks to check if the checkbox is not selected then set that particular checkbox true




Aucun commentaire:

Enregistrer un commentaire