mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-08 15:00:54 +03:00
Theme Editor: fixed tabbed pane "more tabs" popup in preview
This commit is contained in:
@@ -18,7 +18,9 @@
|
|||||||
package com.formdev.flatlaf.themeeditor;
|
package com.formdev.flatlaf.themeeditor;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.HierarchyEvent;
|
import java.awt.event.HierarchyEvent;
|
||||||
|
import java.util.function.Function;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.UIDefaults.ActiveValue;
|
import javax.swing.UIDefaults.ActiveValue;
|
||||||
import javax.swing.UIDefaults.LazyValue;
|
import javax.swing.UIDefaults.LazyValue;
|
||||||
@@ -26,6 +28,7 @@ import javax.swing.event.DocumentEvent;
|
|||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
import com.formdev.flatlaf.FlatLaf;
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
import com.formdev.flatlaf.extras.components.*;
|
import com.formdev.flatlaf.extras.components.*;
|
||||||
|
import com.formdev.flatlaf.ui.FlatTabbedPaneUI;
|
||||||
import net.miginfocom.swing.*;
|
import net.miginfocom.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +46,7 @@ class FlatThemePreview
|
|||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
|
tabbedPane1.uiDefaultsGetter = this::getUIDefaultProperty;
|
||||||
tabbedPane1.setTabLayoutPolicy( JTabbedPane.SCROLL_TAB_LAYOUT );
|
tabbedPane1.setTabLayoutPolicy( JTabbedPane.SCROLL_TAB_LAYOUT );
|
||||||
tabbedPane1.addTab( "Tab 1", null );
|
tabbedPane1.addTab( "Tab 1", null );
|
||||||
tabbedPane1.addTab( "Tab 2", null );
|
tabbedPane1.addTab( "Tab 2", null );
|
||||||
@@ -224,7 +228,7 @@ class FlatThemePreview
|
|||||||
flatButton1 = new FlatButton();
|
flatButton1 = new FlatButton();
|
||||||
buttonLabel = new JLabel();
|
buttonLabel = new JLabel();
|
||||||
button1 = new JButton();
|
button1 = new JButton();
|
||||||
testDefaultButton1 = new FlatThemePreview.TestDefaultButton();
|
testDefaultButton1 = new FlatThemePreview.PreviewDefaultButton();
|
||||||
helpButton = new FlatButton();
|
helpButton = new FlatButton();
|
||||||
hSpacer2 = new JPanel(null);
|
hSpacer2 = new JPanel(null);
|
||||||
toggleButtonLabel = new JLabel();
|
toggleButtonLabel = new JLabel();
|
||||||
@@ -272,7 +276,7 @@ class FlatThemePreview
|
|||||||
toolTipLabel = new JLabel();
|
toolTipLabel = new JLabel();
|
||||||
toolTip1 = new JToolTip();
|
toolTip1 = new JToolTip();
|
||||||
tabbedPaneLabel = new JLabel();
|
tabbedPaneLabel = new JLabel();
|
||||||
tabbedPane1 = new JTabbedPane();
|
tabbedPane1 = new FlatThemePreview.PreviewTabbedPane();
|
||||||
|
|
||||||
//======== this ========
|
//======== this ========
|
||||||
setLayout(new MigLayout(
|
setLayout(new MigLayout(
|
||||||
@@ -585,7 +589,7 @@ class FlatThemePreview
|
|||||||
private FlatButton flatButton1;
|
private FlatButton flatButton1;
|
||||||
private JLabel buttonLabel;
|
private JLabel buttonLabel;
|
||||||
private JButton button1;
|
private JButton button1;
|
||||||
private FlatThemePreview.TestDefaultButton testDefaultButton1;
|
private FlatThemePreview.PreviewDefaultButton testDefaultButton1;
|
||||||
private FlatButton helpButton;
|
private FlatButton helpButton;
|
||||||
private JPanel hSpacer2;
|
private JPanel hSpacer2;
|
||||||
private JLabel toggleButtonLabel;
|
private JLabel toggleButtonLabel;
|
||||||
@@ -633,12 +637,12 @@ class FlatThemePreview
|
|||||||
private JLabel toolTipLabel;
|
private JLabel toolTipLabel;
|
||||||
private JToolTip toolTip1;
|
private JToolTip toolTip1;
|
||||||
private JLabel tabbedPaneLabel;
|
private JLabel tabbedPaneLabel;
|
||||||
private JTabbedPane tabbedPane1;
|
private FlatThemePreview.PreviewTabbedPane tabbedPane1;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
|
|
||||||
//---- class TestDefaultButton --------------------------------------------
|
//---- class PreviewDefaultButton -----------------------------------------
|
||||||
|
|
||||||
private static class TestDefaultButton
|
private static class PreviewDefaultButton
|
||||||
extends JButton
|
extends JButton
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -646,4 +650,47 @@ class FlatThemePreview
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---- class PreviewTabbedPane --------------------------------------------
|
||||||
|
|
||||||
|
private static class PreviewTabbedPane
|
||||||
|
extends JTabbedPane
|
||||||
|
{
|
||||||
|
Function<Object, Object> uiDefaultsGetter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateUI() {
|
||||||
|
setUI( new PreviewFlatTabbedPaneUI( uiDefaultsGetter ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---- class PreviewFlatTabbedPaneUI --------------------------------------
|
||||||
|
|
||||||
|
private static class PreviewFlatTabbedPaneUI
|
||||||
|
extends FlatTabbedPaneUI
|
||||||
|
{
|
||||||
|
private final Function<Object, Object> uiDefaultsGetter;
|
||||||
|
|
||||||
|
PreviewFlatTabbedPaneUI( Function<Object, Object> uiDefaultsGetter ) {
|
||||||
|
this.uiDefaultsGetter = uiDefaultsGetter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JButton createMoreTabsButton() {
|
||||||
|
return new PreviewFlatMoreTabsButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---- class PreviewFlatMoreTabsButton --------------------------------
|
||||||
|
|
||||||
|
protected class PreviewFlatMoreTabsButton
|
||||||
|
extends FlatMoreTabsButton
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void actionPerformed( ActionEvent e ) {
|
||||||
|
FlatLaf.runWithUIDefaultsGetter( uiDefaultsGetter, () -> {
|
||||||
|
super.actionPerformed( e );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 3,alignx left,growx 0"
|
"value": "cell 1 3,alignx left,growx 0"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreview$TestDefaultButton" ) {
|
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreview$PreviewDefaultButton" ) {
|
||||||
name: "testDefaultButton1"
|
name: "testDefaultButton1"
|
||||||
"text": "OK"
|
"text": "OK"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
@@ -404,7 +404,7 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 22"
|
"value": "cell 0 22"
|
||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
|
add( new FormContainer( "com.formdev.flatlaf.themeeditor.FlatThemePreview$PreviewTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
|
||||||
name: "tabbedPane1"
|
name: "tabbedPane1"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 22"
|
"value": "cell 1 22"
|
||||||
|
|||||||
Reference in New Issue
Block a user