mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 15:27:16 -06:00
This commit is contained in:
@@ -47,6 +47,7 @@ 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 com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Flat LaF title bar.
|
* Provides the Flat LaF title bar.
|
||||||
@@ -58,6 +59,7 @@ import javax.swing.UIManager;
|
|||||||
* @uiDefault TitlePane.iconSize Dimension
|
* @uiDefault TitlePane.iconSize Dimension
|
||||||
* @uiDefault TitlePane.iconMargins Insets
|
* @uiDefault TitlePane.iconMargins Insets
|
||||||
* @uiDefault TitlePane.titleMargins Insets
|
* @uiDefault TitlePane.titleMargins Insets
|
||||||
|
* @uiDefault TitlePane.buttonMaximizedHeight int
|
||||||
* @uiDefault TitlePane.closeIcon Icon
|
* @uiDefault TitlePane.closeIcon Icon
|
||||||
* @uiDefault TitlePane.iconifyIcon Icon
|
* @uiDefault TitlePane.iconifyIcon Icon
|
||||||
* @uiDefault TitlePane.maximizeIcon Icon
|
* @uiDefault TitlePane.maximizeIcon Icon
|
||||||
@@ -74,6 +76,7 @@ class FlatTitlePane
|
|||||||
private final Color inactiveForeground = UIManager.getColor( "TitlePane.inactiveForeground" );
|
private final Color inactiveForeground = UIManager.getColor( "TitlePane.inactiveForeground" );
|
||||||
|
|
||||||
private final Dimension iconSize = UIManager.getDimension( "TitlePane.iconSize" );
|
private final Dimension iconSize = UIManager.getDimension( "TitlePane.iconSize" );
|
||||||
|
private final int buttonMaximizedHeight = UIManager.getInt( "TitlePane.buttonMaximizedHeight" );
|
||||||
|
|
||||||
private final JRootPane rootPane;
|
private final JRootPane rootPane;
|
||||||
|
|
||||||
@@ -118,7 +121,20 @@ class FlatTitlePane
|
|||||||
restoreButton = createButton( "TitlePane.restoreIcon", "Restore", e -> restore() );
|
restoreButton = createButton( "TitlePane.restoreIcon", "Restore", e -> restore() );
|
||||||
closeButton = createButton( "TitlePane.closeIcon", "Close", e -> close() );
|
closeButton = createButton( "TitlePane.closeIcon", "Close", e -> close() );
|
||||||
|
|
||||||
buttonPanel = new JPanel();
|
buttonPanel = new JPanel() {
|
||||||
|
@Override
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
Dimension size = super.getPreferredSize();
|
||||||
|
if( buttonMaximizedHeight > 0 &&
|
||||||
|
window instanceof Frame &&
|
||||||
|
(((Frame)window).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0 )
|
||||||
|
{
|
||||||
|
// make title pane height smaller when frame is maximized
|
||||||
|
size = new Dimension( size.width, Math.min( size.height, UIScale.scale( buttonMaximizedHeight ) ) );
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
};
|
||||||
buttonPanel.setOpaque( false );
|
buttonPanel.setOpaque( false );
|
||||||
buttonPanel.setLayout( new BoxLayout( buttonPanel, BoxLayout.X_AXIS ) );
|
buttonPanel.setLayout( new BoxLayout( buttonPanel, BoxLayout.X_AXIS ) );
|
||||||
if( rootPane.getWindowDecorationStyle() == JRootPane.FRAME ) {
|
if( rootPane.getWindowDecorationStyle() == JRootPane.FRAME ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user