Cómo eliminar la barra de título en JFrame


Estoy usando el siguiente código para practicar,

Http://docs.oracle.com/javase/tutorial/uiswing/examples/layout/BorderLayoutDemoProject/src/layout/BorderLayoutDemo.java

También añado

frame.setSize(frame.getMaximumSize());

En el método createAndShowGUI (),

Lo que es más, quiero que esta ventana no tenga la barra de título, cierre y minimice los botones.

Probé el siguiente código,

frame.setUndecorated(true);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Si agrego este código antes de pack (), entra en infine loop con esto exception Excepción en el hilo "AWT-EventQueue-0" java.lang.NegativeArraySizeException

Si agrego la última línea del método createAndShowGUI() arroja Excepción en el hilo "AWT-EventQueue-0" java.awt.IllegalComponentStateException: El marco es visualizable.

¿Qué debo hacer ?

Gracias.

Author: mre, 2012-01-02

2 answers

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Already there
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.setUndecorated(true);
 33
Author: Joop Eggen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-01-02 14:24:04

Bueno, el siguiente fragmento de código en createAndShowGUI() funcionó para mí:

JFrame frame = new JFrame("BorderLayoutDemo");
frame.setUndecorated(true); // Remove title bar
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addComponentsToPane(frame.getContentPane());
frame.pack();
frame.setVisible(true);

Tenga en cuenta que no estoy seguro de lo que está tratando de lograr estableciendo manualmente el tamaño de un fotograma no realizado a su tamaño máximo, que será (0, 0) inicialmente.

 5
Author: mre,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-01-02 14:11:07