显示Jframe但不在任务栏上显示标题栏

Cha*_*Pye 13 java swing

在我的应用程序中,我在屏幕的角落显示一个Jframe以通知.我想只显示Jframe并且不在任务栏显示标题栏.

我怎样才能做到这一点?

Joe*_*han 28

如果您希望窗口只显示并且既没有标题栏也没有出现在任务栏中,请使用a JWindow.

如果您希望窗口显示并具有标题栏但未显示在任务栏中,请使用a JDialog.

  • 这是对的.JFrame意味着主要的应用程序窗口(即框架窗口).JWindow是任何弹出窗口.JDialog是框架,但它是一个辅助窗口,因此它不会显示在任务栏中. (5认同)

Mas*_*dul 13

JDK 1.7为您提供方法setType.使用以下方法.

JFrame.setType(javax.swing.JFrame.Type.UTILITY)
Run Code Online (Sandbox Code Playgroud)

  • 在 Linux 中不起作用。在 Windows 中工作。不知道Mac。 (2认同)

小智 5

"你所要做的就是将你的JFrame"type"属性设置为"UTILITY"并且你拥有它!"

这确实有效,至少在Java 1.7下,它与上面的"myframe".setType(Type.UTILITY)相同,而不是Type.POPUP.测试类型弹出窗口(在win 7下)无法从任务栏中删除它,Type.UTILITY可以.

未修饰将没有所需的结果(因为它从窗口中删除标题栏,而不是任务栏)

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
    }
Run Code Online (Sandbox Code Playgroud)


lin*_*159 3

您可以尝试使用 JWindow 代替。