Merge PR #396: Typography

This commit is contained in:
Karl Tauber
2021-11-19 14:57:36 +01:00
33 changed files with 4151 additions and 210 deletions

View File

@@ -25,7 +25,6 @@ import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.Insets;
@@ -52,6 +51,7 @@ import java.util.prefs.Preferences;
import javax.lang.model.SourceVersion;
import javax.swing.*;
import net.miginfocom.swing.*;
import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.FlatDarculaLaf;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatIntelliJLaf;
@@ -754,8 +754,7 @@ class FlatThemeFileEditor
private void about() {
JLabel titleLabel = new JLabel( "FlatLaf Theme Editor" );
Font titleFont = titleLabel.getFont();
titleLabel.setFont( titleFont.deriveFont( (float) titleFont.getSize() + UIScale.scale( 6 ) ) );
titleLabel.putClientProperty( FlatClientProperties.STYLE_CLASS, "h1" );
String link = "https://www.formdev.com/flatlaf/";
JLabel linkLabel = new JLabel( "<html><a href=\"#\">" + link + "</a></html>" );

View File

@@ -46,6 +46,7 @@ class FlatThemePreview
private final FlatThemePreviewAll allTab;
private final FlatThemePreviewButtons buttonsTab;
private final FlatThemePreviewSwitches switchesTab;
private final FlatThemePreviewFonts fontsTab;
private final Map<LazyValue, Object> lazyValueCache = new WeakHashMap<>();
private int runWithUIDefaultsGetterLevel;
@@ -61,9 +62,11 @@ class FlatThemePreview
allTab = new FlatThemePreviewAll( this );
buttonsTab = new FlatThemePreviewButtons( this );
switchesTab = new FlatThemePreviewSwitches( this );
fontsTab = new FlatThemePreviewFonts();
tabbedPane.addTab( "All", createPreviewTab( allTab ) );
tabbedPane.addTab( "Buttons", createPreviewTab( buttonsTab ) );
tabbedPane.addTab( "Switches", createPreviewTab( switchesTab ) );
tabbedPane.addTab( "Fonts", createPreviewTab( fontsTab ) );
selectRecentTab();
tabbedPane.addChangeListener( e -> selectedTabChanged() );
@@ -175,7 +178,8 @@ class FlatThemePreview
Object value = textArea.propertiesSupport.getParsedProperty( (String) key );
inGetDefaultFont = "defaultFont".equals( key );
boolean isDefaultFont = "defaultFont".equals( key );
inGetDefaultFont = isDefaultFont;
try {
if( value instanceof LazyValue ) {
value = lazyValueCache.computeIfAbsent( (LazyValue) value, k -> {
@@ -189,6 +193,12 @@ class FlatThemePreview
// System.out.println( key + " = " + value );
// for "defaultFont" never return a value that is not a font
// (e.g. a color for "defaultFont = #fff") to avoid StackOverflowError
// in Active.createValue()
if( isDefaultFont && !(value instanceof Font) )
return null;
// If value is null and is a property that is defined in a core theme,
// then force the value to null.
// This is necessary for cases where the current application Laf defines a property
@@ -196,7 +206,7 @@ class FlatThemePreview
// E.g. FlatLightLaf defines Button.focusedBackground, but in FlatDarkLaf
// it is not defined. Without this code, the preview for FlatDarkLaf would use
// Button.focusedBackground from FlatLightLaf if FlatLightLaf is the current application Laf.
if( value == null && FlatThemePropertiesBaseManager.getDefindedCoreKeys().contains( key ) && !"defaultFont".equals( key ) )
if( value == null && FlatThemePropertiesBaseManager.getDefindedCoreKeys().contains( key ) && !isDefaultFont )
return FlatLaf.NULL_VALUE;
return value;
@@ -215,6 +225,7 @@ class FlatThemePreview
{
tabbedPane.setLeadingComponent(previewLabel);
tabbedPane.setTabAreaAlignment(FlatTabbedPane.TabAreaAlignment.trailing);
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
add(tabbedPane, BorderLayout.CENTER);
@@ -223,8 +234,8 @@ class FlatThemePreview
add(previewSeparator, BorderLayout.LINE_START);
//---- previewLabel ----
previewLabel.setText(" Preview ");
previewLabel.setFont(previewLabel.getFont().deriveFont(previewLabel.getFont().getSize() + 6f));
previewLabel.setText(" Preview ");
previewLabel.putClientProperty("FlatLaf.styleClass", "h2");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}

View File

@@ -9,6 +9,7 @@ new FormModel {
name: "tabbedPane"
"leadingComponent": new FormReference( "previewLabel" )
"tabAreaAlignment": enum com.formdev.flatlaf.extras.components.FlatTabbedPane$TabAreaAlignment trailing
"tabLayoutPolicy": 1
}, new FormLayoutConstraints( class java.lang.String ) {
"value": "Center"
} )
@@ -24,8 +25,8 @@ new FormModel {
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "previewLabel"
"text": " Preview "
"font": new com.jformdesigner.model.SwingDerivedFont( null, 0, 6, false )
"text": " Preview "
"$client.FlatLaf.styleClass": "h2"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 235 )
"size": new java.awt.Dimension( 176, 24 )

View File

@@ -560,7 +560,7 @@ class FlatThemePreviewAll
menuUnderlineSelectionButton.setButtonType(FlatButton.ButtonType.toolBarButton);
menuUnderlineSelectionButton.setToolTipText("menu underline selection");
menuUnderlineSelectionButton.setFocusable(false);
menuUnderlineSelectionButton.setFont(menuUnderlineSelectionButton.getFont().deriveFont(menuUnderlineSelectionButton.getFont().getSize() - 2f));
menuUnderlineSelectionButton.putClientProperty("FlatLaf.styleClass", "small");
menuUnderlineSelectionButton.addActionListener(e -> menuUnderlineSelectionChanged());
add(menuUnderlineSelectionButton, "cell 0 11");

View File

@@ -307,7 +307,7 @@ new FormModel {
"buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType toolBarButton
"toolTipText": "menu underline selection"
"focusable": false
"font": new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
"$client.FlatLaf.styleClass": "small"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}

View File

@@ -232,25 +232,25 @@ class FlatThemePreviewButtons
//---- noneButton ----
noneButton.setText("none");
noneButton.setSelected(true);
noneButton.setFont(noneButton.getFont().deriveFont(noneButton.getFont().getSize() - 2f));
noneButton.putClientProperty("FlatLaf.styleClass", "small");
noneButton.addActionListener(e -> buttonTypeChanged());
buttonTypeToolBar1.add(noneButton);
//---- squareButton ----
squareButton.setText("square");
squareButton.setFont(squareButton.getFont().deriveFont(squareButton.getFont().getSize() - 2f));
squareButton.putClientProperty("FlatLaf.styleClass", "small");
squareButton.addActionListener(e -> buttonTypeChanged());
buttonTypeToolBar1.add(squareButton);
//---- roundRectButton ----
roundRectButton.setText("roundRect");
roundRectButton.setFont(roundRectButton.getFont().deriveFont(roundRectButton.getFont().getSize() - 2f));
roundRectButton.putClientProperty("FlatLaf.styleClass", "small");
roundRectButton.addActionListener(e -> buttonTypeChanged());
buttonTypeToolBar1.add(roundRectButton);
//---- tabButton ----
tabButton.setText("tab");
tabButton.setFont(tabButton.getFont().deriveFont(tabButton.getFont().getSize() - 2f));
tabButton.putClientProperty("FlatLaf.styleClass", "small");
tabButton.addActionListener(e -> buttonTypeChanged());
buttonTypeToolBar1.add(tabButton);
}
@@ -263,13 +263,13 @@ class FlatThemePreviewButtons
//---- toolBarButtonButton ----
toolBarButtonButton.setText("toolBarButton");
toolBarButtonButton.setFont(toolBarButtonButton.getFont().deriveFont(toolBarButtonButton.getFont().getSize() - 2f));
toolBarButtonButton.putClientProperty("FlatLaf.styleClass", "small");
toolBarButtonButton.addActionListener(e -> buttonTypeChanged());
buttonTypeToolBar2.add(toolBarButtonButton);
//---- borderlessButton ----
borderlessButton.setText("borderless");
borderlessButton.setFont(borderlessButton.getFont().deriveFont(borderlessButton.getFont().getSize() - 2f));
borderlessButton.putClientProperty("FlatLaf.styleClass", "small");
borderlessButton.addActionListener(e -> buttonTypeChanged());
buttonTypeToolBar2.add(borderlessButton);
}
@@ -279,7 +279,7 @@ class FlatThemePreviewButtons
//---- label11 ----
label11.setText("JButton");
label11.setFont(label11.getFont().deriveFont(label11.getFont().getSize() + 4f));
label11.putClientProperty("FlatLaf.styleClass", "h3");
add(label11, "cell 0 1 3 1");
//---- label27 ----
@@ -292,22 +292,22 @@ class FlatThemePreviewButtons
//---- label5 ----
label5.setText("regular");
label5.setFont(label5.getFont().deriveFont(label5.getFont().getSize() - 2f));
label5.putClientProperty("FlatLaf.styleClass", "small");
add(label5, "cell 1 3,alignx center,growx 0");
//---- label7 ----
label7.setText("default");
label7.setFont(label7.getFont().deriveFont(label7.getFont().getSize() - 2f));
label7.putClientProperty("FlatLaf.styleClass", "small");
add(label7, "cell 2 3,alignx center,growx 0");
//---- label6 ----
label6.setText("regular");
label6.setFont(label6.getFont().deriveFont(label6.getFont().getSize() - 2f));
label6.putClientProperty("FlatLaf.styleClass", "small");
add(label6, "cell 3 3,alignx center,growx 0");
//---- label8 ----
label8.setText("default");
label8.setFont(label8.getFont().deriveFont(label8.getFont().getSize() - 2f));
label8.putClientProperty("FlatLaf.styleClass", "small");
add(label8, "cell 4 3,alignx center,growx 0");
//---- label1 ----
@@ -435,7 +435,7 @@ class FlatThemePreviewButtons
//---- label12 ----
label12.setText("JToggleButton");
label12.setFont(label12.getFont().deriveFont(label12.getFont().getSize() + 4f));
label12.putClientProperty("FlatLaf.styleClass", "h3");
add(label12, "cell 0 9 3 1");
//---- label29 ----
@@ -448,22 +448,22 @@ class FlatThemePreviewButtons
//---- label13 ----
label13.setText("unsel.");
label13.setFont(label13.getFont().deriveFont(label13.getFont().getSize() - 2f));
label13.putClientProperty("FlatLaf.styleClass", "small");
add(label13, "cell 1 11,alignx center,growx 0");
//---- label14 ----
label14.setText("selected");
label14.setFont(label14.getFont().deriveFont(label14.getFont().getSize() - 2f));
label14.putClientProperty("FlatLaf.styleClass", "small");
add(label14, "cell 2 11,alignx center,growx 0");
//---- label15 ----
label15.setText("unsel.");
label15.setFont(label15.getFont().deriveFont(label15.getFont().getSize() - 2f));
label15.putClientProperty("FlatLaf.styleClass", "small");
add(label15, "cell 3 11,alignx center,growx 0");
//---- label16 ----
label16.setText("selected");
label16.setFont(label16.getFont().deriveFont(label16.getFont().getSize() - 2f));
label16.putClientProperty("FlatLaf.styleClass", "small");
add(label16, "cell 4 11,alignx center,growx 0");
//---- label17 ----
@@ -576,7 +576,7 @@ class FlatThemePreviewButtons
//---- label32 ----
label32.setText("Help Button");
label32.setFont(label32.getFont().deriveFont(label32.getFont().getSize() + 4f));
label32.putClientProperty("FlatLaf.styleClass", "h3");
add(label32, "cell 0 17 2 1");
//---- label9 ----

View File

@@ -33,7 +33,7 @@ new FormModel {
"text": "none"
"$buttonGroup": new FormReference( "buttonGroup1" )
"selected": true
"font": &SwingDerivedFont0 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
"$client.FlatLaf.styleClass": "small"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -43,7 +43,7 @@ new FormModel {
name: "squareButton"
"text": "square"
"$buttonGroup": new FormReference( "buttonGroup1" )
"font": #SwingDerivedFont0
"$client.FlatLaf.styleClass": "small"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -53,7 +53,7 @@ new FormModel {
name: "roundRectButton"
"text": "roundRect"
"$buttonGroup": new FormReference( "buttonGroup1" )
"font": #SwingDerivedFont0
"$client.FlatLaf.styleClass": "small"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -63,7 +63,7 @@ new FormModel {
name: "tabButton"
"text": "tab"
"$buttonGroup": new FormReference( "buttonGroup1" )
"font": #SwingDerivedFont0
"$client.FlatLaf.styleClass": "small"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -80,7 +80,7 @@ new FormModel {
name: "toolBarButtonButton"
"text": "toolBarButton"
"$buttonGroup": new FormReference( "buttonGroup1" )
"font": #SwingDerivedFont0
"$client.FlatLaf.styleClass": "small"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -90,7 +90,7 @@ new FormModel {
name: "borderlessButton"
"text": "borderless"
"$buttonGroup": new FormReference( "buttonGroup1" )
"font": #SwingDerivedFont0
"$client.FlatLaf.styleClass": "small"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -105,7 +105,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label11"
"text": "JButton"
"font": &SwingDerivedFont1 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false )
"$client.FlatLaf.styleClass": "h3"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1 3 1"
} )
@@ -124,28 +124,28 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"text": "regular"
"font": &SwingDerivedFont2 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label7"
"text": "default"
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6"
"text": "regular"
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 3,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label8"
"text": "default"
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 3,alignx center,growx 0"
} )
@@ -317,7 +317,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label12"
"text": "JToggleButton"
"font": #SwingDerivedFont1
"$client.FlatLaf.styleClass": "h3"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9 3 1"
} )
@@ -336,28 +336,28 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label13"
"text": "unsel."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 11,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label14"
"text": "selected"
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 11,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label15"
"text": "unsel."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 11,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label16"
"text": "selected"
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 11,alignx center,growx 0"
} )
@@ -514,7 +514,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label32"
"text": "Help Button"
"font": #SwingDerivedFont1
"$client.FlatLaf.styleClass": "h3"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 17 2 1"
} )

