Class FlatTitlePane

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class FlatTitlePane extends JComponent
Provides the Flat LaF title bar.
See Also:
  • Field Details

    • KEY_DEBUG_SHOW_RECTANGLES

      static final String KEY_DEBUG_SHOW_RECTANGLES
      See Also:
    • isWindows_10

      private static final boolean isWindows_10
    • titleFont

      protected final Font titleFont
      Since:
      2.5
    • activeBackground

      protected final Color activeBackground
    • inactiveBackground

      protected final Color inactiveBackground
    • activeForeground

      protected final Color activeForeground
    • inactiveForeground

      protected final Color inactiveForeground
    • embeddedForeground

      protected final Color embeddedForeground
    • borderColor

      protected final Color borderColor
    • showIcon

      protected final boolean showIcon
      Since:
      2
    • showIconInDialogs

      protected final boolean showIconInDialogs
      Since:
      2.5
    • noIconLeftGap

      protected final int noIconLeftGap
      Since:
      2
    • iconSize

      protected final Dimension iconSize
    • titleMinimumWidth

      protected final int titleMinimumWidth
      Since:
      2.4
    • buttonMinimumWidth

      protected final int buttonMinimumWidth
      Since:
      2.4
    • buttonMaximizedHeight

      protected final int buttonMaximizedHeight
    • centerTitle

      protected final boolean centerTitle
    • centerTitleIfMenuBarEmbedded

      protected final boolean centerTitleIfMenuBarEmbedded
    • showIconBesideTitle

      protected final boolean showIconBesideTitle
      Since:
      2.4
    • rootPane

      protected final JRootPane rootPane
    • windowStyle

      protected final String windowStyle
    • leftPanel

      protected JPanel leftPanel
    • iconLabel

      protected JLabel iconLabel
    • titleLabel

      protected JLabel titleLabel
    • buttonPanel

      protected JPanel buttonPanel
    • iconifyButton

      protected JButton iconifyButton
    • maximizeButton

      protected JButton maximizeButton
    • restoreButton

      protected JButton restoreButton
    • closeButton

      protected JButton closeButton
    • window

      protected Window window
    • handler

      private final FlatTitlePane.Handler handler
    • mouseLayer

      final JPanel mouseLayer
      This panel handles mouse events if FlatLaf window decorations are used without native window border. E.g. on Linux.

      This panel usually has same bounds as the title pane, except if fullWindowContent mode is enabled.

      This panel is not a child of the title pane. Instead it is added by FlatRootPaneUI to the layered pane at a layer under the title pane and under the frame content. The separation is necessary for fullWindowContent mode, where the title pane is layered over the frame content (for title pane buttons), but the mousePanel needs to be layered under the frame content so that components on content pane can receive mouse events when located in title area.

    • windowTopBorderLayer

      final JPanel windowTopBorderLayer
      This panel paint a border at the top of the window in fullWindowContent mode, if FlatLaf window decorations are enabled. Only used on Windows 10.

      This panel is not a child of the title pane. Instead it is added by FlatRootPaneUI to the layered pane at a layer over all other layers.

    • laterCounter

      private int laterCounter
    • lastCaptionHitTestX

      private int lastCaptionHitTestX
    • lastCaptionHitTestY

      private int lastCaptionHitTestY
    • lastCaptionHitTestTime

      private long lastCaptionHitTestTime
    • lastCaptionHitTestResult

      private boolean lastCaptionHitTestResult
    • debugTitleBarHeight

      private int debugTitleBarHeight
    • debugAppIconBounds

      private Rectangle debugAppIconBounds
    • debugMinimizeButtonBounds

      private Rectangle debugMinimizeButtonBounds
    • debugMaximizeButtonBounds

      private Rectangle debugMaximizeButtonBounds
    • debugCloseButtonBounds

      private Rectangle debugCloseButtonBounds
  • Constructor Details

    • FlatTitlePane

      public FlatTitlePane(JRootPane rootPane)
  • Method Details

    • createTitlePaneBorder

      protected FlatTitlePane.FlatTitlePaneBorder createTitlePaneBorder()
    • createHandler

      protected FlatTitlePane.Handler createHandler()
    • addSubComponents

      protected void addSubComponents()
    • createButtons

      protected void createButtons()
    • createButton

      protected JButton createButton(String iconKey, String accessibleName, ActionListener action)
    • activeChanged

      protected void activeChanged(boolean active)
    • frameStateChanged

      protected void frameStateChanged()
    • updateVisibility

      protected void updateVisibility()
      Since:
      3
    • updateIcon

      protected void updateIcon()
    • updateFullWindowContentButtonsBoundsProperty

      void updateFullWindowContentButtonsBoundsProperty()
    • addNotify

      public void addNotify()
      Overrides:
      addNotify in class JComponent
    • removeNotify

      public void removeNotify()
      Overrides:
      removeNotify in class JComponent
    • getWindowTitle

      protected String getWindowTitle()
    • installWindowListeners

      protected void installWindowListeners()
    • uninstallWindowListeners

      protected void uninstallWindowListeners()
    • isFullWindowContent

      protected boolean isFullWindowContent()
      Since:
      3.4
    • hasVisibleEmbeddedMenuBar

      protected boolean hasVisibleEmbeddedMenuBar(JMenuBar menuBar)
      Returns whether this title pane currently has a visible and embedded menubar.
    • isMenuBarEmbedded

      protected boolean isMenuBarEmbedded()
      Returns whether the menubar should be embedded into the title pane.
    • getMenuBarBounds

      protected Rectangle getMenuBarBounds()
    • findHorizontalGlue

      protected Component findHorizontalGlue(JMenuBar menuBar)
    • titleBarColorsChanged

      protected void titleBarColorsChanged()
    • paint

      public void paint(Graphics g)
      Overrides:
      paint in class JComponent
    • debugPaintComponentWithMouseListener

      private void debugPaintComponentWithMouseListener(Graphics g, Color color, Component c, int x, int y)
    • debugPaintRect

      private void debugPaintRect(Graphics g, Color color, Rectangle r)
    • paintComponent

      protected void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • repaintWindowBorder

      protected void repaintWindowBorder()
    • iconify

      protected void iconify()
      Iconifies the window.
    • isWindowMaximized

      protected boolean isWindowMaximized()
      Since:
      2.4
    • maximize

      protected void maximize()
      Maximizes the window.
    • updateMaximizedBounds

      protected void updateMaximizedBounds()
    • isMaximizedBoundsFixed

      private boolean isMaximizedBoundsFixed()
      Frame.setMaximizedBounds() behaves different on some Java versions after issues https://bugs.openjdk.java.net/browse/JDK-8231564 and https://bugs.openjdk.java.net/browse/JDK-8176359 (see also https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8176359) were fixed in Java 15 and backported to 11.0.8 and 13.0.4.
    • restore

      protected void restore()
      Restores the window size.
    • maximizeOrRestore

      private void maximizeOrRestore()
    • close

      protected void close()
      Closes the window.
    • hasNativeCustomDecoration

      protected boolean hasNativeCustomDecoration()
      Returns whether windows uses native window border and has custom decorations enabled.
    • isWindowTopBorderNeeded

      boolean isWindowTopBorderNeeded()
    • updateNativeTitleBarHeightAndHitTestSpotsLater

      protected void updateNativeTitleBarHeightAndHitTestSpotsLater()
    • updateNativeTitleBarHeightAndHitTestSpots

      protected void updateNativeTitleBarHeightAndHitTestSpots()
    • boundsInWindow

      private Rectangle boundsInWindow(JComponent c)
    • captionHitTest

      private boolean captionHitTest(Point pt)
      Returns whether there is a component at the given location, that processes mouse events. E.g. buttons, menus, etc.

      Note:

      • This method is invoked often when mouse is moved over title bar and should therefore return quickly.
      • This method is invoked on 'AWT-Windows' thread (not 'AWT-EventQueue' thread) while processing Windows messages.
    • isTitleBarCaptionAt

      private boolean isTitleBarCaptionAt(Component c, int x, int y)