当我尝试显示来自JOptionPane的消息对话时,如果我试图从另一个类访问它,则两个窗口都会无响应。如果我从主类中执行它,它可以工作,但如果我尝试从我的SettingsWindow jframe中使用它,它会崩溃。
JButton btnSave = new JButton("Save");
btnSave.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(Integer.parseInt(textField.getText())>=Integer.parseInt(textField_1.getText())) {
MainClass.vars.setProperty("Width", textField.getText());
MainClass.vars.setProperty("Height", textField_1.getText());
MainClass.savePrefs();
optionsWindow.setVisible(false);
} else {
JOptionPane.showMessageDialog(null, "Height cannot be larger than width!");
//MainClass.showMessage("Height cannot be larger than width!");
}
}
});
btnSave.setBounds(10, 168, 284, 24);
jp.add(btnSave);
我尝试通过主类中的方法访问它,但也崩溃了。