W tym miejscu mam warning:
NewFile dialog = new NewFile(new javax.swing.JFrame(), true);
dialog.setLocation(centerFrame());
dialog.setVisible(true);
if (dialog.getReturnStatus() == dialog.RET_OK){ // <- tu WARNING
.......
}
dialog.setVisible(false);
dialog.dispose();
Netbeans proponuje mi zastąpić dialog.RET_OK na NewFile.RET_OK, ale gdy to zrobię pokazuje się error:
"boolean cannot be dereferenced".
Proszę o wszelkie wskazówki, co jest nie tak.
Poniżej jest prawie cała klasa NewFile:
public class NewFile extends JDialog {
/** A return status code - returned if Cancel button has been pressed */
public static final int RET_CANCEL = 0;
/** A return status code - returned if OK button has been pressed */
public static final int RET_OK = 1;
/** Creates new form NewFile */
public NewFile(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
jRadioButton1.setSelected(true);
}
/** @return the return status of this dialog - one of RET_OK or RET_CANCEL */
public int getReturnStatus() {
return returnStatus;
}
........ // tutaj była metoda initComponents()
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {
doClose(RET_OK);
}
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
doClose(RET_CANCEL);
}
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {
doClose(RET_CANCEL);
}
private void doClose(int retStatus) {
returnStatus = retStatus;
this.setVisible(false);
this.dispose();
}
}
Edit: dodam, że w programie mam dużo podobnych jdialogów, ale tylko tutaj pokazuje warning, a po zamienieniu nazwy zmiennej na klasę, error.