mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be88eeb343 | ||
|
|
342b932f9e | ||
|
|
964dc14a8a | ||
|
|
b56f462626 | ||
|
|
4477b4c44e | ||
|
|
714c6e2920 | ||
|
|
0853a1aa2e | ||
|
|
f9d2312b3a | ||
|
|
f53f205f52 | ||
|
|
41ecbccc76 | ||
|
|
5a952c187c | ||
|
|
0a86d00c1e | ||
|
|
b3e9d82537 | ||
|
|
0970dceee2 | ||
|
|
ffef71d6db | ||
|
|
0ede8cd5b9 | ||
|
|
c1a9f48e6b | ||
|
|
3f7215c602 | ||
|
|
8b5e3e344a | ||
|
|
212ff012d6 | ||
|
|
7c77b857f6 | ||
|
|
423c01074a | ||
|
|
2dbd584e28 | ||
|
|
250f435ceb | ||
|
|
fa4e409555 | ||
|
|
dfc3b7c796 | ||
|
|
41df9859ad | ||
|
|
a8b8cbdf8c | ||
|
|
fe2909c56a | ||
|
|
3a2fe06c34 | ||
|
|
873e8604ce |
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,6 +1,31 @@
|
||||
FlatLaf Change Log
|
||||
==================
|
||||
|
||||
## 0.15
|
||||
|
||||
- ToolTip: Improved styling of dark tooltips (darker background, no border).
|
||||
- ToolTip: Fixed colors in tooltips of disabled components. (issue #15)
|
||||
- ComboBox: Fixed NPE in combobox with custom renderer after switching to
|
||||
FlatLaf. (issue #16; regression in 0.14)
|
||||
|
||||
|
||||
## 0.14
|
||||
|
||||
- ComboBox: Use small border if used as table editor.
|
||||
- ToolBar: Disable focusability of buttons in toolbar.
|
||||
- OptionPane: Fixed rendering of longer HTML text. (issue #12)
|
||||
- EditorPane and TextPane: Fixed font and text color when using HTML content.
|
||||
(issue #9)
|
||||
- ComboBox: Fixed `StackOverflowError` when switching LaF. (issue #14)
|
||||
- SwingX: Support `JXBusyLabel`, `JXDatePicker`, `JXHeader`, `JXHyperlink`,
|
||||
`JXMonthView`, `JXTaskPaneContainer` and `JXTaskPane`. (issue #8)
|
||||
|
||||
|
||||
## 0.13
|
||||
|
||||
- Added developer information to Maven POM for Maven Central publishing.
|
||||
|
||||
|
||||
## 0.12
|
||||
|
||||
- Support Linux. (issue #2)
|
||||
|
||||
25
README.md
25
README.md
@@ -1,15 +1,15 @@
|
||||
FlatLaf - Flat Look and Feel
|
||||
============================
|
||||
|
||||
**FlatLaf** is a modern open-source cross-platform Look and Feel for Java
|
||||
desktop applications.
|
||||
**FlatLaf** is a modern **open-source** cross-platform Look and Feel for Java
|
||||
Swing desktop applications.
|
||||
|
||||
It looks mostly "flat" (no shadows or gradients), clean, simple and elegant.
|
||||
It looks almost flat (no shadows or gradients), clean, simple and elegant.
|
||||
FlatLaf comes with **Light**, **Dark**, **IntelliJ** and **Darcula** themes,
|
||||
scales on **HiDPI** displays and runs on Java 8 or newer.
|
||||
|
||||
The look is heavily inspired by **Darcula** and **IntelliJ** themes from
|
||||
IntelliJ IDEA 2019.2+ and uses mostly the same colors and icons.
|
||||
IntelliJ IDEA 2019.2+ and uses almost the same colors and icons.
|
||||
|
||||

|
||||
|
||||
@@ -28,9 +28,24 @@ Requires Java 8 or newer.
|
||||
Download
|
||||
--------
|
||||
|
||||
FlatLaf binaries are available on **JCenter** and **Maven Central**.
|
||||
|
||||
If you use Maven or Gradle, add a dependency with following coordinates to your
|
||||
build script:
|
||||
|
||||
groupId: com.formdev
|
||||
artifactId: flatlaf
|
||||
version: 0.15
|
||||
|
||||
Otherwise download `flatlaf-<version>.jar` here:
|
||||
|
||||
[](https://bintray.com/jformdesigner/flatlaf/flatlaf/_latestVersion)
|
||||
|
||||
Download from JCenter and Maven Central is coming soon.
|
||||
|
||||
Addons
|
||||
------
|
||||
|
||||
- [SwingX](flatlaf-swingx)
|
||||
|
||||
|
||||
Documentation
|
||||
|
||||
@@ -14,7 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
version = "0.12"
|
||||
version = "0.15"
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
// check required Java version
|
||||
if( JavaVersion.current() < JavaVersion.VERSION_1_8 )
|
||||
|
||||
@@ -22,10 +22,6 @@ plugins {
|
||||
id( "com.jfrog.bintray" ) version "1.8.4"
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
if( JavaVersion.current() >= JavaVersion.VERSION_1_9 ) {
|
||||
sourceSets {
|
||||
create( "module-info" ) {
|
||||
@@ -92,6 +88,19 @@ tasks {
|
||||
|
||||
from( javadoc )
|
||||
}
|
||||
|
||||
register( "testJar", Jar::class ) {
|
||||
archiveBaseName.set( "flatlaf-test" )
|
||||
from( sourceSets.test.get().output )
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
create( "testArtifacts" )
|
||||
}
|
||||
|
||||
artifacts {
|
||||
add( "testArtifacts", tasks.getByPath( "testJar" ) )
|
||||
}
|
||||
|
||||
publishing {
|
||||
@@ -117,6 +126,14 @@ publishing {
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
name.set( "Karl Tauber" )
|
||||
organization.set( "FormDev Software GmbH" )
|
||||
organizationUrl.set( "https://www.formdev.com/" )
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
url.set( "https://github.com/JFormDesigner/FlatLaf" )
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Addon for FlatLaf UI defaults.
|
||||
*
|
||||
* Allows loading of additional .properties files from addon JARs.
|
||||
* {@link java.util.ServiceLoader} is used to load extensions of this class from addon JARs.
|
||||
*
|
||||
* If you extend this class in a addon JAR, you also have to add a text file named
|
||||
* {@code META-INF/services/com.formdev.flatlaf.FlatDefaultsAddon}
|
||||
* to the addon JAR. The file must contain a single line with the class name.
|
||||
*
|
||||
* See 'flatlaf-swingx' addon for an example
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public abstract class FlatDefaultsAddon
|
||||
{
|
||||
/**
|
||||
* Finds an addon .properties file for the given LaF class and returns
|
||||
* it as input stream. Or {@code null} if not found.
|
||||
*/
|
||||
public abstract InputStream getDefaults( Class<?> lafClass );
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.formdev.flatlaf;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
@@ -24,10 +23,10 @@ import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Font;
|
||||
import java.awt.Insets;
|
||||
import java.awt.KeyEventPostProcessor;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.AWTEventListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
@@ -36,8 +35,10 @@ import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.function.Function;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JLabel;
|
||||
@@ -68,6 +69,8 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
public abstract class FlatLaf
|
||||
extends BasicLookAndFeel
|
||||
{
|
||||
private static final String TYPE_PREFIX = "{";
|
||||
private static final String TYPE_PREFIX_END = "}";
|
||||
private static final String VARIABLE_PREFIX = "@";
|
||||
private static final String REF_PREFIX = VARIABLE_PREFIX + "@";
|
||||
private static final String OPTIONAL_PREFIX = "?";
|
||||
@@ -78,7 +81,7 @@ public abstract class FlatLaf
|
||||
private String desktopPropertyName;
|
||||
private PropertyChangeListener desktopPropertyListener;
|
||||
|
||||
private AWTEventListener mnemonicListener;
|
||||
private KeyEventPostProcessor mnemonicListener;
|
||||
private static boolean altKeyPressed;
|
||||
|
||||
public static boolean install( LookAndFeel newLookAndFeel ) {
|
||||
@@ -114,10 +117,11 @@ public abstract class FlatLaf
|
||||
|
||||
// add mnemonic listener
|
||||
mnemonicListener = e -> {
|
||||
if( e instanceof KeyEvent && ((KeyEvent)e).getKeyCode() == KeyEvent.VK_ALT )
|
||||
if( e.getKeyCode() == KeyEvent.VK_ALT )
|
||||
altKeyChanged( e.getID() == KeyEvent.KEY_PRESSED );
|
||||
return false;
|
||||
};
|
||||
Toolkit.getDefaultToolkit().addAWTEventListener( mnemonicListener, AWTEvent.KEY_EVENT_MASK );
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor( mnemonicListener );
|
||||
|
||||
// listen to desktop property changes to update UI if system font or scaling changes
|
||||
if( SystemInfo.IS_WINDOWS ) {
|
||||
@@ -149,7 +153,7 @@ public abstract class FlatLaf
|
||||
|
||||
// remove mnemonic listener
|
||||
if( mnemonicListener != null ) {
|
||||
Toolkit.getDefaultToolkit().removeAWTEventListener( mnemonicListener );
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventPostProcessor( mnemonicListener );
|
||||
mnemonicListener = null;
|
||||
}
|
||||
|
||||
@@ -272,12 +276,22 @@ public abstract class FlatLaf
|
||||
try {
|
||||
// load properties files
|
||||
Properties properties = new Properties();
|
||||
ServiceLoader<FlatDefaultsAddon> addonLoader = ServiceLoader.load( FlatDefaultsAddon.class );
|
||||
for( Class<?> lafClass : lafClasses ) {
|
||||
// load core properties
|
||||
String propertiesName = "/" + lafClass.getName().replace( '.', '/' ) + ".properties";
|
||||
try( InputStream in = lafClass.getResourceAsStream( propertiesName ) ) {
|
||||
if( in != null )
|
||||
properties.load( in );
|
||||
}
|
||||
|
||||
// load properties from addons
|
||||
for( FlatDefaultsAddon addon : addonLoader ) {
|
||||
try( InputStream in = addon.getDefaults( lafClass ) ) {
|
||||
if( in != null )
|
||||
properties.load( in );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Function<String, String> resolver = value -> {
|
||||
@@ -345,54 +359,76 @@ public abstract class FlatLaf
|
||||
return resolveValue( properties, newValue );
|
||||
}
|
||||
|
||||
private enum ValueType { UNKNOWN, STRING, INTEGER, BORDER, ICON, INSETS, SIZE, COLOR, SCALEDNUMBER }
|
||||
|
||||
private Object parseValue( String key, String value, Function<String, String> resolver ) {
|
||||
value = value.trim();
|
||||
|
||||
// null, false, true
|
||||
switch( value ) {
|
||||
case "null": return null;
|
||||
case "null": return null;
|
||||
case "false": return false;
|
||||
case "true": return true;
|
||||
case "true": return true;
|
||||
}
|
||||
|
||||
// borders
|
||||
if( key.endsWith( ".border" ) || key.endsWith( "Border" ) )
|
||||
return parseBorder( value, resolver );
|
||||
ValueType valueType = ValueType.UNKNOWN;
|
||||
|
||||
// icons
|
||||
if( key.endsWith( ".icon" ) || key.endsWith( "Icon" ) )
|
||||
return parseInstance( value );
|
||||
// check whether value type is specified in the value
|
||||
if( value.startsWith( TYPE_PREFIX ) ) {
|
||||
int end = value.indexOf( TYPE_PREFIX_END );
|
||||
if( end != -1 ) {
|
||||
try {
|
||||
String typeStr = value.substring( TYPE_PREFIX.length(), end );
|
||||
valueType = ValueType.valueOf( typeStr.toUpperCase( Locale.ENGLISH ) );
|
||||
|
||||
// insets
|
||||
if( key.endsWith( ".margin" ) || key.endsWith( ".padding" ) ||
|
||||
key.endsWith( "Margins" ) || key.endsWith( "Insets" ) )
|
||||
return parseInsets( value );
|
||||
// remove type from value
|
||||
value = value.substring( end + TYPE_PREFIX_END.length() );
|
||||
} catch( IllegalArgumentException ex ) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// scaled number
|
||||
ScaledNumber scaledNumber = parseScaledNumber( key, value );
|
||||
if( scaledNumber != null )
|
||||
return scaledNumber;
|
||||
// determine value type from key
|
||||
if( valueType == ValueType.UNKNOWN ) {
|
||||
if( key.endsWith( ".border" ) || key.endsWith( "Border" ) )
|
||||
valueType = ValueType.BORDER;
|
||||
else if( key.endsWith( ".icon" ) || key.endsWith( "Icon" ) )
|
||||
valueType = ValueType.ICON;
|
||||
else if( key.endsWith( ".margin" ) || key.endsWith( ".padding" ) ||
|
||||
key.endsWith( "Margins" ) || key.endsWith( "Insets" ) )
|
||||
valueType = ValueType.INSETS;
|
||||
else if( key.endsWith( "Size" ) )
|
||||
valueType = ValueType.SIZE;
|
||||
else if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
||||
valueType = ValueType.INTEGER;
|
||||
}
|
||||
|
||||
// size
|
||||
if( key.endsWith( "Size" ) && !key.equals( "SplitPane.dividerSize" ))
|
||||
return parseSize( value );
|
||||
// parse value
|
||||
switch( valueType ) {
|
||||
case STRING: return value;
|
||||
case INTEGER: return parseInteger( value, true );
|
||||
case BORDER: return parseBorder( value, resolver );
|
||||
case ICON: return parseInstance( value );
|
||||
case INSETS: return parseInsets( value );
|
||||
case SIZE: return parseSize( value );
|
||||
case COLOR: return parseColor( value, true );
|
||||
case SCALEDNUMBER: return parseScaledNumber( value );
|
||||
case UNKNOWN:
|
||||
default:
|
||||
// colors
|
||||
ColorUIResource color = parseColor( value, false );
|
||||
if( color != null )
|
||||
return color;
|
||||
|
||||
// width, height
|
||||
if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
||||
return parseInteger( value, true );
|
||||
// integer
|
||||
Integer integer = parseInteger( value, false );
|
||||
if( integer != null )
|
||||
return integer;
|
||||
|
||||
// colors
|
||||
ColorUIResource color = parseColor( value, false );
|
||||
if( color != null )
|
||||
return color;
|
||||
|
||||
// integer
|
||||
Integer integer = parseInteger( value, false );
|
||||
if( integer != null )
|
||||
return integer;
|
||||
|
||||
// string
|
||||
return value;
|
||||
// string
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
private Object parseBorder( String value, Function<String, String> resolver ) {
|
||||
@@ -482,12 +518,7 @@ public abstract class FlatLaf
|
||||
return null;
|
||||
}
|
||||
|
||||
private ScaledNumber parseScaledNumber( String key, String value ) {
|
||||
if( !key.equals( "OptionPane.buttonMinimumWidth" ) &&
|
||||
!key.equals( "SplitPane.oneTouchButtonSize" ) &&
|
||||
!key.equals( "SplitPane.oneTouchButtonOffset" ) )
|
||||
return null; // not supported
|
||||
|
||||
private ScaledNumber parseScaledNumber( String value ) {
|
||||
try {
|
||||
return new ScaledNumber( Integer.parseInt( value ) );
|
||||
} catch( NumberFormatException ex ) {
|
||||
|
||||
@@ -157,7 +157,7 @@ public class FlatArrowButton
|
||||
g.translate( -x, -y );
|
||||
}
|
||||
|
||||
public static Shape createArrowShape( int direction, boolean chevron, int w, int h ) {
|
||||
public static Shape createArrowShape( int direction, boolean chevron, float w, float h ) {
|
||||
switch( direction ) {
|
||||
case NORTH: return FlatUIUtils.createPath( !chevron, 0,h, (w / 2f),0, w,h );
|
||||
case SOUTH: return FlatUIUtils.createPath( !chevron, 0,0, (w / 2f),h, w,0 );
|
||||
|
||||
@@ -72,9 +72,10 @@ public class FlatBorder
|
||||
try {
|
||||
FlatUIUtils.setRenderingHints( g2 );
|
||||
|
||||
float focusWidth = getFocusWidth();
|
||||
boolean isCellEditor = FlatUIUtils.isTableCellEditor( c );
|
||||
float focusWidth = isCellEditor ? 0 : getFocusWidth();
|
||||
float borderWidth = getBorderWidth( c );
|
||||
float arc = getArc();
|
||||
float arc = isCellEditor ? 0 : getArc();
|
||||
|
||||
if( isFocused( c ) ) {
|
||||
g2.setColor( getFocusColor( c ) );
|
||||
@@ -134,7 +135,8 @@ public class FlatBorder
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||
float ow = getFocusWidth() + getLineWidth();
|
||||
boolean isCellEditor = FlatUIUtils.isTableCellEditor( c );
|
||||
float ow = (isCellEditor ? 0 : getFocusWidth()) + getLineWidth();
|
||||
|
||||
insets = super.getBorderInsets( c, insets );
|
||||
insets.top = Math.round( scale( (float) insets.top ) + ow );
|
||||
|
||||
@@ -218,7 +218,7 @@ public class FlatButtonUI
|
||||
paintText( g, b, textRect, text, b.isEnabled() ? getForeground( b ) : disabledText );
|
||||
}
|
||||
|
||||
static void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text, Color foreground ) {
|
||||
public static void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text, Color foreground ) {
|
||||
FontMetrics fm = b.getFontMetrics( b.getFont() );
|
||||
int mnemonicIndex = FlatLaf.isShowMnemonics() ? b.getDisplayedMnemonicIndex() : -1;
|
||||
|
||||
|
||||
@@ -368,7 +368,6 @@ public class FlatComboBoxUI
|
||||
@SuppressWarnings( { "rawtypes", "unchecked" } )
|
||||
private class FlatComboPopup
|
||||
extends BasicComboPopup
|
||||
implements ListCellRenderer
|
||||
{
|
||||
private CellPaddingBorder paddingBorder;
|
||||
|
||||
@@ -405,7 +404,7 @@ public class FlatComboBoxUI
|
||||
protected void configureList() {
|
||||
super.configureList();
|
||||
|
||||
list.setCellRenderer( this );
|
||||
list.setCellRenderer( new PopupListCellRenderer() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -416,27 +415,33 @@ public class FlatComboBoxUI
|
||||
super.propertyChange( e );
|
||||
|
||||
if( e.getPropertyName() == "renderer" )
|
||||
list.setCellRenderer( FlatComboPopup.this );
|
||||
list.setCellRenderer( new PopupListCellRenderer() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent( JList list, Object value,
|
||||
int index, boolean isSelected, boolean cellHasFocus )
|
||||
//---- class PopupListCellRenderer -----
|
||||
|
||||
private class PopupListCellRenderer
|
||||
implements ListCellRenderer
|
||||
{
|
||||
ListCellRenderer renderer = comboBox.getRenderer();
|
||||
CellPaddingBorder.uninstall( renderer );
|
||||
@Override
|
||||
public Component getListCellRendererComponent( JList list, Object value,
|
||||
int index, boolean isSelected, boolean cellHasFocus )
|
||||
{
|
||||
ListCellRenderer renderer = comboBox.getRenderer();
|
||||
CellPaddingBorder.uninstall( renderer );
|
||||
|
||||
Component c = renderer.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
|
||||
Component c = renderer.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
|
||||
|
||||
if( c instanceof JComponent ) {
|
||||
if( paddingBorder == null )
|
||||
paddingBorder = new CellPaddingBorder( padding );
|
||||
paddingBorder.install( (JComponent) c );
|
||||
if( c instanceof JComponent ) {
|
||||
if( paddingBorder == null )
|
||||
paddingBorder = new CellPaddingBorder( padding );
|
||||
paddingBorder.install( (JComponent) c );
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.ui;
|
||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicEditorPaneUI;
|
||||
@@ -37,6 +38,8 @@ public class FlatEditorPaneUI
|
||||
{
|
||||
protected int minimumWidth;
|
||||
|
||||
private Object oldHonorDisplayProperties;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatEditorPaneUI();
|
||||
}
|
||||
@@ -46,6 +49,17 @@ public class FlatEditorPaneUI
|
||||
super.installDefaults();
|
||||
|
||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||
|
||||
// use component font and foreground for HTML text
|
||||
oldHonorDisplayProperties = getComponent().getClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES );
|
||||
getComponent().putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallDefaults() {
|
||||
super.uninstallDefaults();
|
||||
|
||||
getComponent().putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, oldHonorDisplayProperties );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.awt.GridBagConstraints;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicHTML;
|
||||
import javax.swing.plaf.basic.BasicOptionPaneUI;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
@@ -122,6 +123,10 @@ public class FlatOptionPaneUI
|
||||
if( messagePadding > 0 )
|
||||
cons.insets.bottom = UIScale.scale( messagePadding );
|
||||
|
||||
// disable line wrapping for HTML
|
||||
if( msg instanceof String && BasicHTML.isHTMLString( (String) msg ) )
|
||||
maxll = Integer.MAX_VALUE;
|
||||
|
||||
super.addMessageComponents( container, cons, msg, maxll, internallyCreated );
|
||||
}
|
||||
|
||||
|
||||
@@ -116,15 +116,16 @@ public class FlatPasswordFieldUI
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize( JComponent c ) {
|
||||
return applyMinimumWidth( super.getPreferredSize( c ) );
|
||||
return applyMinimumWidth( super.getPreferredSize( c ), c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize( JComponent c ) {
|
||||
return applyMinimumWidth( super.getMinimumSize( c ) );
|
||||
return applyMinimumWidth( super.getMinimumSize( c ), c );
|
||||
}
|
||||
|
||||
private Dimension applyMinimumWidth( Dimension size ) {
|
||||
private Dimension applyMinimumWidth( Dimension size, JComponent c ) {
|
||||
int focusWidth = (c.getBorder() instanceof FlatBorder) ? this.focusWidth : 0;
|
||||
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -128,6 +128,7 @@ public class FlatTextFieldUI
|
||||
(parent != null && parent.getParent() instanceof JSpinner) )
|
||||
return size;
|
||||
|
||||
int focusWidth = (c.getBorder() instanceof FlatBorder) ? this.focusWidth : 0;
|
||||
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.ui;
|
||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicTextPaneUI;
|
||||
@@ -37,6 +38,8 @@ public class FlatTextPaneUI
|
||||
{
|
||||
protected int minimumWidth;
|
||||
|
||||
private Object oldHonorDisplayProperties;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatTextPaneUI();
|
||||
}
|
||||
@@ -46,6 +49,17 @@ public class FlatTextPaneUI
|
||||
super.installDefaults();
|
||||
|
||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||
|
||||
// use component font and foreground for HTML text
|
||||
oldHonorDisplayProperties = getComponent().getClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES );
|
||||
getComponent().putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallDefaults() {
|
||||
super.uninstallDefaults();
|
||||
|
||||
getComponent().putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, oldHonorDisplayProperties );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.formdev.flatlaf.ui;
|
||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ContainerEvent;
|
||||
import java.awt.event.ContainerListener;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.UIManager;
|
||||
@@ -53,6 +55,29 @@ public class FlatToolBarUI
|
||||
rolloverBorder = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ContainerListener createToolBarContListener() {
|
||||
return new ToolBarContListener() {
|
||||
@Override
|
||||
public void componentAdded( ContainerEvent e ) {
|
||||
super.componentAdded( e );
|
||||
|
||||
Component c = e.getChild();
|
||||
if( c instanceof AbstractButton )
|
||||
c.setFocusable( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void componentRemoved( ContainerEvent e ) {
|
||||
super.componentRemoved( e );
|
||||
|
||||
Component c = e.getChild();
|
||||
if( c instanceof AbstractButton )
|
||||
c.setFocusable( true );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Border createRolloverBorder() {
|
||||
return getRolloverBorder();
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
package com.formdev.flatlaf.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
@@ -61,6 +63,12 @@ public class FlatUIUtils
|
||||
r.height - insets.top - insets.bottom );
|
||||
}
|
||||
|
||||
public static Dimension addInsets( Dimension dim, Insets insets ) {
|
||||
return new Dimension(
|
||||
dim.width + insets.left + insets.right,
|
||||
dim.height + insets.top + insets.bottom );
|
||||
}
|
||||
|
||||
public static Color getUIColor( String key, int defaultColorRGB ) {
|
||||
Color color = UIManager.getColor( key );
|
||||
return (color != null) ? color : new Color( defaultColorRGB );
|
||||
@@ -80,6 +88,10 @@ public class FlatUIUtils
|
||||
return (c instanceof ColorUIResource) ? new Color( c.getRGB(), true ) : c;
|
||||
}
|
||||
|
||||
public static boolean isTableCellEditor( Component c ) {
|
||||
return c instanceof JComponent && Boolean.TRUE.equals( ((JComponent)c).getClientProperty( "JComboBox.isTableCellEditor" ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets rendering hints used for painting.
|
||||
*/
|
||||
@@ -160,21 +172,52 @@ public class FlatUIUtils
|
||||
}
|
||||
|
||||
private static Shape createOutlinePath( float x, float y, float width, float height, float arc ) {
|
||||
if( arc <= 0 )
|
||||
return createRoundRectanglePath( x, y, width, height, arc, arc, arc, arc );
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a not-filled rounded rectangle shape and allows specifying the line width and the radius or each corner.
|
||||
*/
|
||||
public static Path2D createRoundRectangle( float x, float y, float width, float height,
|
||||
float lineWidth, float arcTopLeft, float arcTopRight, float arcBottomLeft, float arcBottomRight )
|
||||
{
|
||||
Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD );
|
||||
path.append( createRoundRectanglePath( x, y, width, height, arcTopLeft, arcTopRight, arcBottomLeft, arcBottomRight ), false );
|
||||
path.append( createRoundRectanglePath( x + lineWidth, y + lineWidth, width - (lineWidth * 2), height - (lineWidth * 2),
|
||||
arcTopLeft - lineWidth, arcTopRight - lineWidth, arcBottomLeft - lineWidth, arcBottomRight - lineWidth ), false );
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a filled rounded rectangle shape and allows specifying the radius or each corner.
|
||||
*/
|
||||
public static Shape createRoundRectanglePath( float x, float y, float width, float height,
|
||||
float arcTopLeft, float arcTopRight, float arcBottomLeft, float arcBottomRight )
|
||||
{
|
||||
if( arcTopLeft <= 0 && arcTopRight <= 0 && arcBottomLeft <= 0 && arcBottomRight <= 0 )
|
||||
return new Rectangle2D.Float( x, y, width, height );
|
||||
|
||||
if( arcTopLeft < 0 )
|
||||
arcTopLeft = 0;
|
||||
if( arcTopRight < 0 )
|
||||
arcTopRight = 0;
|
||||
if( arcBottomLeft < 0 )
|
||||
arcBottomLeft = 0;
|
||||
if( arcBottomRight < 0 )
|
||||
arcBottomRight = 0;
|
||||
|
||||
float x2 = x + width;
|
||||
float y2 = y + height;
|
||||
|
||||
Path2D rect = new Path2D.Float();
|
||||
rect.moveTo( x2 - arc, y );
|
||||
rect.quadTo( x2, y, x2, y + arc );
|
||||
rect.lineTo( x2, y2 - arc );
|
||||
rect.quadTo( x2, y2, x2 - arc, y2 );
|
||||
rect.lineTo( x + arc, y2 );
|
||||
rect.quadTo( x, y2, x, y2 - arc );
|
||||
rect.lineTo( x, y + arc );
|
||||
rect.quadTo( x, y, x + arc, y );
|
||||
rect.moveTo( x2 - arcTopRight, y );
|
||||
rect.quadTo( x2, y, x2, y + arcTopRight );
|
||||
rect.lineTo( x2, y2 - arcBottomRight );
|
||||
rect.quadTo( x2, y2, x2 - arcBottomRight, y2 );
|
||||
rect.lineTo( x + arcBottomLeft, y2 );
|
||||
rect.quadTo( x, y2, x, y2 - arcBottomLeft );
|
||||
rect.lineTo( x, y + arcTopLeft );
|
||||
rect.quadTo( x, y, x + arcTopLeft, y );
|
||||
rect.closePath();
|
||||
|
||||
return rect;
|
||||
|
||||
@@ -227,7 +227,8 @@ ToggleButton.toolbar.selectedBackground=5c6164
|
||||
|
||||
#---- ToolTip ----
|
||||
|
||||
ToolTip.background=4b4d4d
|
||||
ToolTip.border=4,6,4,6
|
||||
ToolTip.background=1e2123
|
||||
|
||||
|
||||
#---- Tree ----
|
||||
|
||||
@@ -212,7 +212,7 @@ OptionPane.maxCharactersPerLine=80
|
||||
OptionPane.iconMessageGap=16
|
||||
OptionPane.messagePadding=3
|
||||
OptionPane.buttonPadding=8
|
||||
OptionPane.buttonMinimumWidth=72
|
||||
OptionPane.buttonMinimumWidth={scaledNumber}72
|
||||
OptionPane.sameSizeButtons=true
|
||||
OptionPane.setButtonMargin=false
|
||||
OptionPane.buttonOrientation=4
|
||||
@@ -307,12 +307,12 @@ Spinner.editorBorderPainted=false
|
||||
|
||||
#---- SplitPane ----
|
||||
|
||||
SplitPane.dividerSize=5
|
||||
SplitPane.dividerSize={integer}5
|
||||
SplitPane.continuousLayout=true
|
||||
SplitPane.border=null
|
||||
SplitPane.centerOneTouchButtons=true
|
||||
SplitPane.oneTouchButtonSize=6
|
||||
SplitPane.oneTouchButtonOffset=2
|
||||
SplitPane.oneTouchButtonSize={scaledNumber}6
|
||||
SplitPane.oneTouchButtonOffset={scaledNumber}2
|
||||
|
||||
SplitPaneDivider.border=null
|
||||
SplitPaneDivider.oneTouchArrowColor=@@ComboBox.buttonArrowColor
|
||||
@@ -409,7 +409,9 @@ ToolBar.separatorColor=@@Separator.foreground
|
||||
|
||||
#---- ToolTip ----
|
||||
|
||||
ToolTip.border=2,6,2,6,@@Component.borderColor
|
||||
ToolTip.borderInactive=null
|
||||
ToolTip.backgroundInactive=@@ToolTip.background
|
||||
ToolTip.foregroundInactive=@disabledText
|
||||
|
||||
|
||||
#---- Tree ----
|
||||
|
||||
@@ -234,7 +234,8 @@ ToggleButton.toolbar.selectedBackground=cfcfcf
|
||||
|
||||
#---- ToolTip ----
|
||||
|
||||
ToolTip.background=f7f7f7
|
||||
ToolTip.border=4,6,4,6,@@Component.borderColor
|
||||
ToolTip.background=fafafa
|
||||
|
||||
|
||||
#---- Tree ----
|
||||
|
||||
@@ -143,7 +143,14 @@ public class FlatComponentsTest
|
||||
JToggleButton toggleButton7 = new JToggleButton();
|
||||
JLabel scrollBarLabel = new JLabel();
|
||||
JScrollBar scrollBar1 = new JScrollBar();
|
||||
JLabel label4 = new JLabel();
|
||||
JScrollBar scrollBar4 = new JScrollBar();
|
||||
JPanel panel3 = new JPanel();
|
||||
JLabel label3 = new JLabel();
|
||||
JScrollPane scrollPane15 = new JScrollPane();
|
||||
JEditorPane editorPane6 = new JEditorPane();
|
||||
JScrollPane scrollPane16 = new JScrollPane();
|
||||
JTextPane textPane6 = new JTextPane();
|
||||
JLabel separatorLabel = new JLabel();
|
||||
JSeparator separator1 = new JSeparator();
|
||||
JPanel panel2 = new JPanel();
|
||||
@@ -223,12 +230,14 @@ public class FlatComponentsTest
|
||||
//---- button1 ----
|
||||
button1.setText("enabled");
|
||||
button1.setDisplayedMnemonicIndex(0);
|
||||
button1.setToolTipText("This button is enabled.");
|
||||
add(button1, "cell 1 1");
|
||||
|
||||
//---- button2 ----
|
||||
button2.setText("disabled");
|
||||
button2.setDisplayedMnemonicIndex(0);
|
||||
button2.setEnabled(false);
|
||||
button2.setToolTipText("This button is disabled.");
|
||||
add(button2, "cell 2 1");
|
||||
|
||||
//---- button5 ----
|
||||
@@ -719,11 +728,52 @@ public class FlatComponentsTest
|
||||
scrollBar1.setOrientation(Adjustable.HORIZONTAL);
|
||||
add(scrollBar1, "cell 1 14,growx");
|
||||
|
||||
//---- label4 ----
|
||||
label4.setText("HTML:");
|
||||
add(label4, "cell 5 14");
|
||||
|
||||
//---- scrollBar4 ----
|
||||
scrollBar4.setOrientation(Adjustable.HORIZONTAL);
|
||||
scrollBar4.setEnabled(false);
|
||||
add(scrollBar4, "cell 1 15,growx");
|
||||
|
||||
//======== panel3 ========
|
||||
{
|
||||
panel3.setLayout(new MigLayout(
|
||||
"insets 0,hidemode 3,gap 5 5,ltr",
|
||||
// columns
|
||||
"[]",
|
||||
// rows
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- label3 ----
|
||||
label3.setText("<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u></html>");
|
||||
panel3.add(label3, "cell 0 0");
|
||||
|
||||
//======== scrollPane15 ========
|
||||
{
|
||||
|
||||
//---- editorPane6 ----
|
||||
editorPane6.setContentType("text/html");
|
||||
editorPane6.setText("JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u>");
|
||||
scrollPane15.setViewportView(editorPane6);
|
||||
}
|
||||
panel3.add(scrollPane15, "cell 0 1,grow");
|
||||
|
||||
//======== scrollPane16 ========
|
||||
{
|
||||
|
||||
//---- textPane6 ----
|
||||
textPane6.setContentType("text/html");
|
||||
textPane6.setText("JTextPane HTML<br>Sample <b>content</b><br> <u>text</u>");
|
||||
scrollPane16.setViewportView(textPane6);
|
||||
}
|
||||
panel3.add(scrollPane16, "cell 0 2,grow");
|
||||
}
|
||||
add(panel3, "cell 5 15 1 7,aligny top,grow 100 0");
|
||||
|
||||
//---- separatorLabel ----
|
||||
separatorLabel.setText("JSeparator:");
|
||||
add(separatorLabel, "cell 0 16");
|
||||
|
||||
@@ -43,6 +43,7 @@ new FormModel {
|
||||
name: "button1"
|
||||
"text": "enabled"
|
||||
"displayedMnemonicIndex": 0
|
||||
"toolTipText": "This button is enabled."
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 1"
|
||||
} )
|
||||
@@ -51,6 +52,7 @@ new FormModel {
|
||||
"text": "disabled"
|
||||
"displayedMnemonicIndex": 0
|
||||
"enabled": false
|
||||
"toolTipText": "This button is disabled."
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 1"
|
||||
} )
|
||||
@@ -678,6 +680,12 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 14,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label4"
|
||||
"text": "HTML:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 14"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JScrollBar" ) {
|
||||
name: "scrollBar4"
|
||||
"orientation": 0
|
||||
@@ -685,6 +693,41 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 15,growx"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[]"
|
||||
"$rowConstraints": "[][][]"
|
||||
"$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr"
|
||||
} ) {
|
||||
name: "panel3"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label3"
|
||||
"text": "<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u></html>"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane15"
|
||||
add( new FormComponent( "javax.swing.JEditorPane" ) {
|
||||
name: "editorPane6"
|
||||
"contentType": "text/html"
|
||||
"text": "JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u>"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane16"
|
||||
add( new FormComponent( "javax.swing.JTextPane" ) {
|
||||
name: "textPane6"
|
||||
"contentType": "text/html"
|
||||
"text": "JTextPane HTML<br>Sample <b>content</b><br> <u>text</u>"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2,grow"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 15 1 7,aligny top,grow 100 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "separatorLabel"
|
||||
"text": "JSeparator:"
|
||||
@@ -837,7 +880,7 @@ new FormModel {
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 790, 715 )
|
||||
"size": new java.awt.Dimension( 790, 750 )
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +236,9 @@ public class FlatInspector
|
||||
}
|
||||
}
|
||||
|
||||
text += "Enabled: " + c.isEnabled() + '\n';
|
||||
text += "Opaque: " + c.isOpaque() + '\n';
|
||||
text += "Focusable: " + c.isFocusable() + '\n';
|
||||
text += "Parent: " + c.getParent().getClass().getName();
|
||||
|
||||
return text;
|
||||
|
||||
@@ -201,7 +201,7 @@ public class FlatOptionPaneTest
|
||||
//---- warningOptionPane ----
|
||||
warningOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE);
|
||||
warningOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
|
||||
warningOptionPane.setMessage("Beware of the dog!");
|
||||
warningOptionPane.setMessage("<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines.");
|
||||
panel5.add(warningOptionPane, BorderLayout.CENTER);
|
||||
}
|
||||
add(panel5, "cell 1 4");
|
||||
|
||||
@@ -140,7 +140,7 @@ new FormModel {
|
||||
name: "warningOptionPane"
|
||||
"messageType": 2
|
||||
"optionType": 2
|
||||
"message": "Beware of the dog!"
|
||||
"message": "<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines."
|
||||
}, new FormLayoutConstraints( class java.lang.String ) {
|
||||
"value": "Center"
|
||||
} )
|
||||
|
||||
@@ -22,8 +22,7 @@ import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
@@ -205,7 +204,7 @@ public class FlatTestFrame
|
||||
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||
}
|
||||
|
||||
protected void showFrame( JComponent content ) {
|
||||
public void showFrame( JComponent content ) {
|
||||
this.content = content;
|
||||
|
||||
contentPanel.getContentPane().add( content );
|
||||
@@ -290,7 +289,15 @@ public class FlatTestFrame
|
||||
boolean explicit = explicitColorsCheckBox.isSelected();
|
||||
ColorUIResource restoreColor = new ColorUIResource( Color.white );
|
||||
|
||||
explicitColors( content, explicit, restoreColor );
|
||||
updateComponentsRecur( content, (c, type) -> {
|
||||
if( type == "view" || type == "tab" ) {
|
||||
c.setForeground( explicit ? Color.magenta : restoreColor );
|
||||
c.setBackground( explicit ? Color.orange : restoreColor );
|
||||
} else {
|
||||
c.setForeground( explicit ? Color.blue : restoreColor );
|
||||
c.setBackground( explicit ? Color.red : restoreColor );
|
||||
}
|
||||
} );
|
||||
|
||||
// because colors may depend on state (e.g. disabled JTextField)
|
||||
// it is best to update all UI delegates to get correct result
|
||||
@@ -299,40 +306,6 @@ public class FlatTestFrame
|
||||
} );
|
||||
}
|
||||
|
||||
private void explicitColors( Container container, boolean explicit, ColorUIResource restoreColor ) {
|
||||
for( Component c : container.getComponents() ) {
|
||||
if( c instanceof JPanel ) {
|
||||
explicitColors( (JPanel) c, explicit, restoreColor );
|
||||
continue;
|
||||
}
|
||||
|
||||
c.setForeground( explicit ? Color.blue : restoreColor );
|
||||
c.setBackground( explicit ? Color.red : restoreColor );
|
||||
|
||||
if( c instanceof JScrollPane ) {
|
||||
Component view = ((JScrollPane)c).getViewport().getView();
|
||||
if( view != null ) {
|
||||
view.setForeground( explicit ? Color.magenta : restoreColor );
|
||||
view.setBackground( explicit ? Color.orange : restoreColor );
|
||||
}
|
||||
} else if( c instanceof JTabbedPane ) {
|
||||
JTabbedPane tabPane = (JTabbedPane)c;
|
||||
int tabCount = tabPane.getTabCount();
|
||||
for( int i = 0; i < tabCount; i++ ) {
|
||||
Component tab = tabPane.getComponentAt( i );
|
||||
if( tab != null ) {
|
||||
tab.setForeground( explicit ? Color.magenta : restoreColor );
|
||||
tab.setBackground( explicit ? Color.orange : restoreColor );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( c instanceof JToolBar )
|
||||
explicitColors( (JToolBar) c, explicit, restoreColor );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void rightToLeftChanged() {
|
||||
contentPanel.applyComponentOrientation( rightToLeftCheckBox.isSelected()
|
||||
? ComponentOrientation.RIGHT_TO_LEFT
|
||||
@@ -342,35 +315,10 @@ public class FlatTestFrame
|
||||
}
|
||||
|
||||
private void enabledChanged() {
|
||||
enabledDisable( content, enabledCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void enabledDisable( Container container, boolean enabled ) {
|
||||
for( Component c : container.getComponents() ) {
|
||||
if( c instanceof JPanel ) {
|
||||
enabledDisable( (JPanel) c, enabled );
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean enabled = enabledCheckBox.isSelected();
|
||||
updateComponentsRecur( content, (c, type) -> {
|
||||
c.setEnabled( enabled );
|
||||
|
||||
if( c instanceof JScrollPane ) {
|
||||
Component view = ((JScrollPane)c).getViewport().getView();
|
||||
if( view != null )
|
||||
view.setEnabled( enabled );
|
||||
} else if( c instanceof JTabbedPane ) {
|
||||
JTabbedPane tabPane = (JTabbedPane)c;
|
||||
int tabCount = tabPane.getTabCount();
|
||||
for( int i = 0; i < tabCount; i++ ) {
|
||||
Component tab = tabPane.getComponentAt( i );
|
||||
if( tab != null )
|
||||
tab.setEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
if( c instanceof JToolBar )
|
||||
enabledDisable( (JToolBar) c, enabled );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void inspectChanged() {
|
||||
@@ -404,6 +352,34 @@ public class FlatTestFrame
|
||||
scaleFactorComboBox.setEnabled( !UIScale.isSystemScalingEnabled() && UIManager.getLookAndFeel() instanceof FlatLaf );
|
||||
}
|
||||
|
||||
private void updateComponentsRecur( Container container, BiConsumer<Component, String> action ) {
|
||||
for( Component c : container.getComponents() ) {
|
||||
if( c instanceof JPanel ) {
|
||||
updateComponentsRecur( (JPanel) c, action );
|
||||
continue;
|
||||
}
|
||||
|
||||
action.accept( c, null );
|
||||
|
||||
if( c instanceof JScrollPane ) {
|
||||
Component view = ((JScrollPane)c).getViewport().getView();
|
||||
if( view != null )
|
||||
action.accept( view, "view" );
|
||||
} else if( c instanceof JTabbedPane ) {
|
||||
JTabbedPane tabPane = (JTabbedPane)c;
|
||||
int tabCount = tabPane.getTabCount();
|
||||
for( int i = 0; i < tabCount; i++ ) {
|
||||
Component tab = tabPane.getComponentAt( i );
|
||||
if( tab != null )
|
||||
action.accept( tab, "tab" );
|
||||
}
|
||||
}
|
||||
|
||||
if( c instanceof JToolBar )
|
||||
updateComponentsRecur( (JToolBar) c, action );
|
||||
}
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
dialogPane = new JPanel();
|
||||
|
||||
@@ -18,10 +18,7 @@ version = rootProject.version
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
id( "com.jfrog.bintray" ) version "1.8.4"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -38,6 +35,8 @@ java {
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
dependsOn( ":flatlaf-core:jar" )
|
||||
|
||||
manifest {
|
||||
attributes( "Main-Class" to "com.formdev.flatlaf.demo.FlatLafDemo" )
|
||||
}
|
||||
@@ -50,3 +49,23 @@ tasks {
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
bintray {
|
||||
user = System.getenv( "BINTRAY_USER" ) ?: System.getProperty( "bintray.user" )
|
||||
key = System.getenv( "BINTRAY_KEY" ) ?: System.getProperty( "bintray.key" )
|
||||
|
||||
setConfigurations( "archives" )
|
||||
|
||||
with( pkg ) {
|
||||
repo = "flatlaf"
|
||||
name = "flatlaf-demo"
|
||||
setLicenses( "Apache-2.0" )
|
||||
vcsUrl = "https://github.com/JFormDesigner/FlatLaf"
|
||||
|
||||
with( version ) {
|
||||
name = project.version.toString()
|
||||
}
|
||||
|
||||
publish = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ class OptionPanePanel
|
||||
//---- warningOptionPane ----
|
||||
warningOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE);
|
||||
warningOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
|
||||
warningOptionPane.setMessage("Beware of the dog!");
|
||||
warningOptionPane.setMessage("<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines.");
|
||||
panel5.add(warningOptionPane, BorderLayout.CENTER);
|
||||
}
|
||||
panel9.add(panel5, "cell 1 4");
|
||||
|
||||
@@ -143,7 +143,7 @@ new FormModel {
|
||||
name: "warningOptionPane"
|
||||
"messageType": 2
|
||||
"optionType": 2
|
||||
"message": "Beware of the dog!"
|
||||
"message": "<html>I like <b>bold</b>,<br> and I like <i>italic</i>,<br> and I like to have<br> many lines.<br> Lots of lines."
|
||||
}, new FormLayoutConstraints( class java.lang.String ) {
|
||||
"value": "Center"
|
||||
} )
|
||||
|
||||
43
flatlaf-swingx/README.md
Normal file
43
flatlaf-swingx/README.md
Normal file
@@ -0,0 +1,43 @@
|
||||
FlatLaf addon for SwingX
|
||||
========================
|
||||
|
||||
This addon for FlatLaf adds support for **some** widely used SwingX components.
|
||||
|
||||
Many SwingX components that do not use UI delegates (e.g. `JXButton`, `JXLabel`,
|
||||
`JXList`, etc) work with FlatLaf without adaptation.
|
||||
|
||||
Following SwingX components, which use UI delegates, are supported by this
|
||||
addon:
|
||||
|
||||
- `JXBusyLabel`
|
||||
- `JXDatePicker`
|
||||
- `JXHeader`
|
||||
- `JXHyperlink`
|
||||
- `JXMonthView`
|
||||
- `JXTaskPaneContainer`
|
||||
- `JXTaskPane`
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
Download
|
||||
--------
|
||||
|
||||
FlatLaf for SwingX binaries are available on **JCenter** and **Maven Central**.
|
||||
|
||||
If you use Maven or Gradle, add a dependency with following coordinates to your
|
||||
build script:
|
||||
|
||||
groupId: com.formdev
|
||||
artifactId: flatlaf-swingx
|
||||
version: 0.15
|
||||
|
||||
Otherwise download `flatlaf-swingx-<version>.jar` here:
|
||||
|
||||
[](https://bintray.com/jformdesigner/flatlaf/flatlaf-swingx/_latestVersion)
|
||||
|
||||
You also need `flatlaf-<version>.jar`, which you can download here:
|
||||
|
||||
[](https://bintray.com/jformdesigner/flatlaf/flatlaf/_latestVersion)
|
||||
119
flatlaf-swingx/build.gradle.kts
Normal file
119
flatlaf-swingx/build.gradle.kts
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
version = rootProject.version
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id( "com.jfrog.bintray" ) version "1.8.4"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation( project( ":flatlaf-core" ) )
|
||||
implementation( "org.swinglabs.swingx:swingx-all:1.6.5-1" )
|
||||
|
||||
testImplementation( project( ":flatlaf-core", "testArtifacts" ) )
|
||||
testImplementation( "org.swinglabs.swingx:swingx-beaninfo:1.6.5-1" )
|
||||
testImplementation( "com.miglayout:miglayout-swing:5.2" )
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
javadoc {
|
||||
options {
|
||||
this as StandardJavadocDocletOptions
|
||||
tags = listOf( "uiDefault", "clientProperty" )
|
||||
}
|
||||
isFailOnError = false
|
||||
}
|
||||
|
||||
register( "sourcesJar", Jar::class ) {
|
||||
archiveClassifier.set( "sources" )
|
||||
|
||||
from( sourceSets.main.get().allJava )
|
||||
}
|
||||
|
||||
register( "javadocJar", Jar::class ) {
|
||||
archiveClassifier.set( "javadoc" )
|
||||
|
||||
from( javadoc )
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>( "maven" ) {
|
||||
artifactId = "flatlaf-swingx"
|
||||
groupId = "com.formdev"
|
||||
|
||||
from( components["java"] )
|
||||
|
||||
artifact( tasks["sourcesJar"] )
|
||||
artifact( tasks["javadocJar"] )
|
||||
|
||||
pom {
|
||||
name.set( "FlatLaf addon for SwingX" )
|
||||
description.set( "Flat Look and Feel addon for SwingX" )
|
||||
url.set( "https://github.com/JFormDesigner/FlatLaf" )
|
||||
|
||||
licenses {
|
||||
license {
|
||||
name.set( "The Apache License, Version 2.0" )
|
||||
url.set( "http://www.apache.org/licenses/LICENSE-2.0.txt" )
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
name.set( "Karl Tauber" )
|
||||
organization.set( "FormDev Software GmbH" )
|
||||
organizationUrl.set( "https://www.formdev.com/" )
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
url.set( "https://github.com/JFormDesigner/FlatLaf" )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bintray {
|
||||
user = System.getenv( "BINTRAY_USER" ) ?: System.getProperty( "bintray.user" )
|
||||
key = System.getenv( "BINTRAY_KEY" ) ?: System.getProperty( "bintray.key" )
|
||||
|
||||
setPublications( "maven" )
|
||||
|
||||
with( pkg ) {
|
||||
repo = "flatlaf"
|
||||
name = "flatlaf-swingx"
|
||||
setLicenses( "Apache-2.0" )
|
||||
vcsUrl = "https://github.com/JFormDesigner/FlatLaf"
|
||||
|
||||
with( version ) {
|
||||
name = project.version.toString()
|
||||
}
|
||||
|
||||
publish = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
import org.jdesktop.swingx.plaf.basic.BasicLookAndFeelAddons;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
|
||||
/**
|
||||
* SwingX LaF addon.
|
||||
*
|
||||
* This class is required because without this class, the system addon would be used,
|
||||
* which may result in wrong UI defaults. (e.g. background of TaskPaneContainer)
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatLookAndFeelAddons
|
||||
extends BasicLookAndFeelAddons
|
||||
{
|
||||
@Override
|
||||
protected boolean matches() {
|
||||
return UIManager.getLookAndFeel() instanceof FlatLaf;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx;
|
||||
|
||||
import java.io.InputStream;
|
||||
import com.formdev.flatlaf.FlatDefaultsAddon;
|
||||
|
||||
/**
|
||||
* SwingX addon for FlatLaf.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatSwingXDefaultsAddon
|
||||
extends FlatDefaultsAddon
|
||||
{
|
||||
/**
|
||||
* Finds SwingX addon .properties file for the given LaF class
|
||||
* in the same package as this class.
|
||||
*/
|
||||
@Override
|
||||
public InputStream getDefaults( Class<?> lafClass ) {
|
||||
Class<?> addonClass = this.getClass();
|
||||
String propertiesName = "/" + addonClass.getPackage().getName().replace( '.', '/' )
|
||||
+ '/' + lafClass.getSimpleName() + ".properties";
|
||||
return addonClass.getResourceAsStream( propertiesName );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import org.jdesktop.swingx.JXBusyLabel;
|
||||
import org.jdesktop.swingx.plaf.basic.BasicBusyLabelUI;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
|
||||
//TODO scale busy spinner
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link org.jdesktop.swingx.JXBusyLabel}.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatBusyLabelUI
|
||||
extends BasicBusyLabelUI
|
||||
{
|
||||
private Color disabledForeground;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatBusyLabelUI( (JXBusyLabel) c );
|
||||
}
|
||||
|
||||
public FlatBusyLabelUI( JXBusyLabel busyLabel ) {
|
||||
super( busyLabel );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults( JLabel c ) {
|
||||
super.installDefaults( c );
|
||||
|
||||
disabledForeground = UIManager.getColor( "Label.disabledForeground" );
|
||||
|
||||
// force recreation of busy painter for correct colors when switching LaF
|
||||
if( c.getIcon() != null ) {
|
||||
JXBusyLabel busyLabel = (JXBusyLabel) c;
|
||||
boolean oldBusy = busyLabel.isBusy();
|
||||
busyLabel.setBusy( false );
|
||||
busyLabel.setBusyPainter( null );
|
||||
busyLabel.setBusy( oldBusy );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallDefaults( JLabel c ) {
|
||||
super.uninstallDefaults( c );
|
||||
|
||||
disabledForeground = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintDisabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
|
||||
int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1;
|
||||
g.setColor( disabledForeground );
|
||||
FlatUIUtils.drawStringUnderlineCharAt( l, g, s, mnemIndex, textX, textY );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx.ui;
|
||||
|
||||
import java.awt.Component;
|
||||
import org.jdesktop.swingx.JXDatePicker;
|
||||
import com.formdev.flatlaf.ui.FlatRoundBorder;
|
||||
|
||||
/**
|
||||
* Border for {@link org.jdesktop.swingx.JXDatePicker}.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatDatePickerBorder
|
||||
extends FlatRoundBorder
|
||||
{
|
||||
@Override
|
||||
protected boolean isFocused( Component c ) {
|
||||
if( c instanceof JXDatePicker )
|
||||
return ((JXDatePicker)c).getEditor().hasFocus();
|
||||
|
||||
return super.isFocused( c );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx.ui;
|
||||
|
||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.LayoutManager;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFormattedTextField;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import org.jdesktop.swingx.JXHyperlink;
|
||||
import org.jdesktop.swingx.JXPanel;
|
||||
import org.jdesktop.swingx.calendar.DatePickerFormatter.DatePickerFormatterUIResource;
|
||||
import org.jdesktop.swingx.plaf.basic.BasicDatePickerUI;
|
||||
import com.formdev.flatlaf.ui.FlatArrowButton;
|
||||
import com.formdev.flatlaf.ui.FlatBorder;
|
||||
import com.formdev.flatlaf.ui.FlatRoundBorder;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.ui.MigLayoutVisualPadding;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link org.jdesktop.swingx.JXDatePicker}.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatDatePickerUI
|
||||
extends BasicDatePickerUI
|
||||
{
|
||||
protected Insets padding;
|
||||
|
||||
protected int focusWidth;
|
||||
protected int arc;
|
||||
protected String arrowType;
|
||||
protected Color borderColor;
|
||||
protected Color disabledBorderColor;
|
||||
|
||||
protected Color disabledBackground;
|
||||
|
||||
protected Color buttonBackground;
|
||||
protected Color buttonArrowColor;
|
||||
protected Color buttonDisabledArrowColor;
|
||||
protected Color buttonHoverArrowColor;
|
||||
|
||||
private JButton popupButton;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatDatePickerUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installUI( JComponent c ) {
|
||||
// must get UI defaults here because installDefaults() is invoked after
|
||||
// installComponents(), which uses these values to create popup button
|
||||
|
||||
padding = UIManager.getInsets( "ComboBox.padding" );
|
||||
|
||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||
arc = UIManager.getInt( "Component.arc" );
|
||||
arrowType = UIManager.getString( "Component.arrowType" );
|
||||
borderColor = UIManager.getColor( "Component.borderColor" );
|
||||
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
||||
|
||||
disabledBackground = UIManager.getColor( "ComboBox.disabledBackground" );
|
||||
|
||||
buttonBackground = UIManager.getColor( "ComboBox.buttonBackground" );
|
||||
buttonArrowColor = UIManager.getColor( "ComboBox.buttonArrowColor" );
|
||||
buttonDisabledArrowColor = UIManager.getColor( "ComboBox.buttonDisabledArrowColor" );
|
||||
buttonHoverArrowColor = UIManager.getColor( "ComboBox.buttonHoverArrowColor" );
|
||||
|
||||
super.installUI( c );
|
||||
|
||||
// hack JXDatePicker.TodayPanel colors
|
||||
// (there is no need to uninstall these changes because only UIResources are used,
|
||||
// which are automatically replaced when switching LaF)
|
||||
JPanel linkPanel = datePicker.getLinkPanel();
|
||||
if( linkPanel instanceof JXPanel && linkPanel.getClass().getName().equals( "org.jdesktop.swingx.JXDatePicker$TodayPanel" ) ) {
|
||||
((JXPanel)linkPanel).setBackgroundPainter( null );
|
||||
linkPanel.setBackground( UIManager.getColor( "JXMonthView.background" ) );
|
||||
|
||||
if( linkPanel.getComponentCount() >= 1 && linkPanel.getComponent( 0 ) instanceof JXHyperlink ) {
|
||||
JXHyperlink todayLink = (JXHyperlink) linkPanel.getComponent( 0 );
|
||||
todayLink.setUnclickedColor( UIManager.getColor( "Hyperlink.linkColor" ) );
|
||||
todayLink.setClickedColor( UIManager.getColor( "Hyperlink.visitedColor" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
|
||||
LookAndFeel.installColors( datePicker, "ComboBox.background", "ComboBox.foreground" );
|
||||
|
||||
LookAndFeel.installBorder( datePicker, "JXDatePicker.border" );
|
||||
LookAndFeel.installProperty( datePicker, "opaque", Boolean.TRUE );
|
||||
|
||||
MigLayoutVisualPadding.install( datePicker, focusWidth );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallDefaults() {
|
||||
super.uninstallDefaults();
|
||||
|
||||
borderColor = null;
|
||||
disabledBorderColor = null;
|
||||
|
||||
disabledBackground = null;
|
||||
|
||||
buttonBackground = null;
|
||||
buttonArrowColor = null;
|
||||
buttonDisabledArrowColor = null;
|
||||
buttonHoverArrowColor = null;
|
||||
|
||||
if( datePicker.getBorder() instanceof UIResource )
|
||||
datePicker.setBorder( null );
|
||||
|
||||
MigLayoutVisualPadding.uninstall( datePicker );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JFormattedTextField createEditor() {
|
||||
JFormattedTextField editor = new DefaultEditor( new DatePickerFormatterUIResource( datePicker.getLocale() ) );
|
||||
editor.setName( "dateField" );
|
||||
editor.setBorder( BorderFactory.createEmptyBorder() );
|
||||
editor.setOpaque( false );
|
||||
editor.addFocusListener( new FocusListener() {
|
||||
@Override
|
||||
public void focusLost( FocusEvent e ) {
|
||||
if( datePicker != null )
|
||||
datePicker.repaint();
|
||||
}
|
||||
@Override
|
||||
public void focusGained( FocusEvent e ) {
|
||||
if( datePicker != null )
|
||||
datePicker.repaint();
|
||||
}
|
||||
} );
|
||||
return editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JButton createPopupButton() {
|
||||
popupButton = new FlatArrowButton( SwingConstants.SOUTH, arrowType, buttonArrowColor,
|
||||
buttonDisabledArrowColor, buttonHoverArrowColor, null );
|
||||
popupButton.setName( "popupButton" );
|
||||
return popupButton;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LayoutManager createLayoutManager() {
|
||||
return new LayoutManager() {
|
||||
@Override
|
||||
public void addLayoutComponent( String name, Component comp ) {}
|
||||
@Override
|
||||
public void removeLayoutComponent( Component comp ) {}
|
||||
|
||||
@Override
|
||||
public Dimension preferredLayoutSize( Container parent ) {
|
||||
return parent.getPreferredSize();
|
||||
}
|
||||
@Override
|
||||
public Dimension minimumLayoutSize( Container parent ) {
|
||||
return parent.getMinimumSize();
|
||||
}
|
||||
@Override
|
||||
public void layoutContainer( Container parent ) {
|
||||
Insets insets = datePicker.getInsets();
|
||||
int x = insets.left;
|
||||
int y = insets.top;
|
||||
int width = datePicker.getWidth() - insets.left - insets.right;
|
||||
int height = datePicker.getHeight() - insets.top - insets.bottom;
|
||||
|
||||
int popupButtonWidth = popupButton != null ? height : 0;
|
||||
boolean ltr = datePicker.getComponentOrientation().isLeftToRight();
|
||||
|
||||
Rectangle r = new Rectangle( x + (ltr ? 0 : popupButtonWidth), y, width - popupButtonWidth, height );
|
||||
r = FlatUIUtils.subtractInsets( r, UIScale.scale( padding ) );
|
||||
datePicker.getEditor().setBounds( r );
|
||||
|
||||
if( popupButton != null )
|
||||
popupButton.setBounds( x + (ltr ? width - popupButtonWidth : 0), y, popupButtonWidth, height );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize( JComponent c ) {
|
||||
Dimension dim = datePicker.getEditor().getPreferredSize();
|
||||
dim = FlatUIUtils.addInsets( dim, UIScale.scale( padding ) );
|
||||
if( popupButton != null )
|
||||
dim.width += dim.height;
|
||||
return FlatUIUtils.addInsets( dim, datePicker.getInsets() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( Graphics g, JComponent c ) {
|
||||
if( c.isOpaque() ) {
|
||||
FlatUIUtils.paintParentBackground( g, c );
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
FlatUIUtils.setRenderingHints( g2 );
|
||||
|
||||
int width = c.getWidth();
|
||||
int height = c.getHeight();
|
||||
float focusWidth = (c.getBorder() instanceof FlatBorder) ? scale( (float) this.focusWidth ) : 0;
|
||||
float arc = (c.getBorder() instanceof FlatRoundBorder) ? scale( (float) this.arc ) : 0;
|
||||
int arrowX = popupButton.getX();
|
||||
int arrowWidth = popupButton.getWidth();
|
||||
boolean enabled = c.isEnabled();
|
||||
boolean isLeftToRight = c.getComponentOrientation().isLeftToRight();
|
||||
|
||||
// paint background
|
||||
g2.setColor( enabled ? c.getBackground() : disabledBackground );
|
||||
FlatUIUtils.fillRoundRectangle( g2, 0, 0, width, height, focusWidth, arc );
|
||||
|
||||
// paint arrow button background
|
||||
if( enabled ) {
|
||||
g2.setColor( buttonBackground );
|
||||
Shape oldClip = g2.getClip();
|
||||
if( isLeftToRight )
|
||||
g2.clipRect( arrowX, 0, width - arrowX, height );
|
||||
else
|
||||
g2.clipRect( 0, 0, arrowX + arrowWidth, height );
|
||||
FlatUIUtils.fillRoundRectangle( g2, 0, 0, width, height, focusWidth, arc );
|
||||
g2.setClip( oldClip );
|
||||
}
|
||||
|
||||
// paint vertical line between value and arrow button
|
||||
g2.setColor( enabled ? borderColor : disabledBorderColor );
|
||||
float lw = scale( 1f );
|
||||
float lx = isLeftToRight ? arrowX : arrowX + arrowWidth - lw;
|
||||
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - (focusWidth * 2) ) );
|
||||
}
|
||||
|
||||
paint( g, c );
|
||||
}
|
||||
|
||||
//---- class DefaultEditor ------------------------------------------------
|
||||
|
||||
private class DefaultEditor
|
||||
extends JFormattedTextField
|
||||
implements UIResource
|
||||
{
|
||||
DefaultEditor( AbstractFormatter formatter ) {
|
||||
super( formatter );
|
||||
|
||||
// disable Component.minimumWidth
|
||||
setColumns( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension prefSize = super.getPreferredSize();
|
||||
|
||||
// create date 2000-11-30 that is used for minimum width calculation
|
||||
Calendar calendar = Calendar.getInstance( datePicker.getLocale() );
|
||||
calendar.set( 2000, 11, 30 );
|
||||
|
||||
try {
|
||||
AbstractFormatter formatter = getFormatter();
|
||||
String str = formatter.valueToString( calendar.getTime() );
|
||||
|
||||
Insets insets = getInsets();
|
||||
FontMetrics metrics = getFontMetrics( getFont() );
|
||||
int minWidth = metrics.stringWidth( str ) + insets.left + insets.right + 2;
|
||||
return new Dimension( Math.max( minWidth, prefSize.width ), prefSize.height );
|
||||
} catch( ParseException ex ) {
|
||||
// ignore
|
||||
return prefSize;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize() {
|
||||
return getPreferredSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx.ui;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.LayoutManager;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import org.jdesktop.swingx.JXHeader;
|
||||
import org.jdesktop.swingx.plaf.basic.BasicHeaderUI;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link org.jdesktop.swingx.JXHeader}.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatHeaderUI
|
||||
extends BasicHeaderUI
|
||||
{
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatHeaderUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installComponents( JXHeader header ) {
|
||||
super.installComponents( header );
|
||||
|
||||
scaleLayout( header );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPropertyChange( JXHeader h, String propertyName, Object oldValue, Object newValue ) {
|
||||
super.onPropertyChange( h, propertyName, oldValue, newValue );
|
||||
|
||||
if( "iconPosition".equals( propertyName ) )
|
||||
scaleLayout( h );
|
||||
}
|
||||
|
||||
private void scaleLayout( JXHeader header ) {
|
||||
if( UIScale.getUserScaleFactor() == 1f )
|
||||
return;
|
||||
|
||||
LayoutManager layout = header.getLayout();
|
||||
if( !(layout instanceof GridBagLayout) )
|
||||
return;
|
||||
|
||||
GridBagLayout gbl = (GridBagLayout) layout;
|
||||
for( Component c : header.getComponents() ) {
|
||||
GridBagConstraints cons = gbl.getConstraints( c );
|
||||
cons.insets = UIScale.scale( cons.insets );
|
||||
gbl.setConstraints( c, cons );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx.ui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import org.jdesktop.swingx.plaf.basic.BasicHyperlinkUI;
|
||||
import com.formdev.flatlaf.ui.FlatButtonUI;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link org.jdesktop.swingx.JXHyperlink}.
|
||||
*
|
||||
* @uiDefault Hyperlink.disabledText Color
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatHyperlinkUI
|
||||
extends BasicHyperlinkUI
|
||||
{
|
||||
protected Color disabledText;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatHyperlinkUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults( AbstractButton b ) {
|
||||
super.installDefaults( b );
|
||||
|
||||
disabledText = UIManager.getColor( "Hyperlink.disabledText" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallDefaults( AbstractButton b ) {
|
||||
super.uninstallDefaults( b );
|
||||
|
||||
disabledText = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint( Graphics g, JComponent c ) {
|
||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||
|
||||
super.paint( g, c );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text ) {
|
||||
FlatButtonUI.paintText( g, b, textRect, text, b.isEnabled() ? b.getForeground() : disabledText );
|
||||
|
||||
if( b.getModel().isRollover() )
|
||||
paintUnderline( g, textRect );
|
||||
}
|
||||
|
||||
private void paintUnderline( Graphics g, Rectangle rect ) {
|
||||
int descent = g.getFontMetrics().getDescent();
|
||||
|
||||
((Graphics2D)g).fill( new Rectangle2D.Float(
|
||||
rect.x, (rect.y + rect.height) - descent + UIScale.scale( 1f ),
|
||||
rect.width, UIScale.scale( 1f ) ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx.ui;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Shape;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import com.formdev.flatlaf.icons.FlatAbstractIcon;
|
||||
import com.formdev.flatlaf.ui.FlatArrowButton;
|
||||
|
||||
/**
|
||||
* "month down" icon for {@link org.jdesktop.swingx.JXMonthView}.
|
||||
*
|
||||
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||
* @uiDefault JXMonthView.arrowColor Color
|
||||
* @uiDefault JXMonthView.disabledArrowColor Color
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatMonthDownIcon
|
||||
extends FlatAbstractIcon
|
||||
{
|
||||
protected final boolean chevron = "chevron".equals( UIManager.getString( "Component.arrowType" ) );
|
||||
protected final Color arrowColor = UIManager.getColor( "JXMonthView.arrowColor" );
|
||||
protected final Color disabledArrowColor = UIManager.getColor( "JXMonthView.disabledArrowColor" );
|
||||
|
||||
private final int direction;
|
||||
|
||||
public FlatMonthDownIcon() {
|
||||
this( SwingConstants.WEST );
|
||||
}
|
||||
|
||||
protected FlatMonthDownIcon( int direction ) {
|
||||
super( 20, 20, null );
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintIcon( Component c, Graphics2D g ) {
|
||||
int h = chevron ? 4 : 5;
|
||||
int w = chevron ? 8 : 9;
|
||||
int x = Math.round( (width - h) / 2f );
|
||||
int y = Math.round( (height - w) / 2f );
|
||||
|
||||
g.setColor( c.isEnabled() ? arrowColor : disabledArrowColor );
|
||||
g.translate( x, y );
|
||||
Shape arrowShape = FlatArrowButton.createArrowShape( direction, chevron, w, h );
|
||||
if( chevron ) {
|
||||
// chevron arrow
|
||||
g.setStroke( new BasicStroke( 1f ) );
|
||||
g.draw( arrowShape );
|
||||
} else {
|
||||
// triangle arrow
|
||||
g.fill( arrowShape );
|
||||
}
|
||||
g.translate( -x, -y );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx.ui;
|
||||
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
/**
|
||||
* "month up" icon for {@link org.jdesktop.swingx.JXMonthView}.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatMonthUpIcon
|
||||
extends FlatMonthDownIcon
|
||||
{
|
||||
public FlatMonthUpIcon() {
|
||||
super( SwingConstants.EAST );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx.ui;
|
||||
|
||||
import java.awt.Insets;
|
||||
import java.util.Calendar;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import org.jdesktop.swingx.JXMonthView;
|
||||
import org.jdesktop.swingx.plaf.basic.BasicMonthViewUI;
|
||||
import org.jdesktop.swingx.plaf.basic.CalendarRenderingHandler;
|
||||
import org.jdesktop.swingx.plaf.basic.CalendarState;
|
||||
import com.formdev.flatlaf.ui.FlatEmptyBorder;
|
||||
import com.formdev.flatlaf.ui.FlatLineBorder;
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link org.jdesktop.swingx.JXMonthView}.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatMonthViewUI
|
||||
extends BasicMonthViewUI
|
||||
{
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatMonthViewUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CalendarRenderingHandler createRenderingHandler() {
|
||||
return new FlatRenderingHandler();
|
||||
}
|
||||
|
||||
//---- class FlatRenderingHandler -----------------------------------------
|
||||
|
||||
private static class FlatRenderingHandler
|
||||
extends RenderingHandler
|
||||
{
|
||||
@Override
|
||||
public JComponent prepareRenderingComponent( JXMonthView monthView, Calendar calendar,
|
||||
CalendarState dayState )
|
||||
{
|
||||
JComponent c = super.prepareRenderingComponent( monthView, calendar, dayState );
|
||||
|
||||
int px = monthView.getBoxPaddingX();
|
||||
int py = monthView.getBoxPaddingY();
|
||||
|
||||
// scale borders
|
||||
Border border = null;
|
||||
if( dayState == CalendarState.TITLE && monthView.isTraversable() ) {
|
||||
Border b = c.getBorder();
|
||||
if( b instanceof CompoundBorder && ((CompoundBorder)b).getInsideBorder() instanceof EmptyBorder )
|
||||
border = new CompoundBorder( ((CompoundBorder)b).getOutsideBorder(), new FlatEmptyBorder( py * 2, 0, py * 2, 0 ) );
|
||||
} else if( dayState == CalendarState.TODAY )
|
||||
border = new FlatLineBorder( new Insets( py, px, py, px ), monthView.getTodayBackground() );
|
||||
|
||||
if( border == null )
|
||||
border = new FlatEmptyBorder( py, px, py, px );
|
||||
c.setBorder( border );
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx.ui;
|
||||
|
||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Shape;
|
||||
import java.awt.geom.Path2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import org.jdesktop.swingx.JXTaskPane;
|
||||
import org.jdesktop.swingx.plaf.basic.BasicTaskPaneUI;
|
||||
import com.formdev.flatlaf.ui.FlatArrowButton;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
|
||||
/**
|
||||
* Provides the Flat LaF UI delegate for {@link org.jdesktop.swingx.JXTaskPane}.
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatTaskPaneUI
|
||||
extends BasicTaskPaneUI
|
||||
{
|
||||
private Color background;
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new FlatTaskPaneUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults() {
|
||||
if( group.getContentPane() instanceof JComponent ) {
|
||||
// remove default SwingX content border, which may be still set when switching LaF
|
||||
JComponent content = (JComponent) group.getContentPane();
|
||||
Border contentBorder = content.getBorder();
|
||||
if( contentBorder instanceof CompoundBorder &&
|
||||
((CompoundBorder)contentBorder).getOutsideBorder() instanceof BasicTaskPaneUI.ContentPaneBorder &&
|
||||
((CompoundBorder)contentBorder).getInsideBorder() instanceof EmptyBorder )
|
||||
{
|
||||
content.setBorder( null );
|
||||
}
|
||||
|
||||
// set non-UIResource color to background to avoid that it is lost when switching LaF
|
||||
background = UIManager.getColor( "TaskPane.background" );
|
||||
Color bg = content.getBackground();
|
||||
if( bg == null || bg instanceof UIResource ) {
|
||||
content.setBackground( new Color( background.getRGB(), true ) );
|
||||
}
|
||||
}
|
||||
|
||||
roundHeight = FlatUIUtils.getUIInt( "TaskPane.roundHeight", UIManager.getInt( "Component.arc" ) );
|
||||
|
||||
super.installDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninstallUI( JComponent c ) {
|
||||
if( group.getContentPane() instanceof JComponent ) {
|
||||
// uninstall our content border, because it does not implement UIResource,
|
||||
// to alloy other LaF to install its own border
|
||||
JComponent content = (JComponent) group.getContentPane();
|
||||
if( content.getBorder() instanceof FlatContentPaneBorder )
|
||||
content.setBorder( null );
|
||||
|
||||
// replace our non-UIResouce background with UIResouce background
|
||||
// to allow next LaF to overwrite it
|
||||
if( background.equals( content.getBackground() ) )
|
||||
content.setBackground( background );
|
||||
background = null;
|
||||
}
|
||||
|
||||
|
||||
super.uninstallUI( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTitleHeight( Component c ) {
|
||||
return Math.max( super.getTitleHeight( c ), UIScale.scale( titleHeight ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRoundHeight() {
|
||||
return UIScale.scale( roundHeight );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Border createPaneBorder() {
|
||||
return new FlatPaneBorder();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Border createContentPaneBorder() {
|
||||
return new FlatContentPaneBorder( UIManager.getColor( "TaskPane.borderColor" ),
|
||||
UIManager.getInsets( "TaskPane.contentInsets" ) );
|
||||
}
|
||||
|
||||
//---- class FlatContentPaneBorder ----------------------------------------
|
||||
|
||||
/**
|
||||
* The content pane border.
|
||||
*/
|
||||
private static class FlatContentPaneBorder
|
||||
extends EmptyBorder
|
||||
{
|
||||
Color color;
|
||||
|
||||
FlatContentPaneBorder( Color color, Insets insets ) {
|
||||
super( insets );
|
||||
this.color = color;
|
||||
|
||||
// add space for the line border
|
||||
left++;
|
||||
right++;
|
||||
bottom++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
||||
if( color == null )
|
||||
return;
|
||||
|
||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||
|
||||
g.setColor( color );
|
||||
|
||||
float lineWidth = UIScale.scale( 1f );
|
||||
Path2D path = new Path2D.Float( Path2D.WIND_EVEN_ODD );
|
||||
path.append( new Rectangle2D.Float( x, y, width, height ), false );
|
||||
path.append( new Rectangle2D.Float( x + lineWidth, y, width - (lineWidth * 2), height - lineWidth ), false );
|
||||
((Graphics2D)g).fill( path );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets() {
|
||||
return new Insets( scale( top ), scale( left ), scale( bottom ), scale( right ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||
insets.left = scale( left );
|
||||
insets.top = scale( top );
|
||||
insets.right = scale( right );
|
||||
insets.bottom = scale( bottom );
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
|
||||
//---- class FlatPaneBorder -----------------------------------------------
|
||||
|
||||
private class FlatPaneBorder
|
||||
extends PaneBorder
|
||||
{
|
||||
@Override
|
||||
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
|
||||
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||
|
||||
super.paintBorder( c, g, x, y, width, height );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintTitleBackground( JXTaskPane group, Graphics g ) {
|
||||
int width = group.getWidth();
|
||||
int height = getTitleHeight( group ) ;
|
||||
float arc = UIScale.scale( (float) roundHeight );
|
||||
float lineWidth = UIScale.scale( 1f );
|
||||
|
||||
// paint background
|
||||
g.setColor( group.isSpecial() ? specialTitleBackground : titleBackgroundGradientStart );
|
||||
((Graphics2D)g).fill( FlatUIUtils.createRoundRectanglePath( lineWidth, lineWidth,
|
||||
width - (lineWidth * 2), height - (lineWidth * 2), arc - lineWidth, arc - lineWidth, 0, 0 ) );
|
||||
|
||||
// paint border
|
||||
if( borderColor != null ) {
|
||||
g.setColor( borderColor );
|
||||
((Graphics2D)g).fill( FlatUIUtils.createRoundRectangle( 0, 0, width, height, lineWidth, arc, arc, 0, 0 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintExpandedControls( JXTaskPane group, Graphics g, int x, int y, int width, int height ) {
|
||||
g.setColor( getPaintColor( group ) );
|
||||
paintChevronControls( group, g, x, y, width, height );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintChevronControls( JXTaskPane group, Graphics g, int x, int y, int width, int height ) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
|
||||
// scale chevron size
|
||||
float cw = scale( 6f );
|
||||
float ch = scale( 3f );
|
||||
|
||||
// create arrow shape
|
||||
int direction = group.isCollapsed() ? SwingConstants.SOUTH : SwingConstants.NORTH;
|
||||
Shape arrowShape = FlatArrowButton.createArrowShape( direction, true, cw, ch );
|
||||
|
||||
// fix position of controls
|
||||
x = group.getComponentOrientation().isLeftToRight() ? (group.getWidth() - width - y) : y;
|
||||
|
||||
// compute chevron position
|
||||
int cx = (int) (x + width / 2 - cw / 2);
|
||||
int cy = (int) (y + (height / 2 - ch));
|
||||
float offset = ch + UIScale.scale( 1f );
|
||||
|
||||
// set stroke with scaled width
|
||||
g2.setStroke( new BasicStroke( scale( 1f ) ) );
|
||||
|
||||
// paint
|
||||
g2.translate( cx, cy );
|
||||
g2.draw( arrowShape );
|
||||
g2.translate( 0, offset );
|
||||
g2.draw( arrowShape );
|
||||
g2.translate( -cx, -(cy + offset) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintTitle( JXTaskPane group, Graphics g, Color textColor,
|
||||
int x, int y, int width, int height )
|
||||
{
|
||||
// scale title position
|
||||
int titleX = UIScale.scale( 3 );
|
||||
int titleWidth = group.getWidth() - getTitleHeight(group) - titleX;
|
||||
if( !group.getComponentOrientation().isLeftToRight() ) {
|
||||
// right-to-left
|
||||
titleX = group.getWidth() - titleX - titleWidth;
|
||||
}
|
||||
|
||||
super.paintTitle( group, g, textColor, titleX, y, titleWidth, height );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintFocus( Graphics g, Color paintColor, int x, int y, int width, int height ) {
|
||||
// scale focus rectangle
|
||||
int sx = UIScale.scale( x );
|
||||
int sy = UIScale.scale( y );
|
||||
int swidth = width - (sx - x) * 2;
|
||||
int sheight = height - (sy - y) * 2;
|
||||
|
||||
super.paintFocus( g, paintColor, sx, sy, swidth, sheight );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isMouseOverBorder() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
com.formdev.flatlaf.swingx.FlatSwingXDefaultsAddon
|
||||
@@ -0,0 +1 @@
|
||||
com.formdev.flatlaf.swingx.FlatLookAndFeelAddons
|
||||
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# Copyright 2019 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
|
||||
#
|
||||
# http://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.
|
||||
#
|
||||
|
||||
#---- BusyLabel ----
|
||||
|
||||
JXBusyLabel.baseColor=777777
|
||||
JXBusyLabel.highlightColor=e0e0e0
|
||||
|
||||
|
||||
#---- Header ----
|
||||
|
||||
JXHeader.background=@background
|
||||
JXHeader.startBackground=4c5052
|
||||
|
||||
|
||||
#---- Hyperlink ----
|
||||
|
||||
Hyperlink.linkColor=589df6
|
||||
Hyperlink.visitedColor=@@Hyperlink.linkColor
|
||||
Hyperlink.disabledText=@disabledText
|
||||
|
||||
|
||||
#---- MonthView ----
|
||||
|
||||
JXMonthView.background=@textComponentBackground
|
||||
JXMonthView.monthStringBackground=4c5052
|
||||
JXMonthView.monthStringForeground=@foreground
|
||||
JXMonthView.daysOfTheWeekForeground=aaaaaa
|
||||
JXMonthView.weekOfTheYearForeground=888888
|
||||
JXMonthView.unselectableDayForeground=E05555
|
||||
JXMonthView.selectedBackground=@selectionBackground
|
||||
JXMonthView.flaggedDayForeground=E05555
|
||||
JXMonthView.leadingDayForeground=@disabledText
|
||||
JXMonthView.trailingDayForeground=@disabledText
|
||||
JXMonthView.arrowColor=@foreground
|
||||
JXMonthView.disabledArrowColor=@disabledText
|
||||
|
||||
|
||||
#---- TaskPaneContainer ----
|
||||
|
||||
TaskPaneContainer.background=3E434C
|
||||
TaskPaneContainer.border=10,10,10,10
|
||||
|
||||
|
||||
#---- TaskPane ----
|
||||
|
||||
TaskPane.background=@background
|
||||
TaskPane.borderColor=@@Button.borderColor
|
||||
TaskPane.contentInsets=10,10,10,10
|
||||
|
||||
TaskPane.titleBackgroundGradientStart=4c5052
|
||||
TaskPane.titleForeground=@foreground
|
||||
TaskPane.titleOver=888888
|
||||
TaskPane.specialTitleBackground=afafaf
|
||||
TaskPane.specialTitleForeground=222222
|
||||
TaskPane.specialTitleOver=666666
|
||||
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# Copyright 2019 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
|
||||
#
|
||||
# http://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.
|
||||
#
|
||||
|
||||
#---- UI delegates ----
|
||||
|
||||
BusyLabelUI=com.formdev.flatlaf.swingx.ui.FlatBusyLabelUI
|
||||
DatePickerUI=com.formdev.flatlaf.swingx.ui.FlatDatePickerUI
|
||||
HeaderUI=com.formdev.flatlaf.swingx.ui.FlatHeaderUI
|
||||
HyperlinkUI=com.formdev.flatlaf.swingx.ui.FlatHyperlinkUI
|
||||
MonthViewUI=com.formdev.flatlaf.swingx.ui.FlatMonthViewUI
|
||||
swingx/TaskPaneUI=com.formdev.flatlaf.swingx.ui.FlatTaskPaneUI
|
||||
|
||||
|
||||
#---- DatePicker ----
|
||||
|
||||
JXDatePicker.border=com.formdev.flatlaf.swingx.ui.FlatDatePickerBorder
|
||||
|
||||
|
||||
#---- MonthView ----
|
||||
|
||||
JXMonthView.monthDownFileName={icon}com.formdev.flatlaf.swingx.ui.FlatMonthDownIcon
|
||||
JXMonthView.monthUpFileName={icon}com.formdev.flatlaf.swingx.ui.FlatMonthUpIcon
|
||||
@@ -0,0 +1,69 @@
|
||||
#
|
||||
# Copyright 2019 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
|
||||
#
|
||||
# http://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.
|
||||
#
|
||||
|
||||
#---- BusyLabel ----
|
||||
|
||||
JXBusyLabel.baseColor=c4c4c4
|
||||
JXBusyLabel.highlightColor=808080
|
||||
|
||||
|
||||
#---- Header ----
|
||||
|
||||
JXHeader.background=@background
|
||||
JXHeader.startBackground=ffffff
|
||||
|
||||
|
||||
#---- Hyperlink ----
|
||||
|
||||
Hyperlink.linkColor=4a78c2
|
||||
Hyperlink.visitedColor=@@Hyperlink.linkColor
|
||||
Hyperlink.disabledText=@disabledText
|
||||
|
||||
|
||||
#---- MonthView ----
|
||||
|
||||
JXMonthView.background=@textComponentBackground
|
||||
JXMonthView.monthStringBackground=dfdfdf
|
||||
JXMonthView.monthStringForeground=@foreground
|
||||
JXMonthView.daysOfTheWeekForeground=444444
|
||||
JXMonthView.weekOfTheYearForeground=666666
|
||||
JXMonthView.unselectableDayForeground=E02222
|
||||
JXMonthView.selectedBackground=B9CEF8
|
||||
JXMonthView.flaggedDayForeground=E02222
|
||||
JXMonthView.leadingDayForeground=@disabledText
|
||||
JXMonthView.trailingDayForeground=@disabledText
|
||||
JXMonthView.arrowColor=@foreground
|
||||
JXMonthView.disabledArrowColor=@disabledText
|
||||
|
||||
|
||||
#---- TaskPaneContainer ----
|
||||
|
||||
TaskPaneContainer.background=E6EBF0
|
||||
TaskPaneContainer.border=10,10,10,10
|
||||
|
||||
|
||||
#---- TaskPane ----
|
||||
|
||||
TaskPane.background=@background
|
||||
TaskPane.borderColor=@@Button.borderColor
|
||||
TaskPane.contentInsets=10,10,10,10
|
||||
|
||||
TaskPane.titleBackgroundGradientStart=dfdfdf
|
||||
TaskPane.titleForeground=222222
|
||||
TaskPane.titleOver=666666
|
||||
TaskPane.specialTitleBackground=afafaf
|
||||
TaskPane.specialTitleForeground=222222
|
||||
TaskPane.specialTitleOver=666666
|
||||
@@ -0,0 +1,321 @@
|
||||
/*
|
||||
* Copyright 2019 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
|
||||
*
|
||||
* http://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.swingx;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import javax.swing.*;
|
||||
import net.miginfocom.swing.*;
|
||||
import org.jdesktop.swingx.*;
|
||||
import com.formdev.flatlaf.FlatTestFrame;
|
||||
|
||||
/**
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
public class FlatSwingXTest
|
||||
extends JPanel
|
||||
{
|
||||
public static void main( String[] args ) {
|
||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatSwingXTest" );
|
||||
frame.showFrame( new FlatSwingXTest() );
|
||||
}
|
||||
|
||||
FlatSwingXTest() {
|
||||
initComponents();
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
|
||||
calendar.set( Calendar.DAY_OF_MONTH, 2 );
|
||||
monthView1.setSelectionDate( calendar.getTime() );
|
||||
|
||||
calendar.set( Calendar.DAY_OF_MONTH, 9 );
|
||||
monthView1.setFlaggedDates( calendar.getTime() );
|
||||
|
||||
calendar.set( Calendar.DAY_OF_MONTH, 16 );
|
||||
monthView1.setUnselectableDates( calendar.getTime() );
|
||||
}
|
||||
|
||||
private void busyChanged() {
|
||||
boolean busy = busyCheckBox.isSelected();
|
||||
xBusyLabel1.setBusy( busy );
|
||||
xBusyLabel2.setBusy( busy );
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
JLabel label1 = new JLabel();
|
||||
JLabel label3 = new JLabel();
|
||||
JLabel datePickerLabel = new JLabel();
|
||||
JXDatePicker xDatePicker1 = new JXDatePicker();
|
||||
JXDatePicker xDatePicker2 = new JXDatePicker();
|
||||
JLabel label4 = new JLabel();
|
||||
JLabel label5 = new JLabel();
|
||||
JXDatePicker xDatePicker3 = new JXDatePicker();
|
||||
JXDatePicker xDatePicker4 = new JXDatePicker();
|
||||
JLabel monthViewLabel = new JLabel();
|
||||
monthView1 = new JXMonthView();
|
||||
monthView2 = new JXMonthView();
|
||||
JLabel hyperlinkLabel = new JLabel();
|
||||
JXHyperlink xHyperlink1 = new JXHyperlink();
|
||||
JXHyperlink xHyperlink2 = new JXHyperlink();
|
||||
JLabel label2 = new JLabel();
|
||||
xBusyLabel1 = new JXBusyLabel();
|
||||
xBusyLabel2 = new JXBusyLabel();
|
||||
busyCheckBox = new JCheckBox();
|
||||
JPanel panel2 = new JPanel();
|
||||
JLabel taskPaneContainerLabel = new JLabel();
|
||||
JLabel taskPaneLabel = new JLabel();
|
||||
JScrollPane scrollPane1 = new JScrollPane();
|
||||
JXTaskPaneContainer xTaskPaneContainer1 = new JXTaskPaneContainer();
|
||||
JXTaskPane xTaskPane3 = new JXTaskPane();
|
||||
JXHyperlink xHyperlink3 = new JXHyperlink();
|
||||
JXHyperlink xHyperlink4 = new JXHyperlink();
|
||||
JXHyperlink xHyperlink5 = new JXHyperlink();
|
||||
JXTaskPane xTaskPane4 = new JXTaskPane();
|
||||
JXHyperlink xHyperlink6 = new JXHyperlink();
|
||||
JXHyperlink xHyperlink7 = new JXHyperlink();
|
||||
JXTaskPane xTaskPane5 = new JXTaskPane();
|
||||
JXHyperlink xHyperlink8 = new JXHyperlink();
|
||||
JXTaskPane xTaskPane6 = new JXTaskPane();
|
||||
JXHyperlink xHyperlink9 = new JXHyperlink();
|
||||
JXHyperlink xHyperlink10 = new JXHyperlink();
|
||||
JLabel headerLabel = new JLabel();
|
||||
JXHeader xHeader1 = new JXHeader();
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
"hidemode 3,ltr",
|
||||
// columns
|
||||
"[left]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]0" +
|
||||
"[]" +
|
||||
"[]0" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- label1 ----
|
||||
label1.setText("enabled");
|
||||
add(label1, "cell 1 0");
|
||||
|
||||
//---- label3 ----
|
||||
label3.setText("disabled");
|
||||
add(label3, "cell 2 0");
|
||||
|
||||
//---- datePickerLabel ----
|
||||
datePickerLabel.setText("JXDatePicker:");
|
||||
add(datePickerLabel, "cell 0 1");
|
||||
add(xDatePicker1, "cell 1 1");
|
||||
|
||||
//---- xDatePicker2 ----
|
||||
xDatePicker2.setEnabled(false);
|
||||
add(xDatePicker2, "cell 2 1");
|
||||
|
||||
//---- label4 ----
|
||||
label4.setText("not editable");
|
||||
add(label4, "cell 1 2");
|
||||
|
||||
//---- label5 ----
|
||||
label5.setText("not editable disabled");
|
||||
add(label5, "cell 2 2");
|
||||
|
||||
//---- xDatePicker3 ----
|
||||
xDatePicker3.setEditable(false);
|
||||
add(xDatePicker3, "cell 1 3");
|
||||
|
||||
//---- xDatePicker4 ----
|
||||
xDatePicker4.setEnabled(false);
|
||||
xDatePicker4.setEditable(false);
|
||||
add(xDatePicker4, "cell 2 3");
|
||||
|
||||
//---- monthViewLabel ----
|
||||
monthViewLabel.setText("JXMonthView:");
|
||||
add(monthViewLabel, "cell 0 4,aligny top,growy 0");
|
||||
|
||||
//---- monthView1 ----
|
||||
monthView1.setTraversable(true);
|
||||
monthView1.setShowingLeadingDays(true);
|
||||
monthView1.setShowingTrailingDays(true);
|
||||
monthView1.setShowingWeekNumber(true);
|
||||
add(monthView1, "cell 1 4");
|
||||
|
||||
//---- monthView2 ----
|
||||
monthView2.setTraversable(true);
|
||||
monthView2.setShowingLeadingDays(true);
|
||||
monthView2.setShowingTrailingDays(true);
|
||||
monthView2.setShowingWeekNumber(true);
|
||||
monthView2.setEnabled(false);
|
||||
add(monthView2, "cell 2 4");
|
||||
|
||||
//---- hyperlinkLabel ----
|
||||
hyperlinkLabel.setText("JXHyperlink:");
|
||||
add(hyperlinkLabel, "cell 0 5");
|
||||
|
||||
//---- xHyperlink1 ----
|
||||
xHyperlink1.setText("enabled");
|
||||
add(xHyperlink1, "cell 1 5");
|
||||
|
||||
//---- xHyperlink2 ----
|
||||
xHyperlink2.setText("disabled");
|
||||
xHyperlink2.setEnabled(false);
|
||||
add(xHyperlink2, "cell 2 5");
|
||||
|
||||
//---- label2 ----
|
||||
label2.setText("JXBusyLabel:");
|
||||
add(label2, "cell 0 6");
|
||||
|
||||
//---- xBusyLabel1 ----
|
||||
xBusyLabel1.setText("enabled");
|
||||
add(xBusyLabel1, "cell 1 6");
|
||||
|
||||
//---- xBusyLabel2 ----
|
||||
xBusyLabel2.setText("disabled");
|
||||
xBusyLabel2.setEnabled(false);
|
||||
add(xBusyLabel2, "cell 2 6,growx");
|
||||
|
||||
//---- busyCheckBox ----
|
||||
busyCheckBox.setText("busy");
|
||||
busyCheckBox.setMnemonic('B');
|
||||
busyCheckBox.addActionListener(e -> busyChanged());
|
||||
add(busyCheckBox, "cell 2 6");
|
||||
|
||||
//======== panel2 ========
|
||||
{
|
||||
panel2.setLayout(new MigLayout(
|
||||
"ltr,insets 0,hidemode 3",
|
||||
// columns
|
||||
"[fill]",
|
||||
// rows
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- taskPaneContainerLabel ----
|
||||
taskPaneContainerLabel.setText("JXTaskPaneContainer:");
|
||||
panel2.add(taskPaneContainerLabel, "cell 0 0");
|
||||
|
||||
//---- taskPaneLabel ----
|
||||
taskPaneLabel.setText("JXTaskPane:");
|
||||
panel2.add(taskPaneLabel, "cell 0 1");
|
||||
|
||||
//======== scrollPane1 ========
|
||||
{
|
||||
|
||||
//======== xTaskPaneContainer1 ========
|
||||
{
|
||||
|
||||
//======== xTaskPane3 ========
|
||||
{
|
||||
xTaskPane3.setTitle("Basic Tasks");
|
||||
Container xTaskPane3ContentPane = xTaskPane3.getContentPane();
|
||||
|
||||
//---- xHyperlink3 ----
|
||||
xHyperlink3.setText("New");
|
||||
xTaskPane3ContentPane.add(xHyperlink3);
|
||||
|
||||
//---- xHyperlink4 ----
|
||||
xHyperlink4.setText("Open");
|
||||
xTaskPane3ContentPane.add(xHyperlink4);
|
||||
|
||||
//---- xHyperlink5 ----
|
||||
xHyperlink5.setText("Save");
|
||||
xTaskPane3ContentPane.add(xHyperlink5);
|
||||
}
|
||||
xTaskPaneContainer1.add(xTaskPane3);
|
||||
|
||||
//======== xTaskPane4 ========
|
||||
{
|
||||
xTaskPane4.setTitle("Other Tasks");
|
||||
xTaskPane4.setIcon(UIManager.getIcon("Tree.closedIcon"));
|
||||
Container xTaskPane4ContentPane = xTaskPane4.getContentPane();
|
||||
|
||||
//---- xHyperlink6 ----
|
||||
xHyperlink6.setText("Duplicate");
|
||||
xTaskPane4ContentPane.add(xHyperlink6);
|
||||
|
||||
//---- xHyperlink7 ----
|
||||
xHyperlink7.setText("Delete");
|
||||
xTaskPane4ContentPane.add(xHyperlink7);
|
||||
}
|
||||
xTaskPaneContainer1.add(xTaskPane4);
|
||||
|
||||
//======== xTaskPane5 ========
|
||||
{
|
||||
xTaskPane5.setTitle("Special Tasks");
|
||||
xTaskPane5.setSpecial(true);
|
||||
Container xTaskPane5ContentPane = xTaskPane5.getContentPane();
|
||||
|
||||
//---- xHyperlink8 ----
|
||||
xHyperlink8.setText("Go to space");
|
||||
xTaskPane5ContentPane.add(xHyperlink8);
|
||||
}
|
||||
xTaskPaneContainer1.add(xTaskPane5);
|
||||
|
||||
//======== xTaskPane6 ========
|
||||
{
|
||||
xTaskPane6.setTitle("Collapsed");
|
||||
xTaskPane6.setCollapsed(true);
|
||||
Container xTaskPane6ContentPane = xTaskPane6.getContentPane();
|
||||
|
||||
//---- xHyperlink9 ----
|
||||
xHyperlink9.setText("text");
|
||||
xTaskPane6ContentPane.add(xHyperlink9);
|
||||
|
||||
//---- xHyperlink10 ----
|
||||
xHyperlink10.setText("text");
|
||||
xTaskPane6ContentPane.add(xHyperlink10);
|
||||
}
|
||||
xTaskPaneContainer1.add(xTaskPane6);
|
||||
}
|
||||
scrollPane1.setViewportView(xTaskPaneContainer1);
|
||||
}
|
||||
panel2.add(scrollPane1, "cell 0 2,width 150,height 350");
|
||||
}
|
||||
add(panel2, "cell 3 0 1 8,aligny top,growy 0");
|
||||
|
||||
//---- headerLabel ----
|
||||
headerLabel.setText("JXHeader:");
|
||||
add(headerLabel, "cell 0 7,aligny top,growy 0");
|
||||
|
||||
//---- xHeader1 ----
|
||||
xHeader1.setTitle("Title");
|
||||
xHeader1.setDescription("Description\nMore description");
|
||||
xHeader1.setIcon(new ImageIcon(getClass().getResource("/org/jdesktop/swingx/plaf/windows/resources/tipoftheday.png")));
|
||||
add(xHeader1, "cell 1 7 2 1,width 200");
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
|
||||
xDatePicker1.setDate( new Date() );
|
||||
xDatePicker2.setDate( new Date() );
|
||||
xDatePicker3.setDate( new Date() );
|
||||
xDatePicker4.setDate( new Date() );
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
private JXMonthView monthView1;
|
||||
private JXMonthView monthView2;
|
||||
private JXBusyLabel xBusyLabel1;
|
||||
private JXBusyLabel xBusyLabel2;
|
||||
private JCheckBox busyCheckBox;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" 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": "hidemode 3,ltr"
|
||||
"$columnConstraints": "[left][][][fill]"
|
||||
"$rowConstraints": "[]0[][]0[][][][][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label1"
|
||||
"text": "enabled"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label3"
|
||||
"text": "disabled"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "datePickerLabel"
|
||||
"text": "JXDatePicker:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
|
||||
name: "xDatePicker1"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 1"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
|
||||
name: "xDatePicker2"
|
||||
"enabled": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label4"
|
||||
"text": "not editable"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label5"
|
||||
"text": "not editable disabled"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 2"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
|
||||
name: "xDatePicker3"
|
||||
"editable": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 3"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXDatePicker" ) {
|
||||
name: "xDatePicker4"
|
||||
"enabled": false
|
||||
"editable": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 3"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "monthViewLabel"
|
||||
"text": "JXMonthView:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4,aligny top,growy 0"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXMonthView" ) {
|
||||
name: "monthView1"
|
||||
"traversable": true
|
||||
"showingLeadingDays": true
|
||||
"showingTrailingDays": true
|
||||
"showingWeekNumber": true
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 4"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXMonthView" ) {
|
||||
name: "monthView2"
|
||||
"traversable": true
|
||||
"showingLeadingDays": true
|
||||
"showingTrailingDays": true
|
||||
"showingWeekNumber": true
|
||||
"enabled": false
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "hyperlinkLabel"
|
||||
"text": "JXHyperlink:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink1"
|
||||
"text": "enabled"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 5"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink2"
|
||||
"text": "disabled"
|
||||
"enabled": false
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label2"
|
||||
"text": "JXBusyLabel:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 6"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXBusyLabel" ) {
|
||||
name: "xBusyLabel1"
|
||||
"text": "enabled"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 6"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXBusyLabel" ) {
|
||||
name: "xBusyLabel2"
|
||||
"text": "disabled"
|
||||
"enabled": false
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 6,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "busyCheckBox"
|
||||
"text": "busy"
|
||||
"mnemonic": 66
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "busyChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 6"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[][][]"
|
||||
"$layoutConstraints": "ltr,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "panel2"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "taskPaneContainerLabel"
|
||||
"text": "JXTaskPaneContainer:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "taskPaneLabel"
|
||||
"text": "JXTaskPane:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane1"
|
||||
add( new FormContainer( "org.jdesktop.swingx.JXTaskPaneContainer", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
|
||||
name: "xTaskPaneContainer1"
|
||||
add( new FormContainer( "org.jdesktop.swingx.JXTaskPane", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
|
||||
name: "xTaskPane3"
|
||||
"title": "Basic Tasks"
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink3"
|
||||
"text": "New"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink4"
|
||||
"text": "Open"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink5"
|
||||
"text": "Save"
|
||||
} )
|
||||
} )
|
||||
add( new FormContainer( "org.jdesktop.swingx.JXTaskPane", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
|
||||
name: "xTaskPane4"
|
||||
"title": "Other Tasks"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink6"
|
||||
"text": "Duplicate"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink7"
|
||||
"text": "Delete"
|
||||
} )
|
||||
} )
|
||||
add( new FormContainer( "org.jdesktop.swingx.JXTaskPane", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
|
||||
name: "xTaskPane5"
|
||||
"title": "Special Tasks"
|
||||
"special": true
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink8"
|
||||
"text": "Go to space"
|
||||
} )
|
||||
} )
|
||||
add( new FormContainer( "org.jdesktop.swingx.JXTaskPane", new FormLayoutManager( class com.jformdesigner.runtime.GenericIndexLayout ) ) {
|
||||
name: "xTaskPane6"
|
||||
"title": "Collapsed"
|
||||
"collapsed": true
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink9"
|
||||
"text": "text"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
|
||||
name: "xHyperlink10"
|
||||
"text": "text"
|
||||
} )
|
||||
} )
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2,width 150,height 350"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 0 1 8,aligny top,growy 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "headerLabel"
|
||||
"text": "JXHeader:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 7,aligny top,growy 0"
|
||||
} )
|
||||
add( new FormComponent( "org.jdesktop.swingx.JXHeader" ) {
|
||||
name: "xHeader1"
|
||||
"title": "Title"
|
||||
"description": "Description\nMore description"
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 0, "/org/jdesktop/swingx/plaf/windows/resources/tipoftheday.png" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 7 2 1,width 200"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 700, 600 )
|
||||
} )
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#
|
||||
# Copyright 2019 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
|
||||
#
|
||||
# http://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.
|
||||
#
|
||||
|
||||
#---- BusyLabel ----
|
||||
|
||||
JXBusyLabel.baseColor=00ff00
|
||||
JXBusyLabel.highlightColor=ff0000
|
||||
|
||||
|
||||
#---- Header ----
|
||||
|
||||
JXHeader.background=ff8888
|
||||
JXHeader.startBackground=ffcccc
|
||||
JXHeader.titleForeground=0000ff
|
||||
JXHeader.descriptionForeground=ff0000
|
||||
|
||||
|
||||
#---- Hyperlink ----
|
||||
|
||||
Hyperlink.linkColor=ff0000
|
||||
Hyperlink.visitedColor=0000ff
|
||||
Hyperlink.disabledText=000088
|
||||
|
||||
|
||||
#---- MonthView ----
|
||||
|
||||
JXMonthView.background=@textComponentBackground
|
||||
JXMonthView.monthStringBackground=00ff00
|
||||
JXMonthView.monthStringForeground=0000ff
|
||||
JXMonthView.daysOfTheWeekForeground=00ff00
|
||||
JXMonthView.weekOfTheYearForeground=0000ff
|
||||
JXMonthView.unselectableDayForeground=0000ff
|
||||
JXMonthView.selectedBackground=aaffaa
|
||||
JXMonthView.flaggedDayForeground=00ffff
|
||||
JXMonthView.leadingDayForeground=c0c0c0
|
||||
JXMonthView.trailingDayForeground=c0c0c0
|
||||
JXMonthView.arrowColor=0000ff
|
||||
JXMonthView.disabledArrowColor=ABABAB
|
||||
|
||||
|
||||
#---- TaskPaneContainer ----
|
||||
|
||||
TaskPaneContainer.background=ff8888
|
||||
TaskPaneContainer.border=10,10,10,10
|
||||
|
||||
|
||||
#---- TaskPane ----
|
||||
|
||||
TaskPane.background=00ff00
|
||||
TaskPane.borderColor=0000ff
|
||||
TaskPane.contentInsets=10,10,10,10
|
||||
|
||||
TaskPane.titleBackgroundGradientStart=ffff00
|
||||
TaskPane.titleForeground=ff00ff
|
||||
TaskPane.titleOver=0000aa
|
||||
TaskPane.specialTitleBackground=00ffff
|
||||
TaskPane.specialTitleForeground=444444
|
||||
TaskPane.specialTitleOver=dd0000
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
BIN
images/FlatDarkSwingXTest.png
Normal file
BIN
images/FlatDarkSwingXTest.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
BIN
images/FlatLightSwingXTest.png
Normal file
BIN
images/FlatLightSwingXTest.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@@ -17,4 +17,5 @@
|
||||
rootProject.name = "FlatLaf"
|
||||
|
||||
include( "flatlaf-core" )
|
||||
include( "flatlaf-swingx" )
|
||||
include( "flatlaf-demo" )
|
||||
|
||||
Reference in New Issue
Block a user