Полагаю, кнопка должна иметь заголовок «Закрыть» в приведенном ниже коде, но не имеет:
public class Test_Actions extends JDialog
{
private AbstractAction closeAction = new AbstractAction()
{
{
putValue("NAME", "Close");
}
@Override
public void actionPerformed(ActionEvent arg0)
{
Test_Actions.this.setVisible(false);
Test_Actions.this.dispatchEvent(new WindowEvent(Test_Actions.this, WindowEvent.WINDOW_CLOSING));
}
};
public Test_Actions()
{
JLabel label = new JLabel("Hello world");
JButton button = new JButton(closeAction);
//button.setText("Text");
setLayout(new BorderLayout());
add(label, BorderLayout.CENTER);
add(button, BorderLayout.SOUTH);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
public static void main(String[] args) throws InterruptedException, InvocationTargetException
{
final Test_Actions dialog = new Test_Actions();
dialog.setModal(true);
SwingUtilities.invokeAndWait(new Runnable()
{
@Override
public void run()
{
dialog.pack();
dialog.setVisible(true);
}
});
System.out.println("Here");
}
}