From 2e479691f66ab8562a76dd6031b1fce13a436262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Levy=2EXie-=E8=A7=A3=E5=AE=89=E6=A3=AE?= Date: Fri, 27 Sep 2024 10:06:52 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-133897=20fix:TabPane=E5=9E=82=E7=9B=B4?= =?UTF-8?q?=E5=B8=83=E5=B1=80=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/frpane/FineTabbedPane.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java index 0ce50448ed..508b58ca96 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/FineTabbedPane.java @@ -43,7 +43,7 @@ public class FineTabbedPane extends Box { private final UIButtonGroup tabGroup; private final Map tabComponents; private final int[] tabLayout; - private final boolean useFitTab ; + private final boolean useFitTab; private FineTabbedPane(Map tabComponents, float headRatio, int[] tabLayout, boolean useFitTab) { this.headRatio = headRatio; @@ -142,35 +142,45 @@ public class FineTabbedPane extends Box { initCoreComponents(); setMatchParentSize(true); float flexRatio = (1 - headRatio) / 2; - int headHeight = FlatUIUtils.getUIInt("Component.defaultHeight",24) * tabLayout.length / 2; - Component component = useFitTab ? row(flex(), cell(tabGroup), flex()).getComponent() : row(flex(flexRatio), cell(tabGroup).weight(headRatio), flex(flexRatio)).getComponent(); + int headHeight = FlatUIUtils.getUIInt("Component.defaultHeight", 24) * tabLayout.length / 2; + Component tabRow = useFitTab ? row(flex(), cell(tabGroup), flex()).getComponent() : row(flex(flexRatio), cell(tabGroup).weight(headRatio), flex(flexRatio)).getComponent(); + Component backgroundComp = createBackGroundComp(); add( column( - cell(component), - flex() + cell(tabRow), + cell(centerPane).with(it -> it.setBorder(new ScaledEmptyBorder(10, 10, 10, 10))).weight(1) ), column( fix(headHeight), - cell(centerPane).with(it -> it.setBorder(new ScaledEmptyBorder(headHeight + 10, 10, 10, 10))).weight(1) + cell(backgroundComp).weight(1) ) ); fillBackgroundColor(); } + private Component createBackGroundComp() { + JPanel pane = new JPanel(); + pane.putClientProperty(PANEL_TYPE, ROUNDED_PANEL); + pane.setBackground(getFillColor()); + return pane; + } + private void initCoreComponents() { cards = new CardLayout(); centerPane = new JPanel(cards); - centerPane.putClientProperty(PANEL_TYPE, ROUNDED_PANEL); tabComponents.forEach((key, value) -> { value.setOpaque(false); centerPane.add(value, key); }); } + private Color getFillColor() { + return FineUIUtils.getUIColor("FineTabbedPane.background", "fill.gray"); + } + private void fillBackgroundColor() { - Color fillColor = FineUIUtils.getUIColor("FineTabbedPane.background", "fill.gray"); Color defaultColor = FineUIUtils.getUIColor("default.background", "Component.background"); - ColorUtils.syncBackgroundIfAbsent(centerPane, fillColor, defaultColor); + ColorUtils.syncBackgroundIfAbsent(centerPane, getFillColor(), defaultColor); } private void initListeners() {