mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 06:57:13 -06:00
This commit is contained in:
@@ -18,6 +18,7 @@ package com.formdev.flatlaf.ui;
|
|||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.Dialog;
|
import java.awt.Dialog;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
@@ -53,6 +54,8 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.JRootPane;
|
import javax.swing.JRootPane;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.border.AbstractBorder;
|
||||||
|
import javax.swing.border.Border;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
@@ -109,6 +112,8 @@ class FlatTitlePane
|
|||||||
FlatTitlePane( JRootPane rootPane ) {
|
FlatTitlePane( JRootPane rootPane ) {
|
||||||
this.rootPane = rootPane;
|
this.rootPane = rootPane;
|
||||||
|
|
||||||
|
setBorder( new TitlePaneBorder() );
|
||||||
|
|
||||||
addSubComponents();
|
addSubComponents();
|
||||||
activeChanged( true );
|
activeChanged( true );
|
||||||
|
|
||||||
@@ -123,7 +128,6 @@ class FlatTitlePane
|
|||||||
iconLabel.setBorder( new FlatEmptyBorder( UIManager.getInsets( "TitlePane.iconMargins" ) ) );
|
iconLabel.setBorder( new FlatEmptyBorder( UIManager.getInsets( "TitlePane.iconMargins" ) ) );
|
||||||
titleLabel.setBorder( new FlatEmptyBorder( UIManager.getInsets( "TitlePane.titleMargins" ) ) );
|
titleLabel.setBorder( new FlatEmptyBorder( UIManager.getInsets( "TitlePane.titleMargins" ) ) );
|
||||||
|
|
||||||
leftPanel.setBorder( new LineBorder( Color.red ) );
|
|
||||||
leftPanel.setLayout( new BoxLayout( leftPanel, BoxLayout.LINE_AXIS ) );
|
leftPanel.setLayout( new BoxLayout( leftPanel, BoxLayout.LINE_AXIS ) );
|
||||||
leftPanel.setOpaque( false );
|
leftPanel.setOpaque( false );
|
||||||
leftPanel.add( iconLabel );
|
leftPanel.add( iconLabel );
|
||||||
@@ -315,6 +319,12 @@ class FlatTitlePane
|
|||||||
Rectangle getMenuBarBounds() {
|
Rectangle getMenuBarBounds() {
|
||||||
Rectangle bounds = menuBarPlaceholder.getBounds();
|
Rectangle bounds = menuBarPlaceholder.getBounds();
|
||||||
bounds = SwingUtilities.convertRectangle( menuBarPlaceholder.getParent(), bounds, rootPane );
|
bounds = SwingUtilities.convertRectangle( menuBarPlaceholder.getParent(), bounds, rootPane );
|
||||||
|
|
||||||
|
// add menu bar bottom border insets to bounds so that menu bar overlaps
|
||||||
|
// title pane border (menu bar border is painted over title pane border)
|
||||||
|
Insets borderInsets = getBorder().getBorderInsets( this );
|
||||||
|
bounds.height += borderInsets.bottom;
|
||||||
|
|
||||||
return FlatUIUtils.subtractInsets( bounds, UIScale.scale( getMenuBarMargins() ) );
|
return FlatUIUtils.subtractInsets( bounds, UIScale.scale( getMenuBarMargins() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,6 +463,39 @@ class FlatTitlePane
|
|||||||
hitTestSpots.add( r );
|
hitTestSpots.add( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---- class TitlePaneBorder ----------------------------------------------
|
||||||
|
|
||||||
|
private class TitlePaneBorder
|
||||||
|
extends AbstractBorder
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||||
|
super.getBorderInsets( c, insets );
|
||||||
|
|
||||||
|
// if menu bar is embedded, add bottom insets of menu bar border
|
||||||
|
Border menuBarBorder = getMenuBarBorder();
|
||||||
|
if( menuBarBorder != null ) {
|
||||||
|
Insets menuBarInsets = menuBarBorder.getBorderInsets( c );
|
||||||
|
insets.bottom += menuBarInsets.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
return insets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
||||||
|
// if menu bar is embedded, paint menu bar border
|
||||||
|
Border menuBarBorder = getMenuBarBorder();
|
||||||
|
if( menuBarBorder != null )
|
||||||
|
menuBarBorder.paintBorder( c, g, x, y, width, height );
|
||||||
|
}
|
||||||
|
|
||||||
|
private Border getMenuBarBorder() {
|
||||||
|
JMenuBar menuBar = rootPane.getJMenuBar();
|
||||||
|
return (menuBar != null && isMenuBarEmbedded()) ? menuBar.getBorder() : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---- class Handler ------------------------------------------------------
|
//---- class Handler ------------------------------------------------------
|
||||||
|
|
||||||
private class Handler
|
private class Handler
|
||||||
|
|||||||
Reference in New Issue
Block a user