エラーなしで実行されるこのコードがありますが、計画どおりに実行されていません。「重要!!」というラベルの付いたボタンをクリックしても、「続行」ボタンが表示されない理由を理解しようとしています。
表示されている唯一のものは、コード 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);