У меня этот код работает без ошибок, но он не работает так, как я планировал. Я пытаюсь понять, почему моя кнопка «Продолжить» не отображается, когда я нажимаю кнопку с надписью «important !!».JDialog modal problem java gui
Единственное, что отображается, это пустое всплывающее окно, которое является частью кода JDialog, и оно установлено как модальное и видимое. Я просто не могу понять. Если кто-нибудь может мне помочь, я буду очень признателен.
JPanel hehePanel = new JPanel(new FlowLayout(FlowLayout.RIGHT,10,20));
JDialog dialog = new JDialog((JFrame)null);
dialog.getContentPane().add(hehePanel,BorderLayout.CENTER);
JButton hButton = new JButton("important!!");
JButton fButton = new JButton(" on construction !!");
JButton exitButton = new JButton("EXIT CAW ");
hehePanel.add(hButton);
hButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final JPanel hehePanel = new JPanel();
final JDialog dialog = new JDialog();
dialog.getContentPane().add(hehePanel,BorderLayout.PAGE_END);
dialog.toFront();
dialog.setModal(true);
dialog.pack();
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
JButton closebutton = new JButton("Continue");
closebutton.setActionCommand("continue");
closebutton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (evt.getActionCommand().equals("continue")) {
dialog.dispose();
}
}
});
hehePanel.add(closebutton);
}
});
hehePanel.add(fButton);
hehePanel.add(exitButton);
спасибо большое, я очень ценю! – thegamer