Is there a way to remove the [ -- ] button on a window?

Yeah, well I am currently trying to create a window with just [x]. I'm currently trying to create a 1x1 undecorated JFrame and create a JDialog which is a child of the JFrame and send all windowActivated/Deactivated events to the JFrame instead. Currently its not working.


public class Dummy extends JFrame {
private GameWindow window;

public Dummy() {
setUndecorated(true);
setSize(1, 1);
setVisible(true);
window = new GameWindow();
window.setVisible(true);
this.addWindowListener(new DummyWindowListener(window));
}
}




public class GameWindow extends JDialog {
}



Did that because JDialogs only have a close button. DummyWindowListener is just a listener which redirects all events to the JDialog instead.




Couldn’t find anything to prevent it, but you can switch back when someone hits that button.


import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;

public class Test extends JFrame implements WindowListener {
    private static final long serialVersionUID = 1L;

    public Test() {
        addWindowListener(this);
    }
    public void windowActivated(WindowEvent e) {
    }
    public void windowClosed(WindowEvent e) {
    }
    public void windowClosing(WindowEvent e) {
        System.exit(0);
    }
    public void windowDeactivated(WindowEvent e) {
    }
    public void windowDeiconified(WindowEvent e) {
    }
    public void windowIconified(WindowEvent e) {
        setExtendedState(JFrame.NORMAL);
    }
    public void windowOpened(WindowEvent e) {
    }

    public static void main(String args[]) {
        Test t = new Test();
        t.setSize(400, 300);
        t.setVisible(true);
    }
}