View File

@@ -0,0 +1,289 @@
/*
/*
* Copyright 2021 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.themeeditor;
import java.awt.*;
import java.text.DecimalFormat;
import javax.swing.*;
import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.util.UIScale;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatThemePreviewFonts
extends JPanel
{
private static final DecimalFormat SCALE_FORMAT = new DecimalFormat( "0.##x" );
public FlatThemePreviewFonts() {
initComponents();
scaleValueLabel.setText( SCALE_FORMAT.format( UIScale.getUserScaleFactor() ) );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel headingsLabel = new JLabel();
FlatThemePreviewFonts.FontPreview h00Preview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview h0Preview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview h1Preview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview h2Preview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview h3Preview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview h4Preview = new FlatThemePreviewFonts.FontPreview();
JLabel textLabel = new JLabel();
FlatThemePreviewFonts.FontPreview largePreview = new FlatThemePreviewFonts.FontPreview();
defaultPreview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview mediumPreview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview smallPreview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview miniPreview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview lightPreview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview semiboldPreview = new FlatThemePreviewFonts.FontPreview();
FlatThemePreviewFonts.FontPreview monospacedPreview = new FlatThemePreviewFonts.FontPreview();
JLabel scaleLabel = new JLabel();
scaleValueLabel = new JLabel();
//======== this ========
setLayout(new MigLayout(
"ltr,insets dialog,hidemode 3",
// columns
"[left]unrel",
// rows
"[]" +
"[bottom]" +
"[bottom]" +
"[bottom]" +
"[bottom]" +
"[bottom]" +
"[bottom]para" +
"[]" +
"[bottom]" +
"[bottom]" +
"[bottom]" +
"[bottom]" +
"[bottom]para" +
"[]" +
"[]para" +
"[]para" +
"[]"));
//---- headingsLabel ----
headingsLabel.setText("Headings");
headingsLabel.putClientProperty("FlatLaf.styleClass", "h3");
add(headingsLabel, "cell 0 0");
//---- h00Preview ----
h00Preview.setFontType("H00");
h00Preview.setFontStyle("h00");
add(h00Preview, "cell 0 1,gapx 12");
//---- h0Preview ----
h0Preview.setFontType("H0");
h0Preview.setFontStyle("h0");
add(h0Preview, "cell 0 2,gapx 12");
//---- h1Preview ----
h1Preview.setFontType("H1");
h1Preview.setFontStyle("h1");
h1Preview.setFontStyleRegular("h1.regular");
add(h1Preview, "cell 0 3,gapx 12");
//---- h2Preview ----
h2Preview.setFontType("H2");
h2Preview.setFontStyle("h2");
h2Preview.setFontStyleRegular("h2.regular");
add(h2Preview, "cell 0 4,gapx 12");
//---- h3Preview ----
h3Preview.setFontType("H3");
h3Preview.setFontStyle("h3");
h3Preview.setFontStyleRegular("h3.regular");
add(h3Preview, "cell 0 5,gapx 12");
//---- h4Preview ----
h4Preview.setFontType("H4");
h4Preview.setFontStyle("h4");
add(h4Preview, "cell 0 6,gapx 12");
//---- textLabel ----
textLabel.setText("Text");
textLabel.putClientProperty("FlatLaf.styleClass", "h3");
add(textLabel, "cell 0 7");
//---- largePreview ----
largePreview.setFontType("Large");
largePreview.setFontStyle("large");
add(largePreview, "cell 0 8,gapx 12");
//---- defaultPreview ----
defaultPreview.setFontType("Default");
add(defaultPreview, "cell 0 9,gapx 12");
//---- mediumPreview ----
mediumPreview.setFontType("Medium");
mediumPreview.setFontStyle("medium");
add(mediumPreview, "cell 0 10,gapx 12");
//---- smallPreview ----
smallPreview.setFontType("Small");
smallPreview.setFontStyle("small");
add(smallPreview, "cell 0 11,gapx 12");
//---- miniPreview ----
miniPreview.setFontType("Mini");
miniPreview.setFontStyle("mini");
add(miniPreview, "cell 0 12,gapx 12");
//---- lightPreview ----
lightPreview.setFontType("Light");
lightPreview.setFontStyle("light");
add(lightPreview, "cell 0 13,gapx 12");
//---- semiboldPreview ----
semiboldPreview.setFontType("Semibold");
semiboldPreview.setFontStyle("semibold");
add(semiboldPreview, "cell 0 14,gapx 12");
//---- monospacedPreview ----
monospacedPreview.setFontType("Monospaced");
monospacedPreview.setFontStyle("monospaced");
add(monospacedPreview, "cell 0 15,gapx 12");
//---- scaleLabel ----
scaleLabel.setText("Fonts in preview are scaled by:");
add(scaleLabel, "cell 0 16,gapx 12");
//---- scaleValueLabel ----
scaleValueLabel.setText("1x");
scaleValueLabel.putClientProperty("FlatLaf.styleClass", "h2");
add(scaleValueLabel, "cell 0 16");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private FlatThemePreviewFonts.FontPreview defaultPreview;
private JLabel scaleValueLabel;
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- class FontPreview --------------------------------------------------
static class FontPreview
extends JPanel
{
private String fontType;
private String fontStyle;
private String fontStyleRegular;
private FontPreview() {
initComponents();
updateDescription( previewLabel.getFont() );
previewLabel.addPropertyChangeListener( "font", e -> {
updateDescription( previewLabel.getFont() );
} );
preview2Label.setVisible( false );
}
public String getFontType() {
return fontType;
}
public void setFontType( String fontType ) {
this.fontType = fontType;
previewLabel.setText( fontType );
preview2Label.setText( " / " + fontType );
}
public String getFontStyle() {
return fontStyle;
}
public void setFontStyle( String fontStyle ) {
this.fontStyle = fontStyle;
previewLabel.putClientProperty( FlatClientProperties.STYLE_CLASS, fontStyle );
}
public String getFontStyleRegular() {
return fontStyleRegular;
}
public void setFontStyleRegular( String fontStyleRegular ) {
this.fontStyleRegular = fontStyleRegular;
preview2Label.putClientProperty( FlatClientProperties.STYLE_CLASS, fontStyleRegular );
preview2Label.setVisible( fontStyleRegular != null );
}
private void updateDescription( Font font ) {
int baseSize = getDefaultFont().getSize();
int fontSize = font.getSize();
descLabel.setText( String.format( "%s %d %s%s (%+d %s)",
font.getFamily(),
fontSize,
(font.getStyle() & Font.BOLD) != 0 ? " bold" : "",
(font.getStyle() & Font.ITALIC) != 0 ? " italic" : "",
fontSize - baseSize,
SCALE_FORMAT.format( (float) fontSize / baseSize ) ) );
}
private Font getDefaultFont() {
Font font = UIManager.getFont( "defaultFont" );
if( font == null )
font = UIManager.getFont( "Label.font" );
return font;
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
previewLabel = new JLabel();
preview2Label = new JLabel();
descLabel = new JLabel();
//======== this ========
setLayout(new MigLayout(
"insets 0,hidemode 3",
// columns
"[90,left]" +
"[fill]",
// rows
"[]0"));
//---- previewLabel ----
previewLabel.setText("preview");
add(previewLabel, "cell 0 0");
//---- preview2Label ----
preview2Label.setText("preview");
add(preview2Label, "cell 0 0,gapx 0");
//---- descLabel ----
descLabel.setText("description");
descLabel.putClientProperty("FlatLaf.styleClass", "medium");
add(descLabel, "cell 1 0");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JLabel previewLabel;
private JLabel preview2Label;
private JLabel descLabel;
// JFormDesigner - End of variables declaration //GEN-END:variables
}
}

View File

@@ -0,0 +1,195 @@
JFDML JFormDesigner: "7.0.5.0.382" Java: "16" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
auxiliary() {
"JavaCodeGenerator.defaultVariableLocal": true
}
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[left]unrel"
"$rowConstraints": "[][bottom][bottom][bottom][bottom][bottom][bottom]para[][bottom][bottom][bottom][bottom][bottom]para[][]para[]para[]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "headingsLabel"
"text": "Headings"
"$client.FlatLaf.styleClass": "h3"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "h00Preview"
"fontType": "H00"
"fontStyle": "h00"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "h0Preview"
"fontType": "H0"
"fontStyle": "h0"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "h1Preview"
"fontType": "H1"
"fontStyle": "h1"
"fontStyleRegular": "h1.regular"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "h2Preview"
"fontType": "H2"
"fontStyle": "h2"
"fontStyleRegular": "h2.regular"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "h3Preview"
"fontType": "H3"
"fontStyle": "h3"
"fontStyleRegular": "h3.regular"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "h4Preview"
"fontType": "H4"
"fontStyle": "h4"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6,gapx 12"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "textLabel"
"text": "Text"
"$client.FlatLaf.styleClass": "h3"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "largePreview"
"fontType": "Large"
"fontStyle": "large"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "defaultPreview"
"fontType": "Default"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "mediumPreview"
"fontType": "Medium"
"fontStyle": "medium"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 10,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "smallPreview"
"fontType": "Small"
"fontStyle": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "miniPreview"
"fontType": "Mini"
"fontStyle": "mini"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 12,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "lightPreview"
"fontType": "Light"
"fontStyle": "light"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 13,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "semiboldPreview"
"fontType": "Semibold"
"fontStyle": "semibold"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 14,gapx 12"
} )
add( new FormComponent( "com.formdev.flatlaf.themeeditor.FlatThemePreviewFonts$FontPreview" ) {
name: "monospacedPreview"
"fontType": "Monospaced"
"fontStyle": "monospaced"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 15,gapx 12"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "scaleLabel"
"text": "Fonts in preview are scaled by:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 16,gapx 12"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "scaleValueLabel"
"text": "1x"
"$client.FlatLaf.styleClass": "h2"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 16"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 5, 0 )
"size": new java.awt.Dimension( 335, 495 )
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[90,left][fill]"
"$rowConstraints": "[]0"
} ) {
name: "panel1"
auxiliary() {
"JavaCodeGenerator.className": "FontPreview"
"JavaCodeGenerator.variableName": "fontPreview"
}
add( new FormComponent( "javax.swing.JLabel" ) {
name: "previewLabel"
"text": "preview"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "preview2Label"
"text": "preview"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0,gapx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "descLabel"
"text": "description"
"$client.FlatLaf.styleClass": "medium"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 5, 545 )
"size": new java.awt.Dimension( 235, 65 )
} )
}
}

View File

@@ -262,25 +262,25 @@ class FlatThemePreviewSwitches
//---- zoom1xButton ----
zoom1xButton.setText("1x");
zoom1xButton.setSelected(true);
zoom1xButton.setFont(zoom1xButton.getFont().deriveFont(zoom1xButton.getFont().getSize() - 2f));
zoom1xButton.putClientProperty("FlatLaf.styleClass", "small");
zoom1xButton.addActionListener(e -> zoomChanged());
zoomToolBar.add(zoom1xButton);
//---- zoom2xButton ----
zoom2xButton.setText("2x");
zoom2xButton.setFont(zoom2xButton.getFont().deriveFont(zoom2xButton.getFont().getSize() - 2f));
zoom2xButton.putClientProperty("FlatLaf.styleClass", "small");
zoom2xButton.addActionListener(e -> zoomChanged());
zoomToolBar.add(zoom2xButton);
//---- zoom3xButton ----
zoom3xButton.setText("3x");
zoom3xButton.setFont(zoom3xButton.getFont().deriveFont(zoom3xButton.getFont().getSize() - 2f));
zoom3xButton.putClientProperty("FlatLaf.styleClass", "small");
zoom3xButton.addActionListener(e -> zoomChanged());
zoomToolBar.add(zoom3xButton);
//---- zoom4xButton ----
zoom4xButton.setText("4x");
zoom4xButton.setFont(zoom4xButton.getFont().deriveFont(zoom4xButton.getFont().getSize() - 2f));
zoom4xButton.putClientProperty("FlatLaf.styleClass", "small");
zoom4xButton.addActionListener(e -> zoomChanged());
zoomToolBar.add(zoom4xButton);
zoomToolBar.addSeparator();
@@ -288,6 +288,7 @@ class FlatThemePreviewSwitches
//---- indeterminateButton ----
indeterminateButton.setText("indeterminate");
indeterminateButton.setSelected(true);
indeterminateButton.putClientProperty("FlatLaf.styleClass", "small");
indeterminateButton.addActionListener(e -> indeterminateChanged());
zoomToolBar.add(indeterminateButton);
}
@@ -297,7 +298,7 @@ class FlatThemePreviewSwitches
//---- label22 ----
label22.setText("JCheckBox");
label22.setFont(label22.getFont().deriveFont(label22.getFont().getSize() + 4f));
label22.putClientProperty("FlatLaf.styleClass", "h3");
add(label22, "cell 0 1 3 1");
//---- label1 ----
@@ -310,32 +311,32 @@ class FlatThemePreviewSwitches
//---- label23 ----
label23.setText("unsel.");
label23.setFont(label23.getFont().deriveFont(label23.getFont().getSize() - 2f));
label23.putClientProperty("FlatLaf.styleClass", "small");
add(label23, "cell 1 3,alignx center,growx 0");
//---- label28 ----
label28.setText("sel.");
label28.setFont(label28.getFont().deriveFont(label28.getFont().getSize() - 2f));
label28.putClientProperty("FlatLaf.styleClass", "small");
add(label28, "cell 2 3,alignx center,growx 0");
//---- label37 ----
label37.setText("ind.");
label37.setFont(label37.getFont().deriveFont(label37.getFont().getSize() - 2f));
label37.putClientProperty("FlatLaf.styleClass", "small");
add(label37, "cell 3 3,alignx center,growx 0");
//---- label24 ----
label24.setText("unsel.");
label24.setFont(label24.getFont().deriveFont(label24.getFont().getSize() - 2f));
label24.putClientProperty("FlatLaf.styleClass", "small");
add(label24, "cell 4 3,alignx center,growx 0");
//---- label29 ----
label29.setText("sel.");
label29.setFont(label29.getFont().deriveFont(label29.getFont().getSize() - 2f));
label29.putClientProperty("FlatLaf.styleClass", "small");
add(label29, "cell 5 3,alignx center,growx 0");
//---- label38 ----
label38.setText("ind.");
label38.setFont(label38.getFont().deriveFont(label38.getFont().getSize() - 2f));
label38.putClientProperty("FlatLaf.styleClass", "small");
add(label38, "cell 6 3,alignx center,growx 0");
//---- label17 ----
@@ -465,7 +466,7 @@ class FlatThemePreviewSwitches
//---- label27 ----
label27.setText("JRadioButton");
label27.setFont(label27.getFont().deriveFont(label27.getFont().getSize() + 4f));
label27.putClientProperty("FlatLaf.styleClass", "h3");
add(label27, "cell 0 9 3 1");
//---- label3 ----
@@ -478,22 +479,22 @@ class FlatThemePreviewSwitches
//---- label25 ----
label25.setText("unsel.");
label25.setFont(label25.getFont().deriveFont(label25.getFont().getSize() - 2f));
label25.putClientProperty("FlatLaf.styleClass", "small");
add(label25, "cell 1 11,alignx center,growx 0");
//---- label30 ----
label30.setText("sel.");
label30.setFont(label30.getFont().deriveFont(label30.getFont().getSize() - 2f));
label30.putClientProperty("FlatLaf.styleClass", "small");
add(label30, "cell 2 11,alignx center,growx 0");
//---- label26 ----
label26.setText("unsel.");
label26.setFont(label26.getFont().deriveFont(label26.getFont().getSize() - 2f));
label26.putClientProperty("FlatLaf.styleClass", "small");
add(label26, "cell 4 11,alignx center,growx 0");
//---- label31 ----
label31.setText("sel.");
label31.setFont(label31.getFont().deriveFont(label31.getFont().getSize() - 2f));
label31.putClientProperty("FlatLaf.styleClass", "small");
add(label31, "cell 5 11,alignx center,growx 0");
//---- label36 ----

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.4.0.360" Java: "17" encoding: "UTF-8"
JFDML JFormDesigner: "7.0.5.0.382" Java: "16" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -32,7 +32,7 @@ new FormModel {
name: "zoom1xButton"
"text": "1x"
"selected": true
"font": &SwingDerivedFont0 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
"$client.FlatLaf.styleClass": "small"
"$buttonGroup": new FormReference( "buttonGroup1" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
@@ -42,7 +42,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "zoom2xButton"
"text": "2x"
"font": #SwingDerivedFont0
"$client.FlatLaf.styleClass": "small"
"$buttonGroup": &FormReference0 new FormReference( "buttonGroup1" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
@@ -52,7 +52,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "zoom3xButton"
"text": "3x"
"font": #SwingDerivedFont0
"$client.FlatLaf.styleClass": "small"
"$buttonGroup": #FormReference0
auxiliary() {
"JavaCodeGenerator.variableLocal": false
@@ -62,7 +62,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "zoom4xButton"
"text": "4x"
"font": #SwingDerivedFont0
"$client.FlatLaf.styleClass": "small"
"$buttonGroup": #FormReference0
auxiliary() {
"JavaCodeGenerator.variableLocal": false
@@ -76,6 +76,7 @@ new FormModel {
name: "indeterminateButton"
"text": "indeterminate"
"selected": true
"$client.FlatLaf.styleClass": "small"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -90,7 +91,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label22"
"text": "JCheckBox"
"font": &SwingDerivedFont1 new com.jformdesigner.model.SwingDerivedFont( null, 0, 4, false )
"$client.FlatLaf.styleClass": "h3"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1 3 1"
} )
@@ -109,42 +110,42 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label23"
"text": "unsel."
"font": &SwingDerivedFont2 new com.jformdesigner.model.SwingDerivedFont( null, 0, -2, false )
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label28"
"text": "sel."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label37"
"text": "ind."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 3,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label24"
"text": "unsel."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 3,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label29"
"text": "sel."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 3,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label38"
"text": "ind."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 3,alignx center,growx 0"
} )
@@ -340,7 +341,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label27"
"text": "JRadioButton"
"font": #SwingDerivedFont1
"$client.FlatLaf.styleClass": "h3"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9 3 1"
} )
@@ -359,28 +360,28 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label25"
"text": "unsel."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 11,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label30"
"text": "sel."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 11,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label26"
"text": "unsel."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 11,alignx center,growx 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label31"
"text": "sel."
"font": #SwingDerivedFont2
"$client.FlatLaf.styleClass": "small"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 11,alignx center,growx 0"
} )

View File

@@ -1093,6 +1093,22 @@ Viewport.background
Viewport.font
Viewport.foreground
ViewportUI
[style].h0
[style].h00
[style].h1
[style].h1.regular
[style].h2
[style].h2.regular
[style].h3
[style].h3.regular
[style].h4
[style].large
[style].light
[style].medium
[style].mini
[style].monospaced
[style].semibold
[style].small
activeCaption
activeCaptionBorder
activeCaptionText
@@ -1104,6 +1120,15 @@ controlShadow
controlText
defaultFont
desktop
h0.font
h00.font
h1.font
h1.regular.font
h2.font
h2.regular.font
h3.font
h3.regular.font
h4.font
html.missingImage
html.pendingImage
inactiveCaption
@@ -1113,9 +1138,16 @@ info
infoText
laf.dark
laf.scaleFactor
large.font
light.font
medium.font
menu
menuText
mini.font
monospaced.font
scrollbar
semibold.font
small.font
swingx/TaskPaneUI
text
textHighlight