Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show Jframe but not show title bar on task bar

Tags:

java

swing

In my application, I show a Jframe at the corner of screen for notification. And I want to show only Jframe and do not display a title bar at task bar.

How can I do that?

like image 413
Chan Pye Avatar asked Jan 13 '10 04:01

Chan Pye


People also ask

How hide title bar in Netbeans?

The title bar can be removed by calling setUndecorated(true) on the Frame or JFrame instance, i.e. by setting the "undecorated" property to true . This removes both the title bar and the surrounding frame.

How do you make a JFrame visible?

When you create a JFrame object, by default, it is not visible. You need to call its setVisible(boolean visible) method to make it visible. If you pass true to this method, the JFrame is made visible, and if you pass false, it is made invisible. new JFrame("Simplest Swing").

How do I display the JFrame in the middle of the screen?

Just click on form and go to JFrame properties, then Code tab and check Generate Center .


3 Answers

If you want the window to just appear and have neither a title bar nor appear in the taskbar, use a JWindow.

If you want the window to appear and have a title bar but to not appear in the taskbar, use a JDialog.

like image 143
Joe Carnahan Avatar answered Sep 25 '22 18:09

Joe Carnahan


JDK 1.7 brings you method setType. Use following method.

JFrame.setType(javax.swing.JFrame.Type.UTILITY)
like image 39
Masudul Avatar answered Sep 23 '22 18:09

Masudul


"All you'd have to do is to set your JFrame "type" property to "UTILITY" and there you have it!"

This does work, at least under Java 1.7, its the same as the above "myframe".setType(Type.UTILITY) instead of Type.POPUP. Testing type popup (under win 7) does not work to remove it from the taskbar, Type.UTILITY does.

Undecorated will not have the desired results (as that removes the title bar from the window, not the taskbar)

public class Window extends Container implements Accessible {
    /**
     * Enumeration of available <i>window types</i>.
     *
     * A window type defines the generic visual appearance and behavior of a
     * top-level window. For example, the type may affect the kind of
     * decorations of a decorated {@code Frame} or {@code Dialog} instance.
     * <p>
     * Some platforms may not fully support a certain window type. Depending on
     * the level of support, some properties of the window type may be
     * disobeyed.
     *
     * @see   #getType
     * @see   #setType
     * @since 1.7
     */
    public static enum Type {
        /**
         * Represents a <i>normal</i> window.
         *
         * This is the default type for objects of the {@code Window} class or
         * its descendants. Use this type for regular top-level windows.
         */
        NORMAL,

        /**
         * Represents a <i>utility</i> window.
         *
         * A utility window is usually a small window such as a toolbar or a
         * palette. The native system may render the window with smaller
         * title-bar if the window is either a {@code Frame} or a {@code
         * Dialog} object, and if it has its decorations enabled.
         */
        UTILITY,

        /**
         * Represents a <i>popup</i> window.
         *
         * A popup window is a temporary window such as a drop-down menu or a
         * tooltip. On some platforms, windows of that type may be forcibly
         * made undecorated even if they are instances of the {@code Frame} or
         * {@code Dialog} class, and have decorations enabled.
         */
        POPUP
    }
like image 26
CodeMnke Avatar answered Sep 22 '22 18:09

CodeMnke