mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -06:00
Compare commits
69 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 | ||
|
|
2cfcd0facf | ||
|
|
b49eff348d | ||
|
|
42d801f123 | ||
|
|
5e33182de3 | ||
|
|
012d86066d | ||
|
|
ff510095a3 | ||
|
|
10283d022f | ||
|
|
d55abd1b00 | ||
|
|
87845fc6f5 | ||
|
|
340c0d647c | ||
|
|
49a574a8d7 | ||
|
|
9216997bba | ||
|
|
267567d0a0 | ||
|
|
230bc28ddd | ||
|
|
57c9ffc2ba | ||
|
|
d0ac7867ae | ||
|
|
b6cd31b734 | ||
|
|
8806cc8e93 | ||
|
|
2da0ca736f | ||
|
|
5288e0f54e | ||
|
|
c87f5cb05f | ||
|
|
17074eb16d | ||
|
|
43429ddc39 | ||
|
|
7ef598ded6 | ||
|
|
37c70f6c9e | ||
|
|
26a2446a4d | ||
|
|
771c949d74 | ||
|
|
23d448d4fc | ||
|
|
86577c5fef | ||
|
|
3a69b41646 | ||
|
|
2d26b6fa94 | ||
|
|
144f79f0f9 | ||
|
|
8ea23fc533 | ||
|
|
ae714502fb | ||
|
|
07d6755ddb | ||
|
|
177996ee81 | ||
|
|
3847b14033 | ||
|
|
423805be3a |
@@ -5,6 +5,7 @@ jdk:
|
|||||||
- openjdk8
|
- openjdk8
|
||||||
- openjdk9
|
- openjdk9
|
||||||
- openjdk11
|
- openjdk11
|
||||||
|
- openjdk13
|
||||||
|
|
||||||
before_cache:
|
before_cache:
|
||||||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
|
||||||
@@ -24,5 +25,5 @@ deploy:
|
|||||||
skip_cleanup: true # to upload artifacts created during the build
|
skip_cleanup: true # to upload artifacts created during the build
|
||||||
on:
|
on:
|
||||||
branch: master
|
branch: master
|
||||||
jdk: openjdk8
|
jdk: openjdk11
|
||||||
tags: true
|
tags: true
|
||||||
|
|||||||
59
CHANGELOG.md
59
CHANGELOG.md
@@ -1,6 +1,65 @@
|
|||||||
FlatLaf Change Log
|
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)
|
||||||
|
- Added `Flat*Laf.install()` methods.
|
||||||
|
- macOS: Use native screen menu bar if system property
|
||||||
|
`apple.laf.useScreenMenuBar` is `true`.
|
||||||
|
- Windows: Update fonts (and scaling) when user changes Windows text size
|
||||||
|
(Settings > Ease of Access > Display > Make text bigger).
|
||||||
|
|
||||||
|
|
||||||
|
## 0.11
|
||||||
|
|
||||||
|
- Changed Maven groupId to `com.formdev` and artifactId to `flatlaf`.
|
||||||
|
|
||||||
|
|
||||||
|
## 0.10
|
||||||
|
|
||||||
|
- Use new chevron arrows in "Flat Light" and "Flat Dark" themes, but keep
|
||||||
|
triangle arrows in "Flat IntelliJ" and "Flat Darcula" themes. (issue #7)
|
||||||
|
- Use bold font for default buttons in "Flat IntelliJ" and "Flat Darcula"
|
||||||
|
themes.
|
||||||
|
- Hide label, button and tab mnemonics by default and show them only when
|
||||||
|
<kbd>Alt</kbd> is pressed. (issue #4)
|
||||||
|
- If a JButton has an icon and no text, then it does not get a minimum width
|
||||||
|
(usually 72 pixel) and the left and right insets are same as top/bottom insets
|
||||||
|
so that it becomes square (if the icon is square).
|
||||||
|
- Changed styling of default button in "Flat Light" theme (wide blue border
|
||||||
|
instead of blue background).
|
||||||
|
- Added Java 9 module descriptor `module-info.class` to `flatlaf.jar` (in
|
||||||
|
`META-INF/versions/9`). But FlatLaf remains Java 8 compatible. (issue #1)
|
||||||
|
- Support specifying custom scale factor in system properties `flatlaf.uiScale`
|
||||||
|
or `sun.java2d.uiScale`. E.g. `-Dflatlaf.uiScale=1.5`. (Java 8 only)
|
||||||
|
|
||||||
|
|
||||||
## 0.9
|
## 0.9
|
||||||
|
|
||||||
- Initial release
|
- Initial release
|
||||||
|
|||||||
45
README.md
45
README.md
@@ -1,14 +1,15 @@
|
|||||||
FlatLaf - Flat Look and Feel
|
FlatLaf - Flat Look and Feel
|
||||||
============================
|
============================
|
||||||
|
|
||||||
**FlatLaf** is a modern open-source cross-platform Look and Feel for Java
|
**FlatLaf** is a modern **open-source** cross-platform Look and Feel for Java
|
||||||
desktop applications.
|
Swing desktop applications.
|
||||||
|
|
||||||
It is mostly "flat" (no shadows or gradients), clean, simple and elegant. It
|
It looks almost flat (no shadows or gradients), clean, simple and elegant.
|
||||||
comes with **Light** and **Dark** themes and is made for **HiDPI** displays.
|
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
|
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.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -18,19 +19,37 @@ IntelliJ IDEA 2019.2+ and uses mostly the same colors and icons.
|
|||||||
Demo
|
Demo
|
||||||
----
|
----
|
||||||
|
|
||||||
Download
|
[](https://download.formdev.com/flatlaf/flatlaf-demo-latest.jar)
|
||||||
[flatlaf-demo-0.1.jar](https://download.formdev.com/flatlaf/flatlaf-demo-0.1.jar)
|
|
||||||
and run it with `java -jar flatlaf-demo-0.1.jar` (or double-click it). Requires
|
Run demo with `java -jar flatlaf-demo-<version>.jar` (or double-click it).
|
||||||
Java 8 or newer.
|
Requires Java 8 or newer.
|
||||||
|
|
||||||
|
|
||||||
Download
|
Download
|
||||||
--------
|
--------
|
||||||
|
|
||||||
Coming soon
|
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)
|
||||||
|
|
||||||
|
|
||||||
License
|
Addons
|
||||||
-------
|
------
|
||||||
|
|
||||||
FlatLaf is open source licensed under the [Apache 2.0 License](LICENSE)
|
- [SwingX](flatlaf-swingx)
|
||||||
|
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
-------------
|
||||||
|
|
||||||
|
For more information and documentation visit
|
||||||
|
[FlatLaf Home](https://www.formdev.com/flatlaf/)
|
||||||
|
|||||||
@@ -14,7 +14,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
version = "0.9"
|
version = "0.15"
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check required Java version
|
// check required Java version
|
||||||
if( JavaVersion.current() < JavaVersion.VERSION_1_8 )
|
if( JavaVersion.current() < JavaVersion.VERSION_1_8 )
|
||||||
|
|||||||
@@ -22,8 +22,16 @@ plugins {
|
|||||||
id( "com.jfrog.bintray" ) version "1.8.4"
|
id( "com.jfrog.bintray" ) version "1.8.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
if( JavaVersion.current() >= JavaVersion.VERSION_1_9 ) {
|
||||||
jcenter()
|
sourceSets {
|
||||||
|
create( "module-info" ) {
|
||||||
|
java {
|
||||||
|
// include "src/main/java" here to get compile errors if classes are
|
||||||
|
// used from other modules that are not specified in module dependencies
|
||||||
|
setSrcDirs( listOf( "src/main/module-info", "src/main/java" ) )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -37,8 +45,26 @@ java {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
if( JavaVersion.current() >= JavaVersion.VERSION_1_9 ) {
|
||||||
|
named<JavaCompile>( "compileModuleInfoJava" ) {
|
||||||
|
sourceCompatibility = "9"
|
||||||
|
targetCompatibility = "9"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
archiveBaseName.set( "flatlaf" )
|
archiveBaseName.set( "flatlaf" )
|
||||||
|
|
||||||
|
if( JavaVersion.current() >= JavaVersion.VERSION_1_9 ) {
|
||||||
|
manifest.attributes(
|
||||||
|
"Multi-Release" to "true"
|
||||||
|
)
|
||||||
|
|
||||||
|
into( "META-INF/versions/9" ) {
|
||||||
|
from( sourceSets["module-info"].output )
|
||||||
|
include( "module-info.class" )
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
@@ -62,13 +88,26 @@ tasks {
|
|||||||
|
|
||||||
from( javadoc )
|
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 {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
create<MavenPublication>( "maven" ) {
|
create<MavenPublication>( "maven" ) {
|
||||||
artifactId = "flatlaf-core"
|
artifactId = "flatlaf"
|
||||||
groupId = "com.formdev.flatlaf"
|
groupId = "com.formdev"
|
||||||
|
|
||||||
from( components["java"] )
|
from( components["java"] )
|
||||||
|
|
||||||
@@ -87,6 +126,14 @@ publishing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
name.set( "Karl Tauber" )
|
||||||
|
organization.set( "FormDev Software GmbH" )
|
||||||
|
organizationUrl.set( "https://www.formdev.com/" )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
url.set( "https://github.com/JFormDesigner/FlatLaf" )
|
url.set( "https://github.com/JFormDesigner/FlatLaf" )
|
||||||
}
|
}
|
||||||
@@ -103,7 +150,7 @@ bintray {
|
|||||||
|
|
||||||
with( pkg ) {
|
with( pkg ) {
|
||||||
repo = "flatlaf"
|
repo = "flatlaf"
|
||||||
name = "flatlaf-core"
|
name = "flatlaf"
|
||||||
setLicenses( "Apache-2.0" )
|
setLicenses( "Apache-2.0" )
|
||||||
vcsUrl = "https://github.com/JFormDesigner/FlatLaf"
|
vcsUrl = "https://github.com/JFormDesigner/FlatLaf"
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ package com.formdev.flatlaf;
|
|||||||
public class FlatDarculaLaf
|
public class FlatDarculaLaf
|
||||||
extends FlatDarkLaf
|
extends FlatDarkLaf
|
||||||
{
|
{
|
||||||
|
public static boolean install( ) {
|
||||||
|
return install( new FlatDarculaLaf() );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Flat Darcula";
|
return "Flat Darcula";
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ package com.formdev.flatlaf;
|
|||||||
public class FlatDarkLaf
|
public class FlatDarkLaf
|
||||||
extends FlatLaf
|
extends FlatLaf
|
||||||
{
|
{
|
||||||
|
public static boolean install( ) {
|
||||||
|
return install( new FlatDarkLaf() );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Flat Dark";
|
return "Flat Dark";
|
||||||
|
|||||||
@@ -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 );
|
||||||
|
}
|
||||||
@@ -24,6 +24,10 @@ package com.formdev.flatlaf;
|
|||||||
public class FlatIntelliJLaf
|
public class FlatIntelliJLaf
|
||||||
extends FlatLightLaf
|
extends FlatLightLaf
|
||||||
{
|
{
|
||||||
|
public static boolean install( ) {
|
||||||
|
return install( new FlatIntelliJLaf() );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Flat IntelliJ";
|
return "Flat IntelliJ";
|
||||||
|
|||||||
@@ -17,19 +17,37 @@
|
|||||||
package com.formdev.flatlaf;
|
package com.formdev.flatlaf;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.EventQueue;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.KeyEventPostProcessor;
|
||||||
|
import java.awt.KeyboardFocusManager;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.Window;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.beans.PropertyChangeListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.ServiceLoader;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
import javax.swing.AbstractButton;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.LookAndFeel;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIDefaults;
|
import javax.swing.UIDefaults;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
import javax.swing.UIDefaults.LazyValue;
|
import javax.swing.UIDefaults.LazyValue;
|
||||||
import javax.swing.plaf.ColorUIResource;
|
import javax.swing.plaf.ColorUIResource;
|
||||||
import javax.swing.plaf.DimensionUIResource;
|
import javax.swing.plaf.DimensionUIResource;
|
||||||
@@ -41,6 +59,7 @@ import com.formdev.flatlaf.ui.FlatEmptyBorder;
|
|||||||
import com.formdev.flatlaf.ui.FlatLineBorder;
|
import com.formdev.flatlaf.ui.FlatLineBorder;
|
||||||
import com.formdev.flatlaf.util.ScaledNumber;
|
import com.formdev.flatlaf.util.ScaledNumber;
|
||||||
import com.formdev.flatlaf.util.SystemInfo;
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base class for all Flat LaFs.
|
* The base class for all Flat LaFs.
|
||||||
@@ -50,6 +69,8 @@ import com.formdev.flatlaf.util.SystemInfo;
|
|||||||
public abstract class FlatLaf
|
public abstract class FlatLaf
|
||||||
extends BasicLookAndFeel
|
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 VARIABLE_PREFIX = "@";
|
||||||
private static final String REF_PREFIX = VARIABLE_PREFIX + "@";
|
private static final String REF_PREFIX = VARIABLE_PREFIX + "@";
|
||||||
private static final String OPTIONAL_PREFIX = "?";
|
private static final String OPTIONAL_PREFIX = "?";
|
||||||
@@ -57,6 +78,22 @@ public abstract class FlatLaf
|
|||||||
|
|
||||||
private BasicLookAndFeel base;
|
private BasicLookAndFeel base;
|
||||||
|
|
||||||
|
private String desktopPropertyName;
|
||||||
|
private PropertyChangeListener desktopPropertyListener;
|
||||||
|
|
||||||
|
private KeyEventPostProcessor mnemonicListener;
|
||||||
|
private static boolean altKeyPressed;
|
||||||
|
|
||||||
|
public static boolean install( LookAndFeel newLookAndFeel ) {
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel( newLookAndFeel );
|
||||||
|
return true;
|
||||||
|
} catch( Exception ex ) {
|
||||||
|
System.err.println( "Failed to initialize look and feel " + newLookAndFeel.getClass().getName() );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getID() {
|
public String getID() {
|
||||||
return getName();
|
return getName();
|
||||||
@@ -77,10 +114,49 @@ public abstract class FlatLaf
|
|||||||
getBase().initialize();
|
getBase().initialize();
|
||||||
|
|
||||||
super.initialize();
|
super.initialize();
|
||||||
|
|
||||||
|
// add mnemonic listener
|
||||||
|
mnemonicListener = e -> {
|
||||||
|
if( e.getKeyCode() == KeyEvent.VK_ALT )
|
||||||
|
altKeyChanged( e.getID() == KeyEvent.KEY_PRESSED );
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor( mnemonicListener );
|
||||||
|
|
||||||
|
// listen to desktop property changes to update UI if system font or scaling changes
|
||||||
|
if( SystemInfo.IS_WINDOWS ) {
|
||||||
|
// Windows 10 allows increasing font size independent of scaling:
|
||||||
|
// Settings > Ease of Access > Display > Make text bigger (100% - 225%)
|
||||||
|
desktopPropertyName = "win.messagebox.font";
|
||||||
|
} else if( SystemInfo.IS_LINUX ) {
|
||||||
|
// Linux/Gnome allows extra scaling and larger text:
|
||||||
|
// Settings > Devices > Displays > Scale (100% or 200%)
|
||||||
|
// Settings > Universal access > Large Text (off or on, 125%)
|
||||||
|
desktopPropertyName = "gnome.Xft/DPI";
|
||||||
|
}
|
||||||
|
if( desktopPropertyName != null ) {
|
||||||
|
desktopPropertyListener = e -> {
|
||||||
|
reSetLookAndFeel();
|
||||||
|
};
|
||||||
|
Toolkit.getDefaultToolkit().addPropertyChangeListener( desktopPropertyName, desktopPropertyListener );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void uninitialize() {
|
public void uninitialize() {
|
||||||
|
// remove desktop property listener
|
||||||
|
if( desktopPropertyListener != null ) {
|
||||||
|
Toolkit.getDefaultToolkit().removePropertyChangeListener( desktopPropertyName, desktopPropertyListener );
|
||||||
|
desktopPropertyName = null;
|
||||||
|
desktopPropertyListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove mnemonic listener
|
||||||
|
if( mnemonicListener != null ) {
|
||||||
|
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventPostProcessor( mnemonicListener );
|
||||||
|
mnemonicListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
if( base != null )
|
if( base != null )
|
||||||
base.uninitialize();
|
base.uninitialize();
|
||||||
|
|
||||||
@@ -128,9 +204,17 @@ public abstract class FlatLaf
|
|||||||
defaults.put( "Spinner.disabledBackground", control );
|
defaults.put( "Spinner.disabledBackground", control );
|
||||||
defaults.put( "Spinner.disabledForeground", control );
|
defaults.put( "Spinner.disabledForeground", control );
|
||||||
|
|
||||||
|
// remember MenuBarUI from Mac Aqua LaF if Mac screen menubar is enabled
|
||||||
|
boolean useScreenMenuBar = SystemInfo.IS_MAC && "true".equals( System.getProperty( "apple.laf.useScreenMenuBar" ) );
|
||||||
|
Object aquaMenuBarUI = useScreenMenuBar ? defaults.get( "MenuBarUI" ) : null;
|
||||||
|
|
||||||
initFonts( defaults );
|
initFonts( defaults );
|
||||||
loadDefaultsFromProperties( defaults );
|
loadDefaultsFromProperties( defaults );
|
||||||
|
|
||||||
|
// use Aqua MenuBarUI if Mac screen menubar is enabled
|
||||||
|
if( useScreenMenuBar )
|
||||||
|
defaults.put( "MenuBarUI", aquaMenuBarUI );
|
||||||
|
|
||||||
return defaults;
|
return defaults;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,12 +237,15 @@ public abstract class FlatLaf
|
|||||||
uiFont = (font instanceof FontUIResource) ? (FontUIResource) font : new FontUIResource( font );
|
uiFont = (font instanceof FontUIResource) ? (FontUIResource) font : new FontUIResource( font );
|
||||||
|
|
||||||
} else if( SystemInfo.IS_LINUX ) {
|
} else if( SystemInfo.IS_LINUX ) {
|
||||||
System.err.println( "WARNING: FlatLaf is not yet tested on Linux!" );
|
Font font = LinuxFontPolicy.getFont();
|
||||||
|
uiFont = (font instanceof FontUIResource) ? (FontUIResource) font : new FontUIResource( font );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( uiFont == null )
|
if( uiFont == null )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
uiFont = UIScale.applyCustomScaleFactor( uiFont );
|
||||||
|
|
||||||
// override fonts
|
// override fonts
|
||||||
for( Object key : defaults.keySet() ) {
|
for( Object key : defaults.keySet() ) {
|
||||||
if( key instanceof String && ((String)key).endsWith( ".font" ) )
|
if( key instanceof String && ((String)key).endsWith( ".font" ) )
|
||||||
@@ -189,12 +276,22 @@ public abstract class FlatLaf
|
|||||||
try {
|
try {
|
||||||
// load properties files
|
// load properties files
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
ServiceLoader<FlatDefaultsAddon> addonLoader = ServiceLoader.load( FlatDefaultsAddon.class );
|
||||||
for( Class<?> lafClass : lafClasses ) {
|
for( Class<?> lafClass : lafClasses ) {
|
||||||
|
// load core properties
|
||||||
String propertiesName = "/" + lafClass.getName().replace( '.', '/' ) + ".properties";
|
String propertiesName = "/" + lafClass.getName().replace( '.', '/' ) + ".properties";
|
||||||
try( InputStream in = lafClass.getResourceAsStream( propertiesName ) ) {
|
try( InputStream in = lafClass.getResourceAsStream( propertiesName ) ) {
|
||||||
if( in != null )
|
if( in != null )
|
||||||
properties.load( in );
|
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 -> {
|
Function<String, String> resolver = value -> {
|
||||||
@@ -262,6 +359,8 @@ public abstract class FlatLaf
|
|||||||
return resolveValue( properties, newValue );
|
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 ) {
|
private Object parseValue( String key, String value, Function<String, String> resolver ) {
|
||||||
value = value.trim();
|
value = value.trim();
|
||||||
|
|
||||||
@@ -272,32 +371,51 @@ public abstract class FlatLaf
|
|||||||
case "true": return true;
|
case "true": return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// borders
|
ValueType valueType = ValueType.UNKNOWN;
|
||||||
|
|
||||||
|
// 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 ) );
|
||||||
|
|
||||||
|
// remove type from value
|
||||||
|
value = value.substring( end + TYPE_PREFIX_END.length() );
|
||||||
|
} catch( IllegalArgumentException ex ) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine value type from key
|
||||||
|
if( valueType == ValueType.UNKNOWN ) {
|
||||||
if( key.endsWith( ".border" ) || key.endsWith( "Border" ) )
|
if( key.endsWith( ".border" ) || key.endsWith( "Border" ) )
|
||||||
return parseBorder( value, resolver );
|
valueType = ValueType.BORDER;
|
||||||
|
else if( key.endsWith( ".icon" ) || key.endsWith( "Icon" ) )
|
||||||
// icons
|
valueType = ValueType.ICON;
|
||||||
if( key.endsWith( ".icon" ) || key.endsWith( "Icon" ) )
|
else if( key.endsWith( ".margin" ) || key.endsWith( ".padding" ) ||
|
||||||
return parseInstance( value );
|
|
||||||
|
|
||||||
// insets
|
|
||||||
if( key.endsWith( ".margin" ) || key.endsWith( ".padding" ) ||
|
|
||||||
key.endsWith( "Margins" ) || key.endsWith( "Insets" ) )
|
key.endsWith( "Margins" ) || key.endsWith( "Insets" ) )
|
||||||
return parseInsets( value );
|
valueType = ValueType.INSETS;
|
||||||
|
else if( key.endsWith( "Size" ) )
|
||||||
// size
|
valueType = ValueType.SIZE;
|
||||||
if( key.endsWith( "Size" ) && !key.equals( "SplitPane.dividerSize" ))
|
else if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
||||||
return parseSize( value );
|
valueType = ValueType.INTEGER;
|
||||||
|
}
|
||||||
// scaled number
|
|
||||||
ScaledNumber scaledNumber = parseScaledNumber( key, value );
|
|
||||||
if( scaledNumber != null )
|
|
||||||
return scaledNumber;
|
|
||||||
|
|
||||||
// width, height
|
|
||||||
if( key.endsWith( "Width" ) || key.endsWith( "Height" ) )
|
|
||||||
return parseInteger( value, true );
|
|
||||||
|
|
||||||
|
// 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
|
// colors
|
||||||
ColorUIResource color = parseColor( value, false );
|
ColorUIResource color = parseColor( value, false );
|
||||||
if( color != null )
|
if( color != null )
|
||||||
@@ -311,6 +429,7 @@ public abstract class FlatLaf
|
|||||||
// string
|
// string
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Object parseBorder( String value, Function<String, String> resolver ) {
|
private Object parseBorder( String value, Function<String, String> resolver ) {
|
||||||
if( value.indexOf( ',' ) >= 0 ) {
|
if( value.indexOf( ',' ) >= 0 ) {
|
||||||
@@ -399,10 +518,7 @@ public abstract class FlatLaf
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScaledNumber parseScaledNumber( String key, String value ) {
|
private ScaledNumber parseScaledNumber( String value ) {
|
||||||
if( !key.equals( "OptionPane.buttonMinimumWidth" ) )
|
|
||||||
return null; // not supported
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new ScaledNumber( Integer.parseInt( value ) );
|
return new ScaledNumber( Integer.parseInt( value ) );
|
||||||
} catch( NumberFormatException ex ) {
|
} catch( NumberFormatException ex ) {
|
||||||
@@ -424,4 +540,90 @@ public abstract class FlatLaf
|
|||||||
|
|
||||||
return strs;
|
return strs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void reSetLookAndFeel() {
|
||||||
|
EventQueue.invokeLater( () -> {
|
||||||
|
try {
|
||||||
|
// re-set current LaF
|
||||||
|
LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
|
||||||
|
UIManager.setLookAndFeel( lookAndFeel );
|
||||||
|
|
||||||
|
// must fire property change events ourself because old and new LaF are the same
|
||||||
|
PropertyChangeEvent e = new PropertyChangeEvent( UIManager.class, "lookAndFeel", lookAndFeel, lookAndFeel );
|
||||||
|
for( PropertyChangeListener l : UIManager.getPropertyChangeListeners() )
|
||||||
|
l.propertyChange( e );
|
||||||
|
|
||||||
|
// update UI
|
||||||
|
updateUI();
|
||||||
|
} catch( UnsupportedLookAndFeelException ex ) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update UI of all application windows.
|
||||||
|
* Invoke after changing LaF.
|
||||||
|
*/
|
||||||
|
public static void updateUI() {
|
||||||
|
for( Window w : Window.getWindows() )
|
||||||
|
SwingUtilities.updateComponentTreeUI( w );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isShowMnemonics() {
|
||||||
|
return altKeyPressed || !UIManager.getBoolean( "Component.hideMnemonics" );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void altKeyChanged( boolean pressed ) {
|
||||||
|
if( pressed == altKeyPressed )
|
||||||
|
return;
|
||||||
|
|
||||||
|
altKeyPressed = pressed;
|
||||||
|
|
||||||
|
// check whether it is necessary to repaint
|
||||||
|
if( !UIManager.getBoolean( "Component.hideMnemonics" ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// get focus owner
|
||||||
|
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||||
|
if( focusOwner == null )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// get focused window
|
||||||
|
Window window = SwingUtilities.windowForComponent( focusOwner );
|
||||||
|
if( window == null )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// repaint components with mnemonics in focused window
|
||||||
|
repaintMnemonics( window );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void repaintMnemonics( Container container ) {
|
||||||
|
for( Component c : container.getComponents() ) {
|
||||||
|
if( hasMnemonic( c ) )
|
||||||
|
c.repaint();
|
||||||
|
|
||||||
|
if( c instanceof Container )
|
||||||
|
repaintMnemonics( (Container) c );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean hasMnemonic( Component c ) {
|
||||||
|
if( c instanceof JLabel && ((JLabel)c).getDisplayedMnemonicIndex() >= 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if( c instanceof AbstractButton && ((AbstractButton)c).getDisplayedMnemonicIndex() >= 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if( c instanceof JTabbedPane ) {
|
||||||
|
JTabbedPane tabPane = (JTabbedPane) c;
|
||||||
|
int tabCount = tabPane.getTabCount();
|
||||||
|
for( int i = 0; i < tabCount; i++ ) {
|
||||||
|
if( tabPane.getDisplayedMnemonicIndexAt( i ) >= 0 )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ package com.formdev.flatlaf;
|
|||||||
public class FlatLightLaf
|
public class FlatLightLaf
|
||||||
extends FlatLaf
|
extends FlatLaf
|
||||||
{
|
{
|
||||||
|
public static boolean install( ) {
|
||||||
|
return install( new FlatLightLaf() );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Flat Light";
|
return "Flat Light";
|
||||||
|
|||||||
@@ -0,0 +1,248 @@
|
|||||||
|
/*
|
||||||
|
* 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.awt.Font;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
import javax.swing.text.StyleContext;
|
||||||
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
class LinuxFontPolicy
|
||||||
|
{
|
||||||
|
static Font getFont() {
|
||||||
|
return SystemInfo.IS_KDE ? getKDEFont() : getGnomeFont();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default font for Gnome.
|
||||||
|
*/
|
||||||
|
private static Font getGnomeFont() {
|
||||||
|
// see class com.sun.java.swing.plaf.gtk.PangoFonts background information
|
||||||
|
|
||||||
|
Object fontName = Toolkit.getDefaultToolkit().getDesktopProperty( "gnome.Gtk/FontName" );
|
||||||
|
if( !(fontName instanceof String) )
|
||||||
|
fontName = "sans 10";
|
||||||
|
|
||||||
|
String family = "";
|
||||||
|
int style = Font.PLAIN;
|
||||||
|
int size = 10;
|
||||||
|
|
||||||
|
StringTokenizer st = new StringTokenizer( (String) fontName );
|
||||||
|
while( st.hasMoreTokens() ) {
|
||||||
|
String word = st.nextToken();
|
||||||
|
|
||||||
|
if( word.equalsIgnoreCase( "italic" ) )
|
||||||
|
style |= Font.ITALIC;
|
||||||
|
else if( word.equalsIgnoreCase( "bold" ) )
|
||||||
|
style |= Font.BOLD;
|
||||||
|
else if( Character.isDigit( word.charAt( 0 ) ) ) {
|
||||||
|
try {
|
||||||
|
size = Integer.parseInt( word );
|
||||||
|
} catch( NumberFormatException ex ) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
family = family.isEmpty() ? word : (family + ' ' + word);
|
||||||
|
}
|
||||||
|
|
||||||
|
// scale font size
|
||||||
|
double dsize = size * getGnomeFontScale();
|
||||||
|
size = (int) (dsize + 0.5);
|
||||||
|
if( size < 1 )
|
||||||
|
size = 1;
|
||||||
|
|
||||||
|
// handle logical font names
|
||||||
|
String logicalFamily = mapFcName( family.toLowerCase() );
|
||||||
|
if( logicalFamily != null )
|
||||||
|
family = logicalFamily;
|
||||||
|
|
||||||
|
return createFont( family, style, size, dsize );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Font createFont( String family, int style, int size, double dsize ) {
|
||||||
|
// using StyleContext.getFont() here because it uses
|
||||||
|
// sun.font.FontUtilities.getCompositeFontUIResource()
|
||||||
|
Font font = new StyleContext().getFont( family, style, size );
|
||||||
|
|
||||||
|
// set font size in floating points
|
||||||
|
font = font.deriveFont( style, (float) dsize );
|
||||||
|
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double getGnomeFontScale() {
|
||||||
|
// see class com.sun.java.swing.plaf.gtk.PangoFonts background information
|
||||||
|
|
||||||
|
Object value = Toolkit.getDefaultToolkit().getDesktopProperty( "gnome.Xft/DPI" );
|
||||||
|
if( value instanceof Integer ) {
|
||||||
|
int dpi = ((Integer)value).intValue() / 1024;
|
||||||
|
if( dpi == -1 )
|
||||||
|
dpi = 96;
|
||||||
|
if( dpi < 50 )
|
||||||
|
dpi = 50;
|
||||||
|
return dpi / 72.0;
|
||||||
|
} else {
|
||||||
|
return GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||||
|
.getDefaultScreenDevice().getDefaultConfiguration()
|
||||||
|
.getNormalizingTransform().getScaleY();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* map GTK/fontconfig names to equivalent JDK logical font name
|
||||||
|
*/
|
||||||
|
private static String mapFcName( String name ) {
|
||||||
|
switch( name ) {
|
||||||
|
case "sans": return "sansserif";
|
||||||
|
case "sans-serif": return "sansserif";
|
||||||
|
case "serif": return "serif";
|
||||||
|
case "monospace": return "monospaced";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default font for KDE for KDE configuration files.
|
||||||
|
*
|
||||||
|
* The Swing fonts are not updated when the user changes system font size
|
||||||
|
* (System Settings > Fonts > Force Font DPI). A application restart is necessary.
|
||||||
|
* This is the same behavior as in native KDE applications.
|
||||||
|
*
|
||||||
|
* The "display scale factor" (kdeglobals: [KScreen] > ScaleFactor) is not used
|
||||||
|
* KDE also does not use it to calculate font size. Only forceFontDPI is used by KDE.
|
||||||
|
* If user changes "display scale factor" (System Settings > Display and Monitors >
|
||||||
|
* Displays > Scale Display), the forceFontDPI is also changed to reflect the scale factor.
|
||||||
|
*/
|
||||||
|
private static Font getKDEFont() {
|
||||||
|
List<String> kdeglobals = readConfig( "kdeglobals" );
|
||||||
|
List<String> kcmfonts = readConfig( "kcmfonts" );
|
||||||
|
|
||||||
|
String generalFont = getConfigEntry( kdeglobals, "General", "font" );
|
||||||
|
String forceFontDPI = getConfigEntry( kcmfonts, "General", "forceFontDPI" );
|
||||||
|
|
||||||
|
String family = "sansserif";
|
||||||
|
int style = Font.PLAIN;
|
||||||
|
int size = 10;
|
||||||
|
|
||||||
|
if( generalFont != null ) {
|
||||||
|
List<String> strs = FlatLaf.split( generalFont, ',' );
|
||||||
|
try {
|
||||||
|
family = strs.get( 0 );
|
||||||
|
size = Integer.parseInt( strs.get( 1 ) );
|
||||||
|
if( "75".equals( strs.get( 4 ) ) )
|
||||||
|
style |= Font.BOLD;
|
||||||
|
if( "1".equals( strs.get( 5 ) ) )
|
||||||
|
style |= Font.ITALIC;
|
||||||
|
} catch( RuntimeException ex ) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// font dpi
|
||||||
|
int dpi = 96;
|
||||||
|
if( forceFontDPI != null ) {
|
||||||
|
try {
|
||||||
|
dpi = Integer.parseInt( forceFontDPI );
|
||||||
|
if( dpi <= 0 )
|
||||||
|
dpi = 96;
|
||||||
|
if( dpi < 50 )
|
||||||
|
dpi = 50;
|
||||||
|
} catch( NumberFormatException ex ) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scale font size
|
||||||
|
double fontScale = dpi / 72.0;
|
||||||
|
double dsize = size * fontScale;
|
||||||
|
size = (int) (dsize + 0.5);
|
||||||
|
if( size < 1 )
|
||||||
|
size = 1;
|
||||||
|
|
||||||
|
return createFont( family, style, size, dsize );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> readConfig( String filename ) {
|
||||||
|
File userHome = new File( System.getProperty( "user.home" ) );
|
||||||
|
|
||||||
|
// search for config file
|
||||||
|
String[] configDirs = {
|
||||||
|
".config", // KDE 5
|
||||||
|
".kde4/share/config", // KDE 4
|
||||||
|
".kde/share/config"// KDE 3
|
||||||
|
};
|
||||||
|
File file = null;
|
||||||
|
for( String configDir : configDirs ) {
|
||||||
|
file = new File( userHome, configDir + "/" + filename );
|
||||||
|
if( file.isFile() )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if( !file.isFile() )
|
||||||
|
return Collections.emptyList();
|
||||||
|
|
||||||
|
// read config file
|
||||||
|
ArrayList<String> lines = new ArrayList<>( 200 );
|
||||||
|
try( BufferedReader reader = new BufferedReader( new FileReader( file ) ) ) {
|
||||||
|
String line = null;
|
||||||
|
while( (line = reader.readLine()) != null )
|
||||||
|
lines.add( line );
|
||||||
|
} catch( IOException ex ) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getConfigEntry( List<String> config, String group, String key ) {
|
||||||
|
int groupLength = group.length();
|
||||||
|
int keyLength = key.length();
|
||||||
|
boolean inGroup = false;
|
||||||
|
for( String line : config ) {
|
||||||
|
if( !inGroup ) {
|
||||||
|
if( line.length() >= groupLength + 2 &&
|
||||||
|
line.charAt( 0 ) == '[' &&
|
||||||
|
line.charAt( groupLength + 1 ) == ']' &&
|
||||||
|
line.indexOf( group ) == 1 )
|
||||||
|
{
|
||||||
|
inGroup = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if( line.startsWith( "[" ) )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if( line.length() >= keyLength + 2 &&
|
||||||
|
line.charAt( keyLength ) == '=' &&
|
||||||
|
line.startsWith( key ) )
|
||||||
|
{
|
||||||
|
return line.substring( keyLength + 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,9 +16,11 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.icons;
|
package com.formdev.flatlaf.icons;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.geom.Path2D;
|
||||||
import javax.swing.JMenu;
|
import javax.swing.JMenu;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
@@ -26,6 +28,7 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
/**
|
/**
|
||||||
* "arrow" icon for {@link javax.swing.JMenu}.
|
* "arrow" icon for {@link javax.swing.JMenu}.
|
||||||
*
|
*
|
||||||
|
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||||
* @uiDefault Menu.icon.arrowColor Color
|
* @uiDefault Menu.icon.arrowColor Color
|
||||||
* @uiDefault Menu.icon.disabledArrowColor Color
|
* @uiDefault Menu.icon.disabledArrowColor Color
|
||||||
* @uiDefault Menu.selectionForeground Color
|
* @uiDefault Menu.selectionForeground Color
|
||||||
@@ -35,12 +38,13 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
public class FlatMenuArrowIcon
|
public class FlatMenuArrowIcon
|
||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
|
protected final boolean chevron = "chevron".equals( UIManager.getString( "Component.arrowType" ) );
|
||||||
protected final Color arrowColor = UIManager.getColor( "Menu.icon.arrowColor" );
|
protected final Color arrowColor = UIManager.getColor( "Menu.icon.arrowColor" );
|
||||||
protected final Color disabledArrowColor = UIManager.getColor( "Menu.icon.disabledArrowColor" );
|
protected final Color disabledArrowColor = UIManager.getColor( "Menu.icon.disabledArrowColor" );
|
||||||
protected final Color selectionForeground = UIManager.getColor( "Menu.selectionForeground" );
|
protected final Color selectionForeground = UIManager.getColor( "Menu.selectionForeground" );
|
||||||
|
|
||||||
public FlatMenuArrowIcon() {
|
public FlatMenuArrowIcon() {
|
||||||
super( 5, 10, null );
|
super( 6, 10, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,8 +53,16 @@ public class FlatMenuArrowIcon
|
|||||||
g.rotate( Math.toRadians( 180 ), width / 2., height / 2. );
|
g.rotate( Math.toRadians( 180 ), width / 2., height / 2. );
|
||||||
|
|
||||||
g.setColor( getArrowColor( c ) );
|
g.setColor( getArrowColor( c ) );
|
||||||
|
if( chevron ) {
|
||||||
|
// chevron arrow
|
||||||
|
Path2D path = FlatUIUtils.createPath( false, 1,1, 5,5, 1,9 );
|
||||||
|
g.setStroke( new BasicStroke( 1f ) );
|
||||||
|
g.draw( path );
|
||||||
|
} else {
|
||||||
|
// triangle arrow
|
||||||
g.fill( FlatUIUtils.createPath( 0,0.5, 0,9.5, 5,5 ) );
|
g.fill( FlatUIUtils.createPath( 0,0.5, 0,9.5, 5,5 ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Color getArrowColor( Component c ) {
|
private Color getArrowColor( Component c ) {
|
||||||
if( c instanceof JMenu && ((JMenu)c).isSelected() )
|
if( c instanceof JMenu && ((JMenu)c).isSelected() )
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.icons;
|
package com.formdev.flatlaf.icons;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@@ -24,6 +25,7 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
/**
|
/**
|
||||||
* "collapsed" icon for {@link javax.swing.JTree}.
|
* "collapsed" icon for {@link javax.swing.JTree}.
|
||||||
*
|
*
|
||||||
|
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||||
* @uiDefault Tree.icon.collapsedColor Color
|
* @uiDefault Tree.icon.collapsedColor Color
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
@@ -31,15 +33,32 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
public class FlatTreeCollapsedIcon
|
public class FlatTreeCollapsedIcon
|
||||||
extends FlatAbstractIcon
|
extends FlatAbstractIcon
|
||||||
{
|
{
|
||||||
|
private final boolean chevron;
|
||||||
|
|
||||||
public FlatTreeCollapsedIcon() {
|
public FlatTreeCollapsedIcon() {
|
||||||
super( 11, 11, UIManager.getColor( "Tree.icon.collapsedColor" ) );
|
this( UIManager.getColor( "Tree.icon.collapsedColor" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
FlatTreeCollapsedIcon( Color color ) {
|
||||||
|
super( 11, 11, color );
|
||||||
|
chevron = "chevron".equals( UIManager.getString( "Component.arrowType" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintIcon( Component c, Graphics2D g ) {
|
protected void paintIcon( Component c, Graphics2D g ) {
|
||||||
if( !c.getComponentOrientation().isLeftToRight() )
|
rotate( c, g );
|
||||||
g.rotate( Math.toRadians( 180 ), width / 2., height / 2. );
|
|
||||||
|
|
||||||
|
if( chevron ) {
|
||||||
|
// chevron arrow
|
||||||
|
g.fill( FlatUIUtils.createPath( 3,1, 3,2.5, 6,5.5, 3,8.5, 3,10, 4.5,10, 9,5.5, 4.5,1 ) );
|
||||||
|
} else {
|
||||||
|
// triangle arrow
|
||||||
g.fill( FlatUIUtils.createPath( 2,1, 2,10, 10,5.5 ) );
|
g.fill( FlatUIUtils.createPath( 2,1, 2,10, 10,5.5 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rotate( Component c, Graphics2D g ) {
|
||||||
|
if( !c.getComponentOrientation().isLeftToRight() )
|
||||||
|
g.rotate( Math.toRadians( 180 ), width / 2., height / 2. );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.formdev.flatlaf.icons;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "expanded" icon for {@link javax.swing.JTree}.
|
* "expanded" icon for {@link javax.swing.JTree}.
|
||||||
@@ -29,14 +28,14 @@ import com.formdev.flatlaf.ui.FlatUIUtils;
|
|||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
public class FlatTreeExpandedIcon
|
public class FlatTreeExpandedIcon
|
||||||
extends FlatAbstractIcon
|
extends FlatTreeCollapsedIcon
|
||||||
{
|
{
|
||||||
public FlatTreeExpandedIcon() {
|
public FlatTreeExpandedIcon() {
|
||||||
super( 11, 11, UIManager.getColor( "Tree.icon.expandedColor" ) );
|
super( UIManager.getColor( "Tree.icon.expandedColor" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintIcon( Component c, Graphics2D g ) {
|
void rotate( Component c, Graphics2D g ) {
|
||||||
g.fill( FlatUIUtils.createPath( 1,2, 10,2, 5.5,10 ) );
|
g.rotate( Math.toRadians( 90 ), width / 2., height / 2. );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||||
|
import java.awt.BasicStroke;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@@ -37,6 +38,7 @@ public class FlatArrowButton
|
|||||||
extends BasicArrowButton
|
extends BasicArrowButton
|
||||||
implements UIResource
|
implements UIResource
|
||||||
{
|
{
|
||||||
|
private final boolean chevron;
|
||||||
private final Color foreground;
|
private final Color foreground;
|
||||||
private final Color disabledForeground;
|
private final Color disabledForeground;
|
||||||
private final Color hoverForeground;
|
private final Color hoverForeground;
|
||||||
@@ -47,11 +49,12 @@ public class FlatArrowButton
|
|||||||
|
|
||||||
private boolean hover;
|
private boolean hover;
|
||||||
|
|
||||||
public FlatArrowButton( int direction, Color foreground, Color disabledForeground,
|
public FlatArrowButton( int direction, String type, Color foreground, Color disabledForeground,
|
||||||
Color hoverForeground, Color hoverBackground )
|
Color hoverForeground, Color hoverBackground )
|
||||||
{
|
{
|
||||||
super( direction, Color.WHITE, Color.WHITE, Color.WHITE, Color.WHITE );
|
super( direction, Color.WHITE, Color.WHITE, Color.WHITE, Color.WHITE );
|
||||||
|
|
||||||
|
this.chevron = "chevron".equals( type );
|
||||||
this.foreground = foreground;
|
this.foreground = foreground;
|
||||||
this.disabledForeground = disabledForeground;
|
this.disabledForeground = disabledForeground;
|
||||||
this.hoverForeground = hoverForeground;
|
this.hoverForeground = hoverForeground;
|
||||||
@@ -77,6 +80,10 @@ public class FlatArrowButton
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isHover() {
|
||||||
|
return hover;
|
||||||
|
}
|
||||||
|
|
||||||
public int getXOffset() {
|
public int getXOffset() {
|
||||||
return xOffset;
|
return xOffset;
|
||||||
}
|
}
|
||||||
@@ -113,7 +120,7 @@ public class FlatArrowButton
|
|||||||
boolean enabled = isEnabled();
|
boolean enabled = isEnabled();
|
||||||
|
|
||||||
// paint hover background
|
// paint hover background
|
||||||
if( enabled && hover && hoverBackground != null ) {
|
if( enabled && isHover() && hoverBackground != null ) {
|
||||||
g.setColor( hoverBackground );
|
g.setColor( hoverBackground );
|
||||||
g.fillRect( 0, 0, width, height );
|
g.fillRect( 0, 0, width, height );
|
||||||
}
|
}
|
||||||
@@ -121,26 +128,41 @@ public class FlatArrowButton
|
|||||||
int direction = getDirection();
|
int direction = getDirection();
|
||||||
boolean vert = (direction == NORTH || direction == SOUTH);
|
boolean vert = (direction == NORTH || direction == SOUTH);
|
||||||
|
|
||||||
int w = scale( 9 );
|
int w = scale( chevron ? 8 : 9 );
|
||||||
int h = scale( 5 );
|
int h = scale( chevron ? 4 : 5 );
|
||||||
int x = Math.round( (width - (vert ? w : h)) / 2f + scale( (float) xOffset ) );
|
int rw = vert ? w : h;
|
||||||
int y = Math.round( (height - (vert ? h : w)) / 2f + scale( (float) yOffset ) );
|
int rh = vert ? h : w;
|
||||||
|
int x = Math.round( (width - rw) / 2f + scale( (float) xOffset ) );
|
||||||
|
int y = Math.round( (height - rh) / 2f + scale( (float) yOffset ) );
|
||||||
|
|
||||||
|
// optimization for small chevron arrows (e.g. OneTouchButtons in SplitPane)
|
||||||
|
if( x + rw >= width && x > 0 )
|
||||||
|
x--;
|
||||||
|
if( y + rh >= height && y > 0 )
|
||||||
|
y--;
|
||||||
|
|
||||||
// paint arrow
|
// paint arrow
|
||||||
g.setColor( enabled
|
g.setColor( enabled
|
||||||
? (hover && hoverForeground != null ? hoverForeground : foreground)
|
? (isHover() && hoverForeground != null ? hoverForeground : foreground)
|
||||||
: disabledForeground );
|
: disabledForeground );
|
||||||
g.translate( x, y );
|
g.translate( x, y );
|
||||||
g2.fill( createArrowShape( direction, w, h ) );
|
Shape arrowShape = createArrowShape( direction, chevron, w, h );
|
||||||
|
if( chevron ) {
|
||||||
|
g2.setStroke( new BasicStroke( scale( 1f ) ) );
|
||||||
|
g2.draw( arrowShape );
|
||||||
|
} else {
|
||||||
|
// triangle
|
||||||
|
g2.fill( arrowShape );
|
||||||
|
}
|
||||||
g.translate( -x, -y );
|
g.translate( -x, -y );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Shape createArrowShape( int direction, int w, int h ) {
|
public static Shape createArrowShape( int direction, boolean chevron, float w, float h ) {
|
||||||
switch( direction ) {
|
switch( direction ) {
|
||||||
case NORTH: return FlatUIUtils.createPath( 0,h, w,h, (w / 2f),0 );
|
case NORTH: return FlatUIUtils.createPath( !chevron, 0,h, (w / 2f),0, w,h );
|
||||||
case SOUTH: return FlatUIUtils.createPath( 0,0, w,0, (w / 2f),h );
|
case SOUTH: return FlatUIUtils.createPath( !chevron, 0,0, (w / 2f),h, w,0 );
|
||||||
case WEST: return FlatUIUtils.createPath( h,0, h,w, 0,(w / 2f) );
|
case WEST: return FlatUIUtils.createPath( !chevron, h,0, 0,(w / 2f), h,w );
|
||||||
case EAST: return FlatUIUtils.createPath( 0,0, 0,w, h,(w / 2f) );
|
case EAST: return FlatUIUtils.createPath( !chevron, 0,0, h,(w / 2f), 0,w );
|
||||||
default: return new Path2D.Float();
|
default: return new Path2D.Float();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import javax.swing.text.JTextComponent;
|
|||||||
* {@link FlatUIUtils#paintParentBackground} to paint the empty space correctly.
|
* {@link FlatUIUtils#paintParentBackground} to paint the empty space correctly.
|
||||||
*
|
*
|
||||||
* @uiDefault Component.focusWidth int
|
* @uiDefault Component.focusWidth int
|
||||||
|
* @uiDefault Component.innerFocusWidth int
|
||||||
* @uiDefault Component.focusColor Color
|
* @uiDefault Component.focusColor Color
|
||||||
* @uiDefault Component.borderColor Color
|
* @uiDefault Component.borderColor Color
|
||||||
* @uiDefault Component.disabledBorderColor Color
|
* @uiDefault Component.disabledBorderColor Color
|
||||||
@@ -59,6 +60,7 @@ public class FlatBorder
|
|||||||
extends BasicBorders.MarginBorder
|
extends BasicBorders.MarginBorder
|
||||||
{
|
{
|
||||||
protected final int focusWidth = UIManager.getInt( "Component.focusWidth" );
|
protected final int focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||||
|
protected final int innerFocusWidth = UIManager.getInt( "Component.innerFocusWidth" );
|
||||||
protected final Color focusColor = UIManager.getColor( "Component.focusColor" );
|
protected final Color focusColor = UIManager.getColor( "Component.focusColor" );
|
||||||
protected final Color borderColor = UIManager.getColor( "Component.borderColor" );
|
protected final Color borderColor = UIManager.getColor( "Component.borderColor" );
|
||||||
protected final Color disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
protected final Color disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
||||||
@@ -70,17 +72,19 @@ public class FlatBorder
|
|||||||
try {
|
try {
|
||||||
FlatUIUtils.setRenderingHints( g2 );
|
FlatUIUtils.setRenderingHints( g2 );
|
||||||
|
|
||||||
float focusWidth = getFocusWidth();
|
boolean isCellEditor = FlatUIUtils.isTableCellEditor( c );
|
||||||
float lineWidth = getLineWidth();
|
float focusWidth = isCellEditor ? 0 : getFocusWidth();
|
||||||
float arc = getArc();
|
float borderWidth = getBorderWidth( c );
|
||||||
|
float arc = isCellEditor ? 0 : getArc();
|
||||||
|
|
||||||
if( isFocused( c ) ) {
|
if( isFocused( c ) ) {
|
||||||
g2.setColor( getFocusColor( c ) );
|
g2.setColor( getFocusColor( c ) );
|
||||||
FlatUIUtils.paintOutlineBorder( g2, x, y, width, height, focusWidth, lineWidth, arc );
|
FlatUIUtils.paintOutlineBorder( g2, x, y, width, height, focusWidth,
|
||||||
|
getLineWidth() + scale( (float) innerFocusWidth ), arc );
|
||||||
}
|
}
|
||||||
|
|
||||||
g2.setPaint( getBorderColor( c ) );
|
g2.setPaint( getBorderColor( c ) );
|
||||||
FlatUIUtils.drawRoundRectangle( g2, x, y, width, height, focusWidth, lineWidth, arc );
|
FlatUIUtils.drawRoundRectangle( g2, x, y, width, height, focusWidth, borderWidth, arc );
|
||||||
} finally {
|
} finally {
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
}
|
}
|
||||||
@@ -131,7 +135,8 @@ public class FlatBorder
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Insets getBorderInsets( Component c, Insets insets ) {
|
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 = super.getBorderInsets( c, insets );
|
||||||
insets.top = Math.round( scale( (float) insets.top ) + ow );
|
insets.top = Math.round( scale( (float) insets.top ) + ow );
|
||||||
@@ -149,6 +154,10 @@ public class FlatBorder
|
|||||||
return scale( 1f );
|
return scale( 1f );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected float getBorderWidth( Component c ) {
|
||||||
|
return getLineWidth();
|
||||||
|
}
|
||||||
|
|
||||||
protected float getArc() {
|
protected float getArc() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,11 @@ import static com.formdev.flatlaf.util.UIScale.scale;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Insets;
|
||||||
import java.awt.Paint;
|
import java.awt.Paint;
|
||||||
|
import javax.swing.JButton;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.plaf.UIResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Border for {@link javax.swing.JButton}.
|
* Border for {@link javax.swing.JButton}.
|
||||||
@@ -34,6 +37,7 @@ import javax.swing.UIManager;
|
|||||||
* @uiDefault Button.default.hoverBorderColor Color optional
|
* @uiDefault Button.default.hoverBorderColor Color optional
|
||||||
* @uiDefault Button.default.focusedBorderColor Color
|
* @uiDefault Button.default.focusedBorderColor Color
|
||||||
* @uiDefault Button.default.focusColor Color
|
* @uiDefault Button.default.focusColor Color
|
||||||
|
* @uiDefault Button.default.borderWidth int
|
||||||
* @uiDefault Button.arc int
|
* @uiDefault Button.arc int
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
@@ -49,6 +53,7 @@ public class FlatButtonBorder
|
|||||||
protected final Color defaultHoverBorderColor = UIManager.getColor( "Button.default.hoverBorderColor" );
|
protected final Color defaultHoverBorderColor = UIManager.getColor( "Button.default.hoverBorderColor" );
|
||||||
protected final Color defaultFocusedBorderColor = UIManager.getColor( "Button.default.focusedBorderColor" );
|
protected final Color defaultFocusedBorderColor = UIManager.getColor( "Button.default.focusedBorderColor" );
|
||||||
protected final Color defaultFocusColor = UIManager.getColor( "Button.default.focusColor" );
|
protected final Color defaultFocusColor = UIManager.getColor( "Button.default.focusColor" );
|
||||||
|
protected final int defaultBorderWidth = UIManager.getInt( "Button.default.borderWidth" );
|
||||||
protected final int arc = UIManager.getInt( "Button.arc" );
|
protected final int arc = UIManager.getInt( "Button.arc" );
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -73,6 +78,22 @@ public class FlatButtonBorder
|
|||||||
null );
|
null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||||
|
insets = super.getBorderInsets( c, insets );
|
||||||
|
|
||||||
|
// use smaller left and right insets for icon-only buttons (so that they are square)
|
||||||
|
if( FlatButtonUI.isIconOnlyButton( c ) && ((JButton)c).getMargin() instanceof UIResource )
|
||||||
|
insets.left = insets.right = Math.min( insets.top, insets.bottom );
|
||||||
|
|
||||||
|
return insets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected float getBorderWidth( Component c ) {
|
||||||
|
return FlatButtonUI.isDefaultButton( c ) ? scale( (float) defaultBorderWidth ) : super.getBorderWidth( c );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getArc() {
|
protected float getArc() {
|
||||||
return scale( (float) arc );
|
return scale( (float) arc );
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import static com.formdev.flatlaf.util.UIScale.scale;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
@@ -35,7 +36,9 @@ import javax.swing.LookAndFeel;
|
|||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.plaf.basic.BasicButtonUI;
|
import javax.swing.plaf.basic.BasicButtonUI;
|
||||||
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Flat LaF UI delegate for {@link javax.swing.JButton}.
|
* Provides the Flat LaF UI delegate for {@link javax.swing.JButton}.
|
||||||
@@ -55,6 +58,7 @@ import javax.swing.plaf.basic.BasicButtonUI;
|
|||||||
* @uiDefault Button.default.focusedBackground Color optional
|
* @uiDefault Button.default.focusedBackground Color optional
|
||||||
* @uiDefault Button.default.hoverBackground Color optional
|
* @uiDefault Button.default.hoverBackground Color optional
|
||||||
* @uiDefault Button.default.pressedBackground Color optional
|
* @uiDefault Button.default.pressedBackground Color optional
|
||||||
|
* @uiDefault Button.default.boldText boolean
|
||||||
* @uiDefault Button.toolbar.hoverBackground Color
|
* @uiDefault Button.toolbar.hoverBackground Color
|
||||||
* @uiDefault Button.toolbar.pressedBackground Color
|
* @uiDefault Button.toolbar.pressedBackground Color
|
||||||
*
|
*
|
||||||
@@ -78,6 +82,7 @@ public class FlatButtonUI
|
|||||||
protected Color defaultFocusedBackground;
|
protected Color defaultFocusedBackground;
|
||||||
protected Color defaultHoverBackground;
|
protected Color defaultHoverBackground;
|
||||||
protected Color defaultPressedBackground;
|
protected Color defaultPressedBackground;
|
||||||
|
protected boolean defaultBoldText;
|
||||||
|
|
||||||
protected Color toolbarHoverBackground;
|
protected Color toolbarHoverBackground;
|
||||||
protected Color toolbarPressedBackground;
|
protected Color toolbarPressedBackground;
|
||||||
@@ -116,6 +121,7 @@ public class FlatButtonUI
|
|||||||
defaultFocusedBackground = UIManager.getColor( "Button.default.focusedBackground" );
|
defaultFocusedBackground = UIManager.getColor( "Button.default.focusedBackground" );
|
||||||
defaultHoverBackground = UIManager.getColor( "Button.default.hoverBackground" );
|
defaultHoverBackground = UIManager.getColor( "Button.default.hoverBackground" );
|
||||||
defaultPressedBackground = UIManager.getColor( "Button.default.pressedBackground" );
|
defaultPressedBackground = UIManager.getColor( "Button.default.pressedBackground" );
|
||||||
|
defaultBoldText = UIManager.getBoolean( "Button.default.boldText" );
|
||||||
|
|
||||||
toolbarHoverBackground = UIManager.getColor( prefix + "toolbar.hoverBackground" );
|
toolbarHoverBackground = UIManager.getColor( prefix + "toolbar.hoverBackground" );
|
||||||
toolbarPressedBackground = UIManager.getColor( prefix + "toolbar.pressedBackground" );
|
toolbarPressedBackground = UIManager.getColor( prefix + "toolbar.pressedBackground" );
|
||||||
@@ -146,6 +152,13 @@ public class FlatButtonUI
|
|||||||
return c instanceof JButton && ((JButton)c).isDefaultButton();
|
return c instanceof JButton && ((JButton)c).isDefaultButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean isIconOnlyButton( Component c ) {
|
||||||
|
String text;
|
||||||
|
return c instanceof JButton &&
|
||||||
|
((JButton)c).getIcon() != null &&
|
||||||
|
((text = ((JButton)c).getText()) == null || text.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
static boolean isHelpButton( Component c ) {
|
static boolean isHelpButton( Component c ) {
|
||||||
return c instanceof JButton && clientPropertyEquals( (JButton) c, BUTTON_TYPE, BUTTON_TYPE_HELP );
|
return c instanceof JButton && clientPropertyEquals( (JButton) c, BUTTON_TYPE, BUTTON_TYPE_HELP );
|
||||||
}
|
}
|
||||||
@@ -191,12 +204,23 @@ public class FlatButtonUI
|
|||||||
if( isHelpButton( b ) )
|
if( isHelpButton( b ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if( defaultBoldText && isDefaultButton( b ) && b.getFont() instanceof UIResource ) {
|
||||||
|
Font boldFont = g.getFont().deriveFont( Font.BOLD );
|
||||||
|
g.setFont( boldFont );
|
||||||
|
|
||||||
|
int boldWidth = b.getFontMetrics( boldFont ).stringWidth( text );
|
||||||
|
if( boldWidth > textRect.width ) {
|
||||||
|
textRect.x -= (boldWidth - textRect.width) / 2;
|
||||||
|
textRect.width = boldWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
paintText( g, b, textRect, text, b.isEnabled() ? getForeground( b ) : disabledText );
|
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() );
|
FontMetrics fm = b.getFontMetrics( b.getFont() );
|
||||||
int mnemonicIndex = b.getDisplayedMnemonicIndex();
|
int mnemonicIndex = FlatLaf.isShowMnemonics() ? b.getDisplayedMnemonicIndex() : -1;
|
||||||
|
|
||||||
g.setColor( foreground );
|
g.setColor( foreground );
|
||||||
FlatUIUtils.drawStringUnderlineCharAt( b, g, text, mnemonicIndex,
|
FlatUIUtils.drawStringUnderlineCharAt( b, g, text, mnemonicIndex,
|
||||||
@@ -259,8 +283,11 @@ public class FlatButtonUI
|
|||||||
return new Dimension( helpButtonIcon.getIconWidth(), helpButtonIcon.getIconHeight() );
|
return new Dimension( helpButtonIcon.getIconWidth(), helpButtonIcon.getIconHeight() );
|
||||||
|
|
||||||
Dimension prefSize = super.getPreferredSize( c );
|
Dimension prefSize = super.getPreferredSize( c );
|
||||||
if( !isToolBarButton( c ) )
|
|
||||||
|
// apply minimum width, if not in toolbar and not a icon-only button
|
||||||
|
if( !isToolBarButton( c ) && !isIconOnlyButton( c ) )
|
||||||
prefSize.width = Math.max( prefSize.width, scale( minimumWidth + (focusWidth * 2) ) );
|
prefSize.width = Math.max( prefSize.width, scale( minimumWidth + (focusWidth * 2) ) );
|
||||||
|
|
||||||
return prefSize;
|
return prefSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
@@ -57,6 +58,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
*
|
*
|
||||||
* @uiDefault Component.focusWidth int
|
* @uiDefault Component.focusWidth int
|
||||||
* @uiDefault Component.arc int
|
* @uiDefault Component.arc int
|
||||||
|
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||||
* @uiDefault Component.borderColor Color
|
* @uiDefault Component.borderColor Color
|
||||||
* @uiDefault Component.disabledBorderColor Color
|
* @uiDefault Component.disabledBorderColor Color
|
||||||
* @uiDefault ComboBox.disabledBackground Color
|
* @uiDefault ComboBox.disabledBackground Color
|
||||||
@@ -74,6 +76,7 @@ public class FlatComboBoxUI
|
|||||||
{
|
{
|
||||||
protected int focusWidth;
|
protected int focusWidth;
|
||||||
protected int arc;
|
protected int arc;
|
||||||
|
protected String arrowType;
|
||||||
protected Color borderColor;
|
protected Color borderColor;
|
||||||
protected Color disabledBorderColor;
|
protected Color disabledBorderColor;
|
||||||
|
|
||||||
@@ -86,16 +89,42 @@ public class FlatComboBoxUI
|
|||||||
protected Color buttonDisabledArrowColor;
|
protected Color buttonDisabledArrowColor;
|
||||||
protected Color buttonHoverArrowColor;
|
protected Color buttonHoverArrowColor;
|
||||||
|
|
||||||
|
private MouseListener hoverListener;
|
||||||
|
private boolean hover;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatComboBoxUI();
|
return new FlatComboBoxUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installListeners() {
|
||||||
|
super.installListeners();
|
||||||
|
|
||||||
|
hoverListener = new FlatUIUtils.HoverListener( null, h -> {
|
||||||
|
if( !comboBox.isEditable() ) {
|
||||||
|
hover = h;
|
||||||
|
if( arrowButton != null )
|
||||||
|
arrowButton.repaint();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
comboBox.addMouseListener( hoverListener );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void uninstallListeners() {
|
||||||
|
super.uninstallListeners();
|
||||||
|
|
||||||
|
comboBox.removeMouseListener( hoverListener );
|
||||||
|
hoverListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void installDefaults() {
|
protected void installDefaults() {
|
||||||
super.installDefaults();
|
super.installDefaults();
|
||||||
|
|
||||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||||
arc = UIManager.getInt( "Component.arc" );
|
arc = UIManager.getInt( "Component.arc" );
|
||||||
|
arrowType = UIManager.getString( "Component.arrowType" );
|
||||||
borderColor = UIManager.getColor( "Component.borderColor" );
|
borderColor = UIManager.getColor( "Component.borderColor" );
|
||||||
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
||||||
|
|
||||||
@@ -224,8 +253,14 @@ public class FlatComboBoxUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JButton createArrowButton() {
|
protected JButton createArrowButton() {
|
||||||
return new FlatArrowButton( SwingConstants.SOUTH, buttonArrowColor,
|
return new FlatArrowButton( SwingConstants.SOUTH, arrowType, buttonArrowColor,
|
||||||
buttonDisabledArrowColor, buttonHoverArrowColor, null );
|
buttonDisabledArrowColor, buttonHoverArrowColor, null )
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected boolean isHover() {
|
||||||
|
return super.isHover() || (!comboBox.isEditable() ? hover : false);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -333,7 +368,6 @@ public class FlatComboBoxUI
|
|||||||
@SuppressWarnings( { "rawtypes", "unchecked" } )
|
@SuppressWarnings( { "rawtypes", "unchecked" } )
|
||||||
private class FlatComboPopup
|
private class FlatComboPopup
|
||||||
extends BasicComboPopup
|
extends BasicComboPopup
|
||||||
implements ListCellRenderer
|
|
||||||
{
|
{
|
||||||
private CellPaddingBorder paddingBorder;
|
private CellPaddingBorder paddingBorder;
|
||||||
|
|
||||||
@@ -370,7 +404,7 @@ public class FlatComboBoxUI
|
|||||||
protected void configureList() {
|
protected void configureList() {
|
||||||
super.configureList();
|
super.configureList();
|
||||||
|
|
||||||
list.setCellRenderer( this );
|
list.setCellRenderer( new PopupListCellRenderer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -381,11 +415,16 @@ public class FlatComboBoxUI
|
|||||||
super.propertyChange( e );
|
super.propertyChange( e );
|
||||||
|
|
||||||
if( e.getPropertyName() == "renderer" )
|
if( e.getPropertyName() == "renderer" )
|
||||||
list.setCellRenderer( FlatComboPopup.this );
|
list.setCellRenderer( new PopupListCellRenderer() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---- class PopupListCellRenderer -----
|
||||||
|
|
||||||
|
private class PopupListCellRenderer
|
||||||
|
implements ListCellRenderer
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent( JList list, Object value,
|
public Component getListCellRendererComponent( JList list, Object value,
|
||||||
int index, boolean isSelected, boolean cellHasFocus )
|
int index, boolean isSelected, boolean cellHasFocus )
|
||||||
@@ -404,6 +443,7 @@ public class FlatComboBoxUI
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---- class CellPaddingBorder --------------------------------------------
|
//---- class CellPaddingBorder --------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.ui;
|
|||||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JEditorPane;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicEditorPaneUI;
|
import javax.swing.plaf.basic.BasicEditorPaneUI;
|
||||||
@@ -37,6 +38,8 @@ public class FlatEditorPaneUI
|
|||||||
{
|
{
|
||||||
protected int minimumWidth;
|
protected int minimumWidth;
|
||||||
|
|
||||||
|
private Object oldHonorDisplayProperties;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatEditorPaneUI();
|
return new FlatEditorPaneUI();
|
||||||
}
|
}
|
||||||
@@ -46,6 +49,17 @@ public class FlatEditorPaneUI
|
|||||||
super.installDefaults();
|
super.installDefaults();
|
||||||
|
|
||||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
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
|
@Override
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import javax.swing.SwingUtilities;
|
|||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicLabelUI;
|
import javax.swing.plaf.basic.BasicLabelUI;
|
||||||
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,9 +72,16 @@ public class FlatLabelUI
|
|||||||
defaults_initialized = false;
|
defaults_initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintEnabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
|
||||||
|
int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1;
|
||||||
|
g.setColor( l.getForeground() );
|
||||||
|
FlatUIUtils.drawStringUnderlineCharAt( l, g, s, mnemIndex, textX, textY );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintDisabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
|
protected void paintDisabledText( JLabel l, Graphics g, String s, int textX, int textY ) {
|
||||||
int mnemIndex = l.getDisplayedMnemonicIndex();
|
int mnemIndex = FlatLaf.isShowMnemonics() ? l.getDisplayedMnemonicIndex() : -1;
|
||||||
g.setColor( disabledForeground );
|
g.setColor( disabledForeground );
|
||||||
FlatUIUtils.drawStringUnderlineCharAt( l, g, s, mnemIndex, textX, textY );
|
FlatUIUtils.drawStringUnderlineCharAt( l, g, s, mnemIndex, textX, textY );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.awt.GridBagConstraints;
|
|||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
|
import javax.swing.plaf.basic.BasicHTML;
|
||||||
import javax.swing.plaf.basic.BasicOptionPaneUI;
|
import javax.swing.plaf.basic.BasicOptionPaneUI;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
@@ -122,6 +123,10 @@ public class FlatOptionPaneUI
|
|||||||
if( messagePadding > 0 )
|
if( messagePadding > 0 )
|
||||||
cons.insets.bottom = UIScale.scale( messagePadding );
|
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 );
|
super.addMessageComponents( container, cons, msg, maxll, internallyCreated );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,15 +116,16 @@ public class FlatPasswordFieldUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize( JComponent c ) {
|
public Dimension getPreferredSize( JComponent c ) {
|
||||||
return applyMinimumWidth( super.getPreferredSize( c ) );
|
return applyMinimumWidth( super.getPreferredSize( c ), c );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getMinimumSize( JComponent c ) {
|
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) ) );
|
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import javax.swing.plaf.basic.BasicSpinnerUI;
|
|||||||
* @uiDefault Component.focusWidth int
|
* @uiDefault Component.focusWidth int
|
||||||
* @uiDefault Component.arc int
|
* @uiDefault Component.arc int
|
||||||
* @uiDefault Component.minimumWidth int
|
* @uiDefault Component.minimumWidth int
|
||||||
|
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||||
* @uiDefault Component.borderColor Color
|
* @uiDefault Component.borderColor Color
|
||||||
* @uiDefault Component.disabledBorderColor Color
|
* @uiDefault Component.disabledBorderColor Color
|
||||||
* @uiDefault Spinner.disabledBackground Color
|
* @uiDefault Spinner.disabledBackground Color
|
||||||
@@ -68,6 +69,7 @@ public class FlatSpinnerUI
|
|||||||
protected int focusWidth;
|
protected int focusWidth;
|
||||||
protected int arc;
|
protected int arc;
|
||||||
protected int minimumWidth;
|
protected int minimumWidth;
|
||||||
|
protected String arrowType;
|
||||||
protected Color borderColor;
|
protected Color borderColor;
|
||||||
protected Color disabledBorderColor;
|
protected Color disabledBorderColor;
|
||||||
protected Color disabledBackground;
|
protected Color disabledBackground;
|
||||||
@@ -89,6 +91,7 @@ public class FlatSpinnerUI
|
|||||||
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
focusWidth = UIManager.getInt( "Component.focusWidth" );
|
||||||
arc = UIManager.getInt( "Component.arc" );
|
arc = UIManager.getInt( "Component.arc" );
|
||||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||||
|
arrowType = UIManager.getString( "Component.arrowType" );
|
||||||
borderColor = UIManager.getColor( "Component.borderColor" );
|
borderColor = UIManager.getColor( "Component.borderColor" );
|
||||||
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
||||||
disabledBackground = UIManager.getColor( "Spinner.disabledBackground" );
|
disabledBackground = UIManager.getColor( "Spinner.disabledBackground" );
|
||||||
@@ -209,7 +212,7 @@ public class FlatSpinnerUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Component createArrowButton( int direction, String name ) {
|
private Component createArrowButton( int direction, String name ) {
|
||||||
FlatArrowButton button = new FlatArrowButton( direction, buttonArrowColor,
|
FlatArrowButton button = new FlatArrowButton( direction, arrowType, buttonArrowColor,
|
||||||
buttonDisabledArrowColor, buttonHoverArrowColor, null );
|
buttonDisabledArrowColor, buttonHoverArrowColor, null );
|
||||||
button.setName( name );
|
button.setName( name );
|
||||||
button.setYOffset( (direction == SwingConstants.NORTH) ? 1 : -1 );
|
button.setYOffset( (direction == SwingConstants.NORTH) ? 1 : -1 );
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
/**
|
/**
|
||||||
* Provides the Flat LaF UI delegate for {@link javax.swing.JSplitPane}.
|
* Provides the Flat LaF UI delegate for {@link javax.swing.JSplitPane}.
|
||||||
*
|
*
|
||||||
|
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||||
* @uiDefault SplitPane.background Color
|
* @uiDefault SplitPane.background Color
|
||||||
* @uiDefault SplitPane.foreground Color unused
|
* @uiDefault SplitPane.foreground Color unused
|
||||||
* @uiDefault SplitPane.dividerSize int
|
* @uiDefault SplitPane.dividerSize int
|
||||||
@@ -46,6 +47,7 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
public class FlatSplitPaneUI
|
public class FlatSplitPaneUI
|
||||||
extends BasicSplitPaneUI
|
extends BasicSplitPaneUI
|
||||||
{
|
{
|
||||||
|
protected String arrowType;
|
||||||
private Boolean continuousLayout;
|
private Boolean continuousLayout;
|
||||||
private Color oneTouchArrowColor;
|
private Color oneTouchArrowColor;
|
||||||
private Color oneTouchHoverArrowColor;
|
private Color oneTouchHoverArrowColor;
|
||||||
@@ -56,6 +58,8 @@ public class FlatSplitPaneUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void installDefaults() {
|
protected void installDefaults() {
|
||||||
|
arrowType = UIManager.getString( "Component.arrowType" );
|
||||||
|
|
||||||
// get one-touch colors before invoking super.installDefaults() because they are
|
// get one-touch colors before invoking super.installDefaults() because they are
|
||||||
// used in there on LaF switching
|
// used in there on LaF switching
|
||||||
oneTouchArrowColor = UIManager.getColor( "SplitPaneDivider.oneTouchArrowColor" );
|
oneTouchArrowColor = UIManager.getColor( "SplitPaneDivider.oneTouchArrowColor" );
|
||||||
@@ -108,7 +112,7 @@ public class FlatSplitPaneUI
|
|||||||
private final boolean left;
|
private final boolean left;
|
||||||
|
|
||||||
public FlatOneTouchButton( boolean left ) {
|
public FlatOneTouchButton( boolean left ) {
|
||||||
super( SwingConstants.NORTH, oneTouchArrowColor, null, oneTouchHoverArrowColor, null );
|
super( SwingConstants.NORTH, arrowType, oneTouchArrowColor, null, oneTouchHoverArrowColor, null );
|
||||||
setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ) );
|
setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ) );
|
||||||
|
|
||||||
this.left = left;
|
this.left = left;
|
||||||
|
|||||||
@@ -33,12 +33,14 @@ import javax.swing.plaf.ComponentUI;
|
|||||||
import javax.swing.plaf.UIResource;
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
import javax.swing.plaf.basic.BasicTabbedPaneUI;
|
||||||
import javax.swing.text.View;
|
import javax.swing.text.View;
|
||||||
|
import com.formdev.flatlaf.FlatLaf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Flat LaF UI delegate for {@link javax.swing.JTabbedPane}.
|
* Provides the Flat LaF UI delegate for {@link javax.swing.JTabbedPane}.
|
||||||
*
|
*
|
||||||
* @clientProperty JTabbedPane.hasFullBorder boolean
|
* @clientProperty JTabbedPane.hasFullBorder boolean
|
||||||
*
|
*
|
||||||
|
* @uiDefault Component.arrowType String triangle (default) or chevron
|
||||||
* @uiDefault TabbedPane.font Font
|
* @uiDefault TabbedPane.font Font
|
||||||
* @uiDefault TabbedPane.background Color
|
* @uiDefault TabbedPane.background Color
|
||||||
* @uiDefault TabbedPane.foreground Color
|
* @uiDefault TabbedPane.foreground Color
|
||||||
@@ -144,7 +146,8 @@ public class FlatTabbedPaneUI
|
|||||||
@Override
|
@Override
|
||||||
protected JButton createScrollButton( int direction ) {
|
protected JButton createScrollButton( int direction ) {
|
||||||
// this method is invoked before installDefaults(), so we can not use color fields here
|
// this method is invoked before installDefaults(), so we can not use color fields here
|
||||||
return new FlatArrowButton( direction, UIManager.getColor("TabbedPane.shadow"),
|
return new FlatArrowButton( direction, UIManager.getString( "Component.arrowType" ),
|
||||||
|
UIManager.getColor( "TabbedPane.shadow" ),
|
||||||
UIManager.getColor( "TabbedPane.disabledForeground" ), null,
|
UIManager.getColor( "TabbedPane.disabledForeground" ), null,
|
||||||
UIManager.getColor( "TabbedPane.hoverColor" ) );
|
UIManager.getColor( "TabbedPane.hoverColor" ) );
|
||||||
}
|
}
|
||||||
@@ -261,7 +264,7 @@ public class FlatTabbedPaneUI
|
|||||||
} else
|
} else
|
||||||
color = disabledForeground;
|
color = disabledForeground;
|
||||||
|
|
||||||
int mnemIndex = tabPane.getDisplayedMnemonicIndexAt( tabIndex );
|
int mnemIndex = FlatLaf.isShowMnemonics() ? tabPane.getDisplayedMnemonicIndexAt( tabIndex ) : -1;
|
||||||
|
|
||||||
g.setColor( color );
|
g.setColor( color );
|
||||||
FlatUIUtils.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex,
|
FlatUIUtils.drawStringUnderlineCharAt( tabPane, g, title, mnemIndex,
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ public class FlatTextFieldUI
|
|||||||
(parent != null && parent.getParent() instanceof JSpinner) )
|
(parent != null && parent.getParent() instanceof JSpinner) )
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
|
int focusWidth = (c.getBorder() instanceof FlatBorder) ? this.focusWidth : 0;
|
||||||
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
size.width = Math.max( size.width, scale( minimumWidth + (focusWidth * 2) ) );
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.ui;
|
|||||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JEditorPane;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicTextPaneUI;
|
import javax.swing.plaf.basic.BasicTextPaneUI;
|
||||||
@@ -37,6 +38,8 @@ public class FlatTextPaneUI
|
|||||||
{
|
{
|
||||||
protected int minimumWidth;
|
protected int minimumWidth;
|
||||||
|
|
||||||
|
private Object oldHonorDisplayProperties;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatTextPaneUI();
|
return new FlatTextPaneUI();
|
||||||
}
|
}
|
||||||
@@ -46,6 +49,17 @@ public class FlatTextPaneUI
|
|||||||
super.installDefaults();
|
super.installDefaults();
|
||||||
|
|
||||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
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
|
@Override
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ package com.formdev.flatlaf.ui;
|
|||||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ContainerEvent;
|
||||||
|
import java.awt.event.ContainerListener;
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
@@ -53,6 +55,29 @@ public class FlatToolBarUI
|
|||||||
rolloverBorder = null;
|
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
|
@Override
|
||||||
protected Border createRolloverBorder() {
|
protected Border createRolloverBorder() {
|
||||||
return getRolloverBorder();
|
return getRolloverBorder();
|
||||||
|
|||||||
@@ -17,7 +17,9 @@
|
|||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
@@ -61,6 +63,12 @@ public class FlatUIUtils
|
|||||||
r.height - insets.top - insets.bottom );
|
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 ) {
|
public static Color getUIColor( String key, int defaultColorRGB ) {
|
||||||
Color color = UIManager.getColor( key );
|
Color color = UIManager.getColor( key );
|
||||||
return (color != null) ? color : new Color( defaultColorRGB );
|
return (color != null) ? color : new Color( defaultColorRGB );
|
||||||
@@ -80,6 +88,10 @@ public class FlatUIUtils
|
|||||||
return (c instanceof ColorUIResource) ? new Color( c.getRGB(), true ) : c;
|
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.
|
* Sets rendering hints used for painting.
|
||||||
*/
|
*/
|
||||||
@@ -160,31 +172,67 @@ public class FlatUIUtils
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Shape createOutlinePath( float x, float y, float width, float height, float arc ) {
|
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 );
|
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 x2 = x + width;
|
||||||
float y2 = y + height;
|
float y2 = y + height;
|
||||||
|
|
||||||
Path2D rect = new Path2D.Float();
|
Path2D rect = new Path2D.Float();
|
||||||
rect.moveTo( x2 - arc, y );
|
rect.moveTo( x2 - arcTopRight, y );
|
||||||
rect.quadTo( x2, y, x2, y + arc );
|
rect.quadTo( x2, y, x2, y + arcTopRight );
|
||||||
rect.lineTo( x2, y2 - arc );
|
rect.lineTo( x2, y2 - arcBottomRight );
|
||||||
rect.quadTo( x2, y2, x2 - arc, y2 );
|
rect.quadTo( x2, y2, x2 - arcBottomRight, y2 );
|
||||||
rect.lineTo( x + arc, y2 );
|
rect.lineTo( x + arcBottomLeft, y2 );
|
||||||
rect.quadTo( x, y2, x, y2 - arc );
|
rect.quadTo( x, y2, x, y2 - arcBottomLeft );
|
||||||
rect.lineTo( x, y + arc );
|
rect.lineTo( x, y + arcTopLeft );
|
||||||
rect.quadTo( x, y, x + arc, y );
|
rect.quadTo( x, y, x + arcTopLeft, y );
|
||||||
rect.closePath();
|
rect.closePath();
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Path2D createPath( double... points ) {
|
public static Path2D createPath( double... points ) {
|
||||||
|
return createPath( true, points );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path2D createPath( boolean close, double... points ) {
|
||||||
Path2D path = new Path2D.Float();
|
Path2D path = new Path2D.Float();
|
||||||
path.moveTo( points[0], points[1] );
|
path.moveTo( points[0], points[1] );
|
||||||
for( int i = 2; i < points.length; i += 2 )
|
for( int i = 2; i < points.length; i += 2 )
|
||||||
path.lineTo( points[i], points[i + 1] );
|
path.lineTo( points[i], points[i + 1] );
|
||||||
|
if( close )
|
||||||
path.closePath();
|
path.closePath();
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ public class SystemInfo
|
|||||||
// Java VMs
|
// Java VMs
|
||||||
public static final boolean IS_JETBRAINS_JVM;
|
public static final boolean IS_JETBRAINS_JVM;
|
||||||
|
|
||||||
|
// UI toolkits
|
||||||
|
public static final boolean IS_KDE;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// platforms
|
// platforms
|
||||||
String osName = System.getProperty( "os.name" ).toLowerCase( Locale.ENGLISH );
|
String osName = System.getProperty( "os.name" ).toLowerCase( Locale.ENGLISH );
|
||||||
@@ -58,6 +61,9 @@ public class SystemInfo
|
|||||||
// Java VMs
|
// Java VMs
|
||||||
IS_JETBRAINS_JVM = System.getProperty( "java.vm.vendor", "Unknown" )
|
IS_JETBRAINS_JVM = System.getProperty( "java.vm.vendor", "Unknown" )
|
||||||
.toLowerCase( Locale.ENGLISH ).contains( "jetbrains" );
|
.toLowerCase( Locale.ENGLISH ).contains( "jetbrains" );
|
||||||
|
|
||||||
|
// UI toolkits
|
||||||
|
IS_KDE = (IS_LINUX && System.getenv( "KDE_FULL_SESSION" ) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long scanVersion( String version ) {
|
private static long scanVersion( String version ) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import java.lang.reflect.Method;
|
|||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.DimensionUIResource;
|
import javax.swing.plaf.DimensionUIResource;
|
||||||
|
import javax.swing.plaf.FontUIResource;
|
||||||
import javax.swing.plaf.InsetsUIResource;
|
import javax.swing.plaf.InsetsUIResource;
|
||||||
import javax.swing.plaf.UIResource;
|
import javax.swing.plaf.UIResource;
|
||||||
|
|
||||||
@@ -47,8 +48,7 @@ import javax.swing.plaf.UIResource;
|
|||||||
*
|
*
|
||||||
* 2) user scaling mode
|
* 2) user scaling mode
|
||||||
*
|
*
|
||||||
* This mode is for Java 8 compatibility and can be removed when changing minimum
|
* This mode is mainly for Java 8 compatibility, but is also used on Linux.
|
||||||
* required Java version to 9.
|
|
||||||
* The user scale factor is computed based on the used font.
|
* The user scale factor is computed based on the used font.
|
||||||
* The JRE does not scale anything.
|
* The JRE does not scale anything.
|
||||||
* So we have to invoke {@link #scale(float)} where necessary.
|
* So we have to invoke {@link #scale(float)} where necessary.
|
||||||
@@ -65,7 +65,7 @@ public class UIScale
|
|||||||
|
|
||||||
private static Boolean jreHiDPI;
|
private static Boolean jreHiDPI;
|
||||||
|
|
||||||
private static boolean isJreHiDPIEnabled() {
|
public static boolean isSystemScalingEnabled() {
|
||||||
if( jreHiDPI != null )
|
if( jreHiDPI != null )
|
||||||
return jreHiDPI;
|
return jreHiDPI;
|
||||||
|
|
||||||
@@ -93,19 +93,24 @@ public class UIScale
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double getSystemScaleFactor( Graphics2D g ) {
|
public static double getSystemScaleFactor( Graphics2D g ) {
|
||||||
return isJreHiDPIEnabled() ? g.getDeviceConfiguration().getDefaultTransform().getScaleX() : 1;
|
return isSystemScalingEnabled() ? g.getDeviceConfiguration().getDefaultTransform().getScaleX() : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getSystemScaleFactor( GraphicsConfiguration gc ) {
|
public static double getSystemScaleFactor( GraphicsConfiguration gc ) {
|
||||||
return isJreHiDPIEnabled() ? gc.getDefaultTransform().getScaleX() : 1;
|
return isSystemScalingEnabled() ? gc.getDefaultTransform().getScaleX() : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---- user scaling (Java 8) ----------------------------------------------
|
//---- user scaling (Java 8) ----------------------------------------------
|
||||||
|
|
||||||
private static float scaleFactor = 1;
|
private static float scaleFactor = 1;
|
||||||
|
private static boolean initialized;
|
||||||
|
|
||||||
static {
|
private static void initialize() {
|
||||||
if( isEnabled() ) {
|
if( initialized )
|
||||||
|
return;
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
if( isUserScalingEnabled() ) {
|
||||||
// listener to update scale factor if LaF changed or if Label.font changed
|
// listener to update scale factor if LaF changed or if Label.font changed
|
||||||
// (e.g. option "Override default fonts" in IntelliJ IDEA)
|
// (e.g. option "Override default fonts" in IntelliJ IDEA)
|
||||||
PropertyChangeListener listener = new PropertyChangeListener() {
|
PropertyChangeListener listener = new PropertyChangeListener() {
|
||||||
@@ -129,7 +134,7 @@ public class UIScale
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void updateScaleFactor() {
|
private static void updateScaleFactor() {
|
||||||
if( !isEnabled() )
|
if( !isUserScalingEnabled() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// use font size to calculate scale factor (instead of DPI)
|
// use font size to calculate scale factor (instead of DPI)
|
||||||
@@ -138,6 +143,10 @@ public class UIScale
|
|||||||
// (e.g. can avoid large icons with small text)
|
// (e.g. can avoid large icons with small text)
|
||||||
Font font = UIManager.getFont( "Label.font" );
|
Font font = UIManager.getFont( "Label.font" );
|
||||||
|
|
||||||
|
setUserScaleFactor( computeScaleFactor( font ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float computeScaleFactor( Font font ) {
|
||||||
// default font size
|
// default font size
|
||||||
float fontSizeDivider = 12f;
|
float fontSizeDivider = 12f;
|
||||||
|
|
||||||
@@ -148,15 +157,15 @@ public class UIScale
|
|||||||
if( "Tahoma".equals( font.getFamily() ) )
|
if( "Tahoma".equals( font.getFamily() ) )
|
||||||
fontSizeDivider = 11f;
|
fontSizeDivider = 11f;
|
||||||
} else if( SystemInfo.IS_LINUX ) {
|
} else if( SystemInfo.IS_LINUX ) {
|
||||||
// default font size for Unity and Gnome is 15
|
// default font size for Unity and Gnome is 15 and for KDE it is 13
|
||||||
fontSizeDivider = 15f;
|
fontSizeDivider = SystemInfo.IS_KDE ? 13f : 15f;
|
||||||
}
|
}
|
||||||
|
|
||||||
setUserScaleFactor( font.getSize() / fontSizeDivider );
|
return font.getSize() / fontSizeDivider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isEnabled() {
|
private static boolean isUserScalingEnabled() {
|
||||||
if( isJreHiDPIEnabled() )
|
if( isSystemScalingEnabled() && !SystemInfo.IS_LINUX )
|
||||||
return false; // disable user scaling if JRE scales
|
return false; // disable user scaling if JRE scales
|
||||||
|
|
||||||
// same as in IntelliJ IDEA
|
// same as in IntelliJ IDEA
|
||||||
@@ -164,7 +173,58 @@ public class UIScale
|
|||||||
return (hidpi != null) ? Boolean.parseBoolean( hidpi ) : true;
|
return (hidpi != null) ? Boolean.parseBoolean( hidpi ) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a custom scale factor given in system properties "flatlaf.uiScale"
|
||||||
|
* or "sun.java2d.uiScale" to the given font.
|
||||||
|
*/
|
||||||
|
public static FontUIResource applyCustomScaleFactor( FontUIResource font ) {
|
||||||
|
if( UIScale.isSystemScalingEnabled() )
|
||||||
|
return font;
|
||||||
|
|
||||||
|
String uiScale = System.getProperty( "flatlaf.uiScale" );
|
||||||
|
if( uiScale == null )
|
||||||
|
uiScale = System.getProperty( "sun.java2d.uiScale" );
|
||||||
|
|
||||||
|
float scaleFactor = parseScaleFactor( uiScale );
|
||||||
|
if( scaleFactor <= 0 )
|
||||||
|
return font;
|
||||||
|
|
||||||
|
float fontScaleFactor = computeScaleFactor( font );
|
||||||
|
if( scaleFactor == fontScaleFactor )
|
||||||
|
return font;
|
||||||
|
|
||||||
|
int newFontSize = Math.round( (font.getSize() / fontScaleFactor) * scaleFactor );
|
||||||
|
return new FontUIResource( font.getFamily(), font.getStyle(), newFontSize );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to sun.java2d.SunGraphicsEnvironment.getScaleFactor(String)
|
||||||
|
*/
|
||||||
|
private static float parseScaleFactor( String s ) {
|
||||||
|
if( s == null )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
float units = 1;
|
||||||
|
if( s.endsWith( "x" ) )
|
||||||
|
s = s.substring( 0, s.length() - 1 );
|
||||||
|
else if( s.endsWith( "dpi" ) ) {
|
||||||
|
units = 96;
|
||||||
|
s = s.substring( 0, s.length() - 3 );
|
||||||
|
} else if( s.endsWith( "%" ) ) {
|
||||||
|
units = 100;
|
||||||
|
s = s.substring( 0, s.length() - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
float scale = Float.parseFloat( s );
|
||||||
|
return scale > 0 ? scale / units : -1;
|
||||||
|
} catch( NumberFormatException ex ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static float getUserScaleFactor() {
|
public static float getUserScaleFactor() {
|
||||||
|
initialize();
|
||||||
return scaleFactor;
|
return scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,10 +241,12 @@ public class UIScale
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static float scale( float value ) {
|
public static float scale( float value ) {
|
||||||
|
initialize();
|
||||||
return (scaleFactor == 1) ? value : (value * scaleFactor);
|
return (scaleFactor == 1) ? value : (value * scaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int scale( int value ) {
|
public static int scale( int value ) {
|
||||||
|
initialize();
|
||||||
return (scaleFactor == 1) ? value : Math.round( value * scaleFactor );
|
return (scaleFactor == 1) ? value : Math.round( value * scaleFactor );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,23 +254,28 @@ public class UIScale
|
|||||||
* Similar as scale(int) but always "rounds down".
|
* Similar as scale(int) but always "rounds down".
|
||||||
*/
|
*/
|
||||||
public static int scale2( int value ) {
|
public static int scale2( int value ) {
|
||||||
|
initialize();
|
||||||
return (scaleFactor == 1) ? value : (int) (value * scaleFactor);
|
return (scaleFactor == 1) ? value : (int) (value * scaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float unscale( float value ) {
|
public static float unscale( float value ) {
|
||||||
|
initialize();
|
||||||
return (scaleFactor == 1f) ? value : (value / scaleFactor);
|
return (scaleFactor == 1f) ? value : (value / scaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int unscale( int value ) {
|
public static int unscale( int value ) {
|
||||||
|
initialize();
|
||||||
return (scaleFactor == 1f) ? value : Math.round( value / scaleFactor );
|
return (scaleFactor == 1f) ? value : Math.round( value / scaleFactor );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void scaleGraphics( Graphics2D g ) {
|
public static void scaleGraphics( Graphics2D g ) {
|
||||||
|
initialize();
|
||||||
if( scaleFactor != 1f )
|
if( scaleFactor != 1f )
|
||||||
g.scale( scaleFactor, scaleFactor );
|
g.scale( scaleFactor, scaleFactor );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dimension scale( Dimension dimension ) {
|
public static Dimension scale( Dimension dimension ) {
|
||||||
|
initialize();
|
||||||
return (dimension == null || scaleFactor == 1f)
|
return (dimension == null || scaleFactor == 1f)
|
||||||
? dimension
|
? dimension
|
||||||
: (dimension instanceof UIResource
|
: (dimension instanceof UIResource
|
||||||
@@ -217,6 +284,7 @@ public class UIScale
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Insets scale( Insets insets ) {
|
public static Insets scale( Insets insets ) {
|
||||||
|
initialize();
|
||||||
return (insets == null || scaleFactor == 1f)
|
return (insets == null || scaleFactor == 1f)
|
||||||
? insets
|
? insets
|
||||||
: (insets instanceof UIResource
|
: (insets instanceof UIResource
|
||||||
|
|||||||
27
flatlaf-core/src/main/module-info/module-info.java
Normal file
27
flatlaf-core/src/main/module-info/module-info.java
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
module com.formdev.flatlaf {
|
||||||
|
requires java.desktop;
|
||||||
|
|
||||||
|
exports com.formdev.flatlaf;
|
||||||
|
exports com.formdev.flatlaf.icons;
|
||||||
|
exports com.formdev.flatlaf.ui;
|
||||||
|
exports com.formdev.flatlaf.util;
|
||||||
|
}
|
||||||
@@ -18,9 +18,16 @@
|
|||||||
# which is licensed under the Apache 2.0 license. Copyright 2000-2019 JetBrains s.r.o.
|
# which is licensed under the Apache 2.0 license. Copyright 2000-2019 JetBrains s.r.o.
|
||||||
# See: https://github.com/JetBrains/intellij-community/
|
# See: https://github.com/JetBrains/intellij-community/
|
||||||
|
|
||||||
|
#---- Button ----
|
||||||
|
|
||||||
|
Button.default.boldText=true
|
||||||
|
|
||||||
|
|
||||||
#---- Component ----
|
#---- Component ----
|
||||||
|
|
||||||
Component.focusWidth=2
|
Component.focusWidth=2
|
||||||
|
Component.innerFocusWidth=0
|
||||||
|
Component.arrowType=triangle
|
||||||
|
|
||||||
|
|
||||||
#---- RadioButton ----
|
#---- RadioButton ----
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ Button.default.borderColor=4c708c
|
|||||||
Button.default.hoverBorderColor=537699
|
Button.default.hoverBorderColor=537699
|
||||||
Button.default.focusedBorderColor=537699
|
Button.default.focusedBorderColor=537699
|
||||||
Button.default.focusColor=43688c
|
Button.default.focusColor=43688c
|
||||||
|
Button.default.boldText=true
|
||||||
|
|
||||||
Button.toolbar.hoverBackground=4c5052
|
Button.toolbar.hoverBackground=4c5052
|
||||||
Button.toolbar.pressedBackground=555a5d
|
Button.toolbar.pressedBackground=555a5d
|
||||||
@@ -226,7 +227,8 @@ ToggleButton.toolbar.selectedBackground=5c6164
|
|||||||
|
|
||||||
#---- ToolTip ----
|
#---- ToolTip ----
|
||||||
|
|
||||||
ToolTip.background=4b4d4d
|
ToolTip.border=4,6,4,6
|
||||||
|
ToolTip.background=1e2123
|
||||||
|
|
||||||
|
|
||||||
#---- Tree ----
|
#---- Tree ----
|
||||||
|
|||||||
@@ -22,6 +22,17 @@
|
|||||||
|
|
||||||
Button.focusedBackground=null
|
Button.focusedBackground=null
|
||||||
|
|
||||||
|
Button.default.background=4A86C7
|
||||||
|
Button.default.foreground=f0f0f0
|
||||||
|
Button.default.focusedBackground=null
|
||||||
|
Button.default.hoverBackground=5B91CC
|
||||||
|
Button.default.pressedBackground=6E9ED2
|
||||||
|
Button.default.borderColor=3167ad
|
||||||
|
Button.default.hoverBorderColor=a8cef6
|
||||||
|
Button.default.focusedBorderColor=a8cef6
|
||||||
|
Button.default.focusColor=97c3f3
|
||||||
|
Button.default.boldText=true
|
||||||
|
|
||||||
|
|
||||||
#---- CheckBox ----
|
#---- CheckBox ----
|
||||||
|
|
||||||
@@ -37,6 +48,8 @@ CheckBox.icon.selectedPressedBackground=72A1D4
|
|||||||
#---- Component ----
|
#---- Component ----
|
||||||
|
|
||||||
Component.focusWidth=2
|
Component.focusWidth=2
|
||||||
|
Component.innerFocusWidth=0
|
||||||
|
Component.arrowType=triangle
|
||||||
|
|
||||||
|
|
||||||
#---- RadioButton ----
|
#---- RadioButton ----
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ Button.iconTextGap=4
|
|||||||
Button.rollover=true
|
Button.rollover=true
|
||||||
Button.defaultButtonFollowsFocus=false
|
Button.defaultButtonFollowsFocus=false
|
||||||
|
|
||||||
|
Button.default.borderWidth=1
|
||||||
|
|
||||||
|
|
||||||
#---- CheckBox ----
|
#---- CheckBox ----
|
||||||
|
|
||||||
@@ -103,8 +105,11 @@ ComboBox.padding=2,6,2,6
|
|||||||
#---- Component ----
|
#---- Component ----
|
||||||
|
|
||||||
Component.focusWidth=0
|
Component.focusWidth=0
|
||||||
|
Component.innerFocusWidth=0
|
||||||
Component.arc=5
|
Component.arc=5
|
||||||
Component.minimumWidth=64
|
Component.minimumWidth=64
|
||||||
|
Component.arrowType=chevron
|
||||||
|
Component.hideMnemonics=true
|
||||||
|
|
||||||
|
|
||||||
#---- EditorPane ----
|
#---- EditorPane ----
|
||||||
@@ -207,7 +212,7 @@ OptionPane.maxCharactersPerLine=80
|
|||||||
OptionPane.iconMessageGap=16
|
OptionPane.iconMessageGap=16
|
||||||
OptionPane.messagePadding=3
|
OptionPane.messagePadding=3
|
||||||
OptionPane.buttonPadding=8
|
OptionPane.buttonPadding=8
|
||||||
OptionPane.buttonMinimumWidth=72
|
OptionPane.buttonMinimumWidth={scaledNumber}72
|
||||||
OptionPane.sameSizeButtons=true
|
OptionPane.sameSizeButtons=true
|
||||||
OptionPane.setButtonMargin=false
|
OptionPane.setButtonMargin=false
|
||||||
OptionPane.buttonOrientation=4
|
OptionPane.buttonOrientation=4
|
||||||
@@ -302,10 +307,12 @@ Spinner.editorBorderPainted=false
|
|||||||
|
|
||||||
#---- SplitPane ----
|
#---- SplitPane ----
|
||||||
|
|
||||||
SplitPane.dividerSize=5
|
SplitPane.dividerSize={integer}5
|
||||||
SplitPane.continuousLayout=true
|
SplitPane.continuousLayout=true
|
||||||
SplitPane.border=null
|
SplitPane.border=null
|
||||||
SplitPane.centerOneTouchButtons=true
|
SplitPane.centerOneTouchButtons=true
|
||||||
|
SplitPane.oneTouchButtonSize={scaledNumber}6
|
||||||
|
SplitPane.oneTouchButtonOffset={scaledNumber}2
|
||||||
|
|
||||||
SplitPaneDivider.border=null
|
SplitPaneDivider.border=null
|
||||||
SplitPaneDivider.oneTouchArrowColor=@@ComboBox.buttonArrowColor
|
SplitPaneDivider.oneTouchArrowColor=@@ComboBox.buttonArrowColor
|
||||||
@@ -402,7 +409,9 @@ ToolBar.separatorColor=@@Separator.foreground
|
|||||||
|
|
||||||
#---- ToolTip ----
|
#---- ToolTip ----
|
||||||
|
|
||||||
ToolTip.border=2,6,2,6,@@Component.borderColor
|
ToolTip.borderInactive=null
|
||||||
|
ToolTip.backgroundInactive=@@ToolTip.background
|
||||||
|
ToolTip.foregroundInactive=@disabledText
|
||||||
|
|
||||||
|
|
||||||
#---- Tree ----
|
#---- Tree ----
|
||||||
|
|||||||
@@ -72,14 +72,16 @@ Button.disabledBorderColor=cfcfcf
|
|||||||
Button.focusedBorderColor=87afda
|
Button.focusedBorderColor=87afda
|
||||||
Button.hoverBorderColor=@@Button.focusedBorderColor
|
Button.hoverBorderColor=@@Button.focusedBorderColor
|
||||||
|
|
||||||
Button.default.background=4A86C7
|
Button.default.background=@@Button.background
|
||||||
Button.default.foreground=f0f0f0
|
Button.default.foreground=@foreground
|
||||||
Button.default.hoverBackground=5B91CC
|
Button.default.focusedBackground=@@Button.focusedBackground
|
||||||
Button.default.pressedBackground=6E9ED2
|
Button.default.hoverBackground=@@Button.hoverBackground
|
||||||
Button.default.borderColor=3167ad
|
Button.default.pressedBackground=@@Button.pressedBackground
|
||||||
Button.default.hoverBorderColor=a8cef6
|
Button.default.borderColor=4D89C9
|
||||||
Button.default.focusedBorderColor=a8cef6
|
Button.default.hoverBorderColor=@@Button.hoverBorderColor
|
||||||
Button.default.focusColor=97c3f3
|
Button.default.focusedBorderColor=@@Button.focusedBorderColor
|
||||||
|
Button.default.focusColor=@@Component.focusColor
|
||||||
|
Button.default.borderWidth=2
|
||||||
|
|
||||||
Button.toolbar.hoverBackground=dfdfdf
|
Button.toolbar.hoverBackground=dfdfdf
|
||||||
Button.toolbar.pressedBackground=d8d8d8
|
Button.toolbar.pressedBackground=d8d8d8
|
||||||
@@ -232,7 +234,8 @@ ToggleButton.toolbar.selectedBackground=cfcfcf
|
|||||||
|
|
||||||
#---- ToolTip ----
|
#---- ToolTip ----
|
||||||
|
|
||||||
ToolTip.background=f7f7f7
|
ToolTip.border=4,6,4,6,@@Component.borderColor
|
||||||
|
ToolTip.background=fafafa
|
||||||
|
|
||||||
|
|
||||||
#---- Tree ----
|
#---- Tree ----
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public class FlatComponentsTest
|
|||||||
FlatComponentsTest.TestDefaultButton button5 = new FlatComponentsTest.TestDefaultButton();
|
FlatComponentsTest.TestDefaultButton button5 = new FlatComponentsTest.TestDefaultButton();
|
||||||
JButton button3 = new JButton();
|
JButton button3 = new JButton();
|
||||||
JButton button12 = new JButton();
|
JButton button12 = new JButton();
|
||||||
|
JButton button13 = new JButton();
|
||||||
JLabel toggleButtonLabel = new JLabel();
|
JLabel toggleButtonLabel = new JLabel();
|
||||||
JToggleButton toggleButton1 = new JToggleButton();
|
JToggleButton toggleButton1 = new JToggleButton();
|
||||||
JToggleButton toggleButton2 = new JToggleButton();
|
JToggleButton toggleButton2 = new JToggleButton();
|
||||||
@@ -142,7 +143,14 @@ public class FlatComponentsTest
|
|||||||
JToggleButton toggleButton7 = new JToggleButton();
|
JToggleButton toggleButton7 = new JToggleButton();
|
||||||
JLabel scrollBarLabel = new JLabel();
|
JLabel scrollBarLabel = new JLabel();
|
||||||
JScrollBar scrollBar1 = new JScrollBar();
|
JScrollBar scrollBar1 = new JScrollBar();
|
||||||
|
JLabel label4 = new JLabel();
|
||||||
JScrollBar scrollBar4 = new JScrollBar();
|
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();
|
JLabel separatorLabel = new JLabel();
|
||||||
JSeparator separator1 = new JSeparator();
|
JSeparator separator1 = new JSeparator();
|
||||||
JPanel panel2 = new JPanel();
|
JPanel panel2 = new JPanel();
|
||||||
@@ -222,12 +230,14 @@ public class FlatComponentsTest
|
|||||||
//---- button1 ----
|
//---- button1 ----
|
||||||
button1.setText("enabled");
|
button1.setText("enabled");
|
||||||
button1.setDisplayedMnemonicIndex(0);
|
button1.setDisplayedMnemonicIndex(0);
|
||||||
|
button1.setToolTipText("This button is enabled.");
|
||||||
add(button1, "cell 1 1");
|
add(button1, "cell 1 1");
|
||||||
|
|
||||||
//---- button2 ----
|
//---- button2 ----
|
||||||
button2.setText("disabled");
|
button2.setText("disabled");
|
||||||
button2.setDisplayedMnemonicIndex(0);
|
button2.setDisplayedMnemonicIndex(0);
|
||||||
button2.setEnabled(false);
|
button2.setEnabled(false);
|
||||||
|
button2.setToolTipText("This button is disabled.");
|
||||||
add(button2, "cell 2 1");
|
add(button2, "cell 2 1");
|
||||||
|
|
||||||
//---- button5 ----
|
//---- button5 ----
|
||||||
@@ -246,6 +256,10 @@ public class FlatComponentsTest
|
|||||||
button12.setEnabled(false);
|
button12.setEnabled(false);
|
||||||
add(button12, "cell 4 1");
|
add(button12, "cell 4 1");
|
||||||
|
|
||||||
|
//---- button13 ----
|
||||||
|
button13.setIcon(UIManager.getIcon("Tree.closedIcon"));
|
||||||
|
add(button13, "cell 5 1");
|
||||||
|
|
||||||
//---- toggleButtonLabel ----
|
//---- toggleButtonLabel ----
|
||||||
toggleButtonLabel.setText("JToggleButton:");
|
toggleButtonLabel.setText("JToggleButton:");
|
||||||
add(toggleButtonLabel, "cell 0 2");
|
add(toggleButtonLabel, "cell 0 2");
|
||||||
@@ -714,11 +728,52 @@ public class FlatComponentsTest
|
|||||||
scrollBar1.setOrientation(Adjustable.HORIZONTAL);
|
scrollBar1.setOrientation(Adjustable.HORIZONTAL);
|
||||||
add(scrollBar1, "cell 1 14,growx");
|
add(scrollBar1, "cell 1 14,growx");
|
||||||
|
|
||||||
|
//---- label4 ----
|
||||||
|
label4.setText("HTML:");
|
||||||
|
add(label4, "cell 5 14");
|
||||||
|
|
||||||
//---- scrollBar4 ----
|
//---- scrollBar4 ----
|
||||||
scrollBar4.setOrientation(Adjustable.HORIZONTAL);
|
scrollBar4.setOrientation(Adjustable.HORIZONTAL);
|
||||||
scrollBar4.setEnabled(false);
|
scrollBar4.setEnabled(false);
|
||||||
add(scrollBar4, "cell 1 15,growx");
|
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 ----
|
||||||
separatorLabel.setText("JSeparator:");
|
separatorLabel.setText("JSeparator:");
|
||||||
add(separatorLabel, "cell 0 16");
|
add(separatorLabel, "cell 0 16");
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ new FormModel {
|
|||||||
name: "button1"
|
name: "button1"
|
||||||
"text": "enabled"
|
"text": "enabled"
|
||||||
"displayedMnemonicIndex": 0
|
"displayedMnemonicIndex": 0
|
||||||
|
"toolTipText": "This button is enabled."
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 1"
|
"value": "cell 1 1"
|
||||||
} )
|
} )
|
||||||
@@ -51,6 +52,7 @@ new FormModel {
|
|||||||
"text": "disabled"
|
"text": "disabled"
|
||||||
"displayedMnemonicIndex": 0
|
"displayedMnemonicIndex": 0
|
||||||
"enabled": false
|
"enabled": false
|
||||||
|
"toolTipText": "This button is disabled."
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 2 1"
|
"value": "cell 2 1"
|
||||||
} )
|
} )
|
||||||
@@ -76,6 +78,12 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 1"
|
"value": "cell 4 1"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
|
name: "button13"
|
||||||
|
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 5 1"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "toggleButtonLabel"
|
name: "toggleButtonLabel"
|
||||||
"text": "JToggleButton:"
|
"text": "JToggleButton:"
|
||||||
@@ -672,6 +680,12 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 14,growx"
|
"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" ) {
|
add( new FormComponent( "javax.swing.JScrollBar" ) {
|
||||||
name: "scrollBar4"
|
name: "scrollBar4"
|
||||||
"orientation": 0
|
"orientation": 0
|
||||||
@@ -679,6 +693,41 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 15,growx"
|
"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" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "separatorLabel"
|
name: "separatorLabel"
|
||||||
"text": "JSeparator:"
|
"text": "JSeparator:"
|
||||||
@@ -831,7 +880,7 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
"size": new java.awt.Dimension( 790, 715 )
|
"size": new java.awt.Dimension( 790, 750 )
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.awt.Dimension;
|
|||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
@@ -41,6 +42,7 @@ import javax.swing.border.LineBorder;
|
|||||||
import javax.swing.plaf.UIResource;
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
import com.formdev.flatlaf.ui.FlatToolTipUI;
|
import com.formdev.flatlaf.ui.FlatToolTipUI;
|
||||||
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,7 +105,7 @@ public class FlatInspector
|
|||||||
private void inspect( int x, int y ) {
|
private void inspect( int x, int y ) {
|
||||||
Container contentPane = rootPane.getContentPane();
|
Container contentPane = rootPane.getContentPane();
|
||||||
Component c = SwingUtilities.getDeepestComponentAt( contentPane, x, y );
|
Component c = SwingUtilities.getDeepestComponentAt( contentPane, x, y );
|
||||||
if( c == contentPane || c.getParent() == contentPane )
|
if( c == contentPane || (c != null && c.getParent() == contentPane) )
|
||||||
c = null;
|
c = null;
|
||||||
|
|
||||||
if( c == lastComponent )
|
if( c == lastComponent )
|
||||||
@@ -137,6 +139,12 @@ public class FlatInspector
|
|||||||
g.setColor( getBackground() );
|
g.setColor( getBackground() );
|
||||||
g.fillRect( 0, 0, getWidth(), getHeight() );
|
g.fillRect( 0, 0, getWidth(), getHeight() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintBorder( Graphics g ) {
|
||||||
|
FlatUIUtils.setRenderingHints( (Graphics2D) g );
|
||||||
|
super.paintBorder( g );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
c.setBackground( new Color( 255, 0, 0, 32 ) );
|
c.setBackground( new Color( 255, 0, 0, 32 ) );
|
||||||
c.setBorder( new LineBorder( Color.red ) );
|
c.setBorder( new LineBorder( Color.red ) );
|
||||||
@@ -228,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();
|
text += "Parent: " + c.getParent().getClass().getName();
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class FlatOptionPaneTest
|
|||||||
//---- warningOptionPane ----
|
//---- warningOptionPane ----
|
||||||
warningOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE);
|
warningOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE);
|
||||||
warningOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
|
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);
|
panel5.add(warningOptionPane, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
add(panel5, "cell 1 4");
|
add(panel5, "cell 1 4");
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ new FormModel {
|
|||||||
name: "warningOptionPane"
|
name: "warningOptionPane"
|
||||||
"messageType": 2
|
"messageType": 2
|
||||||
"optionType": 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 ) {
|
}, new FormLayoutConstraints( class java.lang.String ) {
|
||||||
"value": "Center"
|
"value": "Center"
|
||||||
} )
|
} )
|
||||||
|
|||||||
@@ -17,13 +17,20 @@
|
|||||||
package com.formdev.flatlaf;
|
package com.formdev.flatlaf;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.plaf.ColorUIResource;
|
import javax.swing.plaf.ColorUIResource;
|
||||||
import javax.swing.plaf.metal.MetalLookAndFeel;
|
import javax.swing.plaf.metal.MetalLookAndFeel;
|
||||||
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
|
||||||
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
import com.formdev.flatlaf.util.SystemInfo;
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
import net.miginfocom.swing.*;
|
import net.miginfocom.swing.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,47 +41,53 @@ public class FlatTestFrame
|
|||||||
{
|
{
|
||||||
private static final String PREFS_ROOT_PATH = "/flatlaf-test";
|
private static final String PREFS_ROOT_PATH = "/flatlaf-test";
|
||||||
private static final String KEY_LAF = "laf";
|
private static final String KEY_LAF = "laf";
|
||||||
|
private static final String KEY_SCALE_FACTOR = "scaleFactor";
|
||||||
|
|
||||||
|
private final String title;
|
||||||
private JComponent content;
|
private JComponent content;
|
||||||
private FlatInspector inspector;
|
private FlatInspector inspector;
|
||||||
|
|
||||||
public static FlatTestFrame create( String[] args, String title ) {
|
public static FlatTestFrame create( String[] args, String title ) {
|
||||||
|
Preferences prefs = Preferences.userRoot().node( PREFS_ROOT_PATH );
|
||||||
|
|
||||||
|
// set scale factor
|
||||||
|
if( System.getProperty( "flatlaf.uiScale", System.getProperty( "sun.java2d.uiScale" ) ) == null ) {
|
||||||
|
String scaleFactor = prefs.get( KEY_SCALE_FACTOR, null );
|
||||||
|
if( scaleFactor != null )
|
||||||
|
System.setProperty( "flatlaf.uiScale", scaleFactor );
|
||||||
|
}
|
||||||
|
|
||||||
// set look and feel
|
// set look and feel
|
||||||
try {
|
try {
|
||||||
if( args.length > 0 )
|
if( args.length > 0 )
|
||||||
UIManager.setLookAndFeel( args[0] );
|
UIManager.setLookAndFeel( args[0] );
|
||||||
else {
|
else {
|
||||||
String lafClassName = Preferences.userRoot().node( PREFS_ROOT_PATH )
|
String lafClassName = prefs.get( KEY_LAF, FlatLightLaf.class.getName() );
|
||||||
.get( KEY_LAF, FlatLightLaf.class.getName() );
|
|
||||||
UIManager.setLookAndFeel( lafClassName );
|
UIManager.setLookAndFeel( lafClassName );
|
||||||
}
|
}
|
||||||
} catch( Exception ex ) {
|
} catch( Exception ex ) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
|
||||||
// fallback
|
// fallback
|
||||||
try {
|
FlatLightLaf.install();
|
||||||
UIManager.setLookAndFeel( new FlatLightLaf() );
|
|
||||||
} catch( Exception ex2 ) {
|
|
||||||
ex2.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create frame
|
// create frame
|
||||||
FlatTestFrame frame = new FlatTestFrame();
|
return new FlatTestFrame( title );
|
||||||
frame.setTitle( title + " (Java " + System.getProperty( "java.version" ) + ")" );
|
|
||||||
return frame;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlatTestFrame() {
|
private FlatTestFrame( String title ) {
|
||||||
|
this.title = title;
|
||||||
|
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
// initialize look and feels combo box
|
// initialize look and feels combo box
|
||||||
DefaultComboBoxModel<LafInfo> lafModel = new DefaultComboBoxModel<>();
|
DefaultComboBoxModel<LafInfo> lafModel = new DefaultComboBoxModel<>();
|
||||||
lafModel.addElement( new LafInfo( "Flat Light (F1)", FlatLightLaf.class.getName() ) );
|
lafModel.addElement( new LafInfo( "Flat Light (F1)", FlatLightLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat Dark (F2)", FlatDarkLaf.class.getName() ) );
|
lafModel.addElement( new LafInfo( "Flat Dark (F2)", FlatDarkLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat Test (F3)", FlatTestLaf.class.getName() ) );
|
lafModel.addElement( new LafInfo( "Flat IntelliJ (F3)", FlatIntelliJLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat IntelliJ (F4)", FlatIntelliJLaf.class.getName() ) );
|
lafModel.addElement( new LafInfo( "Flat Darcula (F4)", FlatDarculaLaf.class.getName() ) );
|
||||||
lafModel.addElement( new LafInfo( "Flat Darcula (F5)", FlatDarculaLaf.class.getName() ) );
|
lafModel.addElement( new LafInfo( "Flat Test (F8)", FlatTestLaf.class.getName() ) );
|
||||||
|
|
||||||
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
|
UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels();
|
||||||
for( UIManager.LookAndFeelInfo lookAndFeel : lookAndFeels ) {
|
for( UIManager.LookAndFeelInfo lookAndFeel : lookAndFeels ) {
|
||||||
@@ -85,7 +98,8 @@ public class FlatTestFrame
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( (SystemInfo.IS_WINDOWS && className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" )) ||
|
if( (SystemInfo.IS_WINDOWS && className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" )) ||
|
||||||
(SystemInfo.IS_MAC && className.equals( "com.apple.laf.AquaLookAndFeel") ) )
|
(SystemInfo.IS_MAC && className.equals( "com.apple.laf.AquaLookAndFeel") ) ||
|
||||||
|
(SystemInfo.IS_LINUX && className.equals( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel") ) )
|
||||||
name += " (F9)";
|
name += " (F9)";
|
||||||
else if( className.equals( MetalLookAndFeel.class.getName() ) )
|
else if( className.equals( MetalLookAndFeel.class.getName() ) )
|
||||||
name += " (F10)";
|
name += " (F10)";
|
||||||
@@ -106,17 +120,25 @@ public class FlatTestFrame
|
|||||||
|
|
||||||
lookAndFeelComboBox.setModel( lafModel );
|
lookAndFeelComboBox.setModel( lafModel );
|
||||||
|
|
||||||
// register F1, F2 and F3 keys to switch to Light, Dark or Test LaF
|
updateScaleFactorComboBox();
|
||||||
|
String scaleFactor = System.getProperty( "flatlaf.uiScale", System.getProperty( "sun.java2d.uiScale" ) );
|
||||||
|
if( scaleFactor != null )
|
||||||
|
scaleFactorComboBox.setSelectedItem( scaleFactor );
|
||||||
|
|
||||||
|
// register F1, F2, ... keys to switch to Light, Dark or other LaFs
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F1, FlatLightLaf.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F1, FlatLightLaf.class.getName() );
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F2, FlatDarkLaf.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F2, FlatDarkLaf.class.getName() );
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F3, FlatTestLaf.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F3, FlatIntelliJLaf.class.getName() );
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F4, FlatIntelliJLaf.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F4, FlatDarculaLaf.class.getName() );
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F5, FlatDarculaLaf.class.getName() );
|
|
||||||
|
registerSwitchToLookAndFeel( KeyEvent.VK_F8, FlatTestLaf.class.getName() );
|
||||||
|
|
||||||
if( SystemInfo.IS_WINDOWS )
|
if( SystemInfo.IS_WINDOWS )
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
|
||||||
else if( SystemInfo.IS_MAC )
|
else if( SystemInfo.IS_MAC )
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.apple.laf.AquaLookAndFeel" );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.apple.laf.AquaLookAndFeel" );
|
||||||
|
else if( SystemInfo.IS_LINUX )
|
||||||
|
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" );
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F10, MetalLookAndFeel.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F10, MetalLookAndFeel.class.getName() );
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F11, NimbusLookAndFeel.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F11, NimbusLookAndFeel.class.getName() );
|
||||||
|
|
||||||
@@ -130,6 +152,47 @@ public class FlatTestFrame
|
|||||||
|
|
||||||
// close frame
|
// close frame
|
||||||
closeButton.addActionListener(e -> dispose());
|
closeButton.addActionListener(e -> dispose());
|
||||||
|
|
||||||
|
// update title
|
||||||
|
addWindowListener( new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowOpened( WindowEvent e ) {
|
||||||
|
updateTitle();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
// update title when moved to another screen
|
||||||
|
addComponentListener( new ComponentAdapter() {
|
||||||
|
@Override
|
||||||
|
public void componentMoved( ComponentEvent e ) {
|
||||||
|
updateTitle();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
UIManager.addPropertyChangeListener( e -> {
|
||||||
|
if( "lookAndFeel".equals( e.getPropertyName() ) ) {
|
||||||
|
EventQueue.invokeLater( () -> {
|
||||||
|
// update title because user scale factor may change
|
||||||
|
updateTitle();
|
||||||
|
|
||||||
|
// enable/disable scale factor combobox
|
||||||
|
updateScaleFactorComboBox();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTitle() {
|
||||||
|
double systemScaleFactor = UIScale.getSystemScaleFactor( getGraphicsConfiguration() );
|
||||||
|
float userScaleFactor = UIScale.getUserScaleFactor();
|
||||||
|
String newTitle = title + " (Java " + System.getProperty( "java.version" )
|
||||||
|
+ (systemScaleFactor != 1 ? ("; system scale factor " + systemScaleFactor) : "")
|
||||||
|
+ (userScaleFactor != 1 ? ("; user scale factor " + userScaleFactor) : "")
|
||||||
|
+ (systemScaleFactor == 1 && userScaleFactor == 1 ? "; no scaling" : "")
|
||||||
|
+ ")";
|
||||||
|
|
||||||
|
if( !newTitle.equals( getTitle() ) )
|
||||||
|
setTitle( newTitle );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerSwitchToLookAndFeel( int keyCode, String lafClassName ) {
|
private void registerSwitchToLookAndFeel( int keyCode, String lafClassName ) {
|
||||||
@@ -141,7 +204,7 @@ public class FlatTestFrame
|
|||||||
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void showFrame( JComponent content ) {
|
public void showFrame( JComponent content ) {
|
||||||
this.content = content;
|
this.content = content;
|
||||||
|
|
||||||
contentPanel.getContentPane().add( content );
|
contentPanel.getContentPane().add( content );
|
||||||
@@ -169,22 +232,48 @@ public class FlatTestFrame
|
|||||||
if( newLaf.className.equals( UIManager.getLookAndFeel().getClass().getName() ) )
|
if( newLaf.className.equals( UIManager.getLookAndFeel().getClass().getName() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// hide popup to avoid occasional StackOverflowError when updating UI
|
||||||
|
lookAndFeelComboBox.setPopupVisible( false );
|
||||||
|
|
||||||
Preferences.userRoot().node( PREFS_ROOT_PATH ).put( KEY_LAF, newLaf.className );
|
Preferences.userRoot().node( PREFS_ROOT_PATH ).put( KEY_LAF, newLaf.className );
|
||||||
|
|
||||||
|
applyLookAndFeel( newLaf.className, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyLookAndFeel( String lafClassName, boolean pack ) {
|
||||||
EventQueue.invokeLater( () -> {
|
EventQueue.invokeLater( () -> {
|
||||||
try {
|
try {
|
||||||
// change look and feel
|
// change look and feel
|
||||||
UIManager.setLookAndFeel( newLaf.className );
|
UIManager.setLookAndFeel( lafClassName );
|
||||||
|
|
||||||
// update all components
|
// update all components
|
||||||
SwingUtilities.updateComponentTreeUI( this );
|
FlatLaf.updateUI();
|
||||||
|
|
||||||
// increase size of frame if necessary
|
// increase size of frame if necessary
|
||||||
|
if( pack )
|
||||||
|
pack();
|
||||||
|
else {
|
||||||
int width = getWidth();
|
int width = getWidth();
|
||||||
int height = getHeight();
|
int height = getHeight();
|
||||||
Dimension prefSize = getPreferredSize();
|
Dimension prefSize = getPreferredSize();
|
||||||
if( prefSize.width > width || prefSize.height > height )
|
if( prefSize.width > width || prefSize.height > height )
|
||||||
setSize( Math.max( prefSize.width, width ), Math.max( prefSize.height, height ) );
|
setSize( Math.max( prefSize.width, width ), Math.max( prefSize.height, height ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// limit frame size to screen size
|
||||||
|
Rectangle screenBounds = getGraphicsConfiguration().getBounds();
|
||||||
|
screenBounds = FlatUIUtils.subtractInsets( screenBounds, getToolkit().getScreenInsets( getGraphicsConfiguration() ) );
|
||||||
|
Dimension frameSize = getSize();
|
||||||
|
if( frameSize.width > screenBounds.width || frameSize.height > screenBounds.height )
|
||||||
|
setSize( Math.min( frameSize.width, screenBounds.width ), Math.min( frameSize.height, screenBounds.height ) );
|
||||||
|
|
||||||
|
// move frame to left/top if necessary
|
||||||
|
if( getX() + getWidth() > screenBounds.x + screenBounds.width ||
|
||||||
|
getY() + getHeight() > screenBounds.y + screenBounds.height )
|
||||||
|
{
|
||||||
|
setLocation( Math.min( getX(), screenBounds.x + screenBounds.width - getWidth() ),
|
||||||
|
Math.min( getY(), screenBounds.y + screenBounds.height - getHeight() ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( inspector != null )
|
if( inspector != null )
|
||||||
inspector.update();
|
inspector.update();
|
||||||
@@ -200,7 +289,15 @@ public class FlatTestFrame
|
|||||||
boolean explicit = explicitColorsCheckBox.isSelected();
|
boolean explicit = explicitColorsCheckBox.isSelected();
|
||||||
ColorUIResource restoreColor = new ColorUIResource( Color.white );
|
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)
|
// because colors may depend on state (e.g. disabled JTextField)
|
||||||
// it is best to update all UI delegates to get correct result
|
// it is best to update all UI delegates to get correct result
|
||||||
@@ -209,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() {
|
private void rightToLeftChanged() {
|
||||||
contentPanel.applyComponentOrientation( rightToLeftCheckBox.isSelected()
|
contentPanel.applyComponentOrientation( rightToLeftCheckBox.isSelected()
|
||||||
? ComponentOrientation.RIGHT_TO_LEFT
|
? ComponentOrientation.RIGHT_TO_LEFT
|
||||||
@@ -252,35 +315,10 @@ public class FlatTestFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void enabledChanged() {
|
private void enabledChanged() {
|
||||||
enabledDisable( content, enabledCheckBox.isSelected() );
|
boolean enabled = enabledCheckBox.isSelected();
|
||||||
}
|
updateComponentsRecur( content, (c, type) -> {
|
||||||
|
|
||||||
private void enabledDisable( Container container, boolean enabled ) {
|
|
||||||
for( Component c : container.getComponents() ) {
|
|
||||||
if( c instanceof JPanel ) {
|
|
||||||
enabledDisable( (JPanel) c, enabled );
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
c.setEnabled( enabled );
|
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() {
|
private void inspectChanged() {
|
||||||
@@ -289,6 +327,59 @@ public class FlatTestFrame
|
|||||||
inspector.setEnabled( inspectCheckBox.isSelected() );
|
inspector.setEnabled( inspectCheckBox.isSelected() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void scaleFactorChanged() {
|
||||||
|
String scaleFactor = (String) scaleFactorComboBox.getSelectedItem();
|
||||||
|
if( "default".equals( scaleFactor ) )
|
||||||
|
scaleFactor = null;
|
||||||
|
|
||||||
|
// hide popup to avoid occasional StackOverflowError when updating UI
|
||||||
|
scaleFactorComboBox.setPopupVisible( false );
|
||||||
|
|
||||||
|
Preferences prefs = Preferences.userRoot().node( PREFS_ROOT_PATH );
|
||||||
|
|
||||||
|
if( scaleFactor != null ) {
|
||||||
|
System.setProperty( "flatlaf.uiScale", scaleFactor );
|
||||||
|
prefs.put( KEY_SCALE_FACTOR, scaleFactor );
|
||||||
|
} else {
|
||||||
|
System.clearProperty( "flatlaf.uiScale" );
|
||||||
|
prefs.remove( KEY_SCALE_FACTOR );
|
||||||
|
}
|
||||||
|
|
||||||
|
applyLookAndFeel( UIManager.getLookAndFeel().getClass().getName(), true );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateScaleFactorComboBox() {
|
||||||
|
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() {
|
private void initComponents() {
|
||||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||||
dialogPane = new JPanel();
|
dialogPane = new JPanel();
|
||||||
@@ -299,6 +390,7 @@ public class FlatTestFrame
|
|||||||
rightToLeftCheckBox = new JCheckBox();
|
rightToLeftCheckBox = new JCheckBox();
|
||||||
enabledCheckBox = new JCheckBox();
|
enabledCheckBox = new JCheckBox();
|
||||||
inspectCheckBox = new JCheckBox();
|
inspectCheckBox = new JCheckBox();
|
||||||
|
scaleFactorComboBox = new JComboBox<>();
|
||||||
closeButton = new JButton();
|
closeButton = new JButton();
|
||||||
|
|
||||||
//======== this ========
|
//======== this ========
|
||||||
@@ -332,6 +424,7 @@ public class FlatTestFrame
|
|||||||
"[fill]" +
|
"[fill]" +
|
||||||
"[fill]" +
|
"[fill]" +
|
||||||
"[fill]" +
|
"[fill]" +
|
||||||
|
"[fill]" +
|
||||||
"[grow,fill]" +
|
"[grow,fill]" +
|
||||||
"[button,fill]",
|
"[button,fill]",
|
||||||
// rows
|
// rows
|
||||||
@@ -366,9 +459,27 @@ public class FlatTestFrame
|
|||||||
inspectCheckBox.addActionListener(e -> inspectChanged());
|
inspectCheckBox.addActionListener(e -> inspectChanged());
|
||||||
buttonBar.add(inspectCheckBox, "cell 4 0");
|
buttonBar.add(inspectCheckBox, "cell 4 0");
|
||||||
|
|
||||||
|
//---- scaleFactorComboBox ----
|
||||||
|
scaleFactorComboBox.setModel(new DefaultComboBoxModel<>(new String[] {
|
||||||
|
"default",
|
||||||
|
"1",
|
||||||
|
"1.25",
|
||||||
|
"1.5",
|
||||||
|
"1.75",
|
||||||
|
"2.0",
|
||||||
|
"2.25",
|
||||||
|
"2.5",
|
||||||
|
"3",
|
||||||
|
"3.5",
|
||||||
|
"4"
|
||||||
|
}));
|
||||||
|
scaleFactorComboBox.setMaximumRowCount(20);
|
||||||
|
scaleFactorComboBox.addActionListener(e -> scaleFactorChanged());
|
||||||
|
buttonBar.add(scaleFactorComboBox, "cell 5 0");
|
||||||
|
|
||||||
//---- closeButton ----
|
//---- closeButton ----
|
||||||
closeButton.setText("Close");
|
closeButton.setText("Close");
|
||||||
buttonBar.add(closeButton, "cell 6 0");
|
buttonBar.add(closeButton, "cell 7 0");
|
||||||
}
|
}
|
||||||
dialogPane.add(buttonBar, BorderLayout.SOUTH);
|
dialogPane.add(buttonBar, BorderLayout.SOUTH);
|
||||||
}
|
}
|
||||||
@@ -385,6 +496,7 @@ public class FlatTestFrame
|
|||||||
private JCheckBox rightToLeftCheckBox;
|
private JCheckBox rightToLeftCheckBox;
|
||||||
private JCheckBox enabledCheckBox;
|
private JCheckBox enabledCheckBox;
|
||||||
private JCheckBox inspectCheckBox;
|
private JCheckBox inspectCheckBox;
|
||||||
|
private JComboBox<String> scaleFactorComboBox;
|
||||||
private JButton closeButton;
|
private JButton closeButton;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "insets dialog"
|
"$layoutConstraints": "insets dialog"
|
||||||
"$columnConstraints": "[fill][fill][fill][fill][fill][grow,fill][button,fill]"
|
"$columnConstraints": "[fill][fill][fill][fill][fill][fill][grow,fill][button,fill]"
|
||||||
"$rowSpecs": "[fill]"
|
"$rowSpecs": "[fill]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "buttonBar"
|
name: "buttonBar"
|
||||||
@@ -67,11 +67,35 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 0"
|
"value": "cell 4 0"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||||
|
name: "scaleFactorComboBox"
|
||||||
|
"model": new javax.swing.DefaultComboBoxModel {
|
||||||
|
selectedItem: "default"
|
||||||
|
addElement( "default" )
|
||||||
|
addElement( "1" )
|
||||||
|
addElement( "1.25" )
|
||||||
|
addElement( "1.5" )
|
||||||
|
addElement( "1.75" )
|
||||||
|
addElement( "2.0" )
|
||||||
|
addElement( "2.25" )
|
||||||
|
addElement( "2.5" )
|
||||||
|
addElement( "3" )
|
||||||
|
addElement( "3.5" )
|
||||||
|
addElement( "4" )
|
||||||
|
}
|
||||||
|
"maximumRowCount": 20
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.typeParameters": "String"
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scaleFactorChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 5 0"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JButton" ) {
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
name: "closeButton"
|
name: "closeButton"
|
||||||
"text": "Close"
|
"text": "Close"
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 6 0"
|
"value": "cell 7 0"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class java.lang.String ) {
|
}, new FormLayoutConstraints( class java.lang.String ) {
|
||||||
"value": "South"
|
"value": "South"
|
||||||
@@ -81,7 +105,7 @@ new FormModel {
|
|||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
"size": new java.awt.Dimension( 510, 300 )
|
"size": new java.awt.Dimension( 640, 300 )
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,14 @@ version = rootProject.version
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
`java-library`
|
`java-library`
|
||||||
}
|
id( "com.jfrog.bintray" ) version "1.8.4"
|
||||||
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation( project( ":flatlaf-core" ) )
|
implementation( project( ":flatlaf-core" ) )
|
||||||
implementation( "com.miglayout:miglayout-swing:5.2" )
|
implementation( "com.miglayout:miglayout-swing:5.2" )
|
||||||
implementation( "com.jgoodies:jgoodies-forms:1.9.0" )
|
implementation( "com.jgoodies:jgoodies-forms:1.9.0" )
|
||||||
implementation( "guru.nidi.com.kitfox:svgSalamander:1.1.2" )
|
implementation( "com.formdev:svgSalamander:1.1.2.1" )
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@@ -38,13 +35,37 @@ java {
|
|||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
jar {
|
jar {
|
||||||
|
dependsOn( ":flatlaf-core:jar" )
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes( "Main-Class" to "com.formdev.flatlaf.demo.FlatLafDemo" )
|
attributes( "Main-Class" to "com.formdev.flatlaf.demo.FlatLafDemo" )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exclude( "META-INF/versions/**" )
|
||||||
|
|
||||||
// include all dependencies in jar
|
// include all dependencies in jar
|
||||||
from( {
|
from( {
|
||||||
configurations.runtimeClasspath.get().filter { it.name.endsWith( "jar" ) }.map { zipTree( it ) }
|
configurations.runtimeClasspath.get().filter { it.name.endsWith( "jar" ) }.map { zipTree( it ) }
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ class BasicComponentsPanel
|
|||||||
JButton button2 = new JButton();
|
JButton button2 = new JButton();
|
||||||
JButton button3 = new JButton();
|
JButton button3 = new JButton();
|
||||||
JButton button4 = new JButton();
|
JButton button4 = new JButton();
|
||||||
|
JButton button13 = new JButton();
|
||||||
JLabel checkBoxLabel = new JLabel();
|
JLabel checkBoxLabel = new JLabel();
|
||||||
JCheckBox checkBox1 = new JCheckBox();
|
JCheckBox checkBox1 = new JCheckBox();
|
||||||
JCheckBox checkBox2 = new JCheckBox();
|
JCheckBox checkBox2 = new JCheckBox();
|
||||||
@@ -169,6 +170,10 @@ class BasicComponentsPanel
|
|||||||
button4.setEnabled(false);
|
button4.setEnabled(false);
|
||||||
add(button4, "cell 4 1");
|
add(button4, "cell 4 1");
|
||||||
|
|
||||||
|
//---- button13 ----
|
||||||
|
button13.setIcon(UIManager.getIcon("Tree.closedIcon"));
|
||||||
|
add(button13, "cell 5 1");
|
||||||
|
|
||||||
//---- checkBoxLabel ----
|
//---- checkBoxLabel ----
|
||||||
checkBoxLabel.setText("JCheckBox");
|
checkBoxLabel.setText("JCheckBox");
|
||||||
add(checkBoxLabel, "cell 0 2");
|
add(checkBoxLabel, "cell 0 2");
|
||||||
|
|||||||
@@ -69,6 +69,12 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 1"
|
"value": "cell 4 1"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JButton" ) {
|
||||||
|
name: "button13"
|
||||||
|
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 5 1"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
name: "checkBoxLabel"
|
name: "checkBoxLabel"
|
||||||
"text": "JCheckBox"
|
"text": "JCheckBox"
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
package com.formdev.flatlaf.demo;
|
package com.formdev.flatlaf.demo;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
@@ -56,7 +58,8 @@ class ControlBar
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( (SystemInfo.IS_WINDOWS && className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" )) ||
|
if( (SystemInfo.IS_WINDOWS && className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" )) ||
|
||||||
(SystemInfo.IS_MAC && className.equals( "com.apple.laf.AquaLookAndFeel") ) )
|
(SystemInfo.IS_MAC && className.equals( "com.apple.laf.AquaLookAndFeel") ) ||
|
||||||
|
(SystemInfo.IS_LINUX && className.equals( "com.sun.java.swing.plaf.gtk.GTKLookAndFeel") ) )
|
||||||
name += " (F9)";
|
name += " (F9)";
|
||||||
else if( className.equals( MetalLookAndFeel.class.getName() ) )
|
else if( className.equals( MetalLookAndFeel.class.getName() ) )
|
||||||
name += " (F10)";
|
name += " (F10)";
|
||||||
@@ -76,6 +79,15 @@ class ControlBar
|
|||||||
lafModel.setSelectedItem( lafModel.getElementAt( sel ) );
|
lafModel.setSelectedItem( lafModel.getElementAt( sel ) );
|
||||||
|
|
||||||
lookAndFeelComboBox.setModel( lafModel );
|
lookAndFeelComboBox.setModel( lafModel );
|
||||||
|
|
||||||
|
UIManager.addPropertyChangeListener( e -> {
|
||||||
|
if( "lookAndFeel".equals( e.getPropertyName() ) ) {
|
||||||
|
EventQueue.invokeLater( () -> {
|
||||||
|
// update info label because user scale factor may change
|
||||||
|
updateInfoLabel();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize( JFrame frame, JTabbedPane tabbedPane ) {
|
void initialize( JFrame frame, JTabbedPane tabbedPane ) {
|
||||||
@@ -92,6 +104,8 @@ class ControlBar
|
|||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
|
||||||
else if( SystemInfo.IS_MAC )
|
else if( SystemInfo.IS_MAC )
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.apple.laf.AquaLookAndFeel" );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.apple.laf.AquaLookAndFeel" );
|
||||||
|
else if( SystemInfo.IS_LINUX )
|
||||||
|
registerSwitchToLookAndFeel( KeyEvent.VK_F9, "com.sun.java.swing.plaf.gtk.GTKLookAndFeel" );
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F10, MetalLookAndFeel.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F10, MetalLookAndFeel.class.getName() );
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F11, NimbusLookAndFeel.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F11, NimbusLookAndFeel.class.getName() );
|
||||||
|
|
||||||
@@ -106,15 +120,19 @@ class ControlBar
|
|||||||
// make the "close" button the default button
|
// make the "close" button the default button
|
||||||
frame.getRootPane().setDefaultButton( closeButton );
|
frame.getRootPane().setDefaultButton( closeButton );
|
||||||
|
|
||||||
// move focus to "close" button
|
// update info label and move focus to "close" button
|
||||||
frame.addWindowListener( new WindowAdapter() {
|
frame.addWindowListener( new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowOpened( WindowEvent e ) {
|
public void windowOpened( WindowEvent e ) {
|
||||||
updateInfoLabel();
|
updateInfoLabel();
|
||||||
closeButton.requestFocusInWindow();
|
closeButton.requestFocusInWindow();
|
||||||
}
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
// update info label when moved to another screen
|
||||||
|
frame.addComponentListener( new ComponentAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowActivated( WindowEvent e ) {
|
public void componentMoved( ComponentEvent e ) {
|
||||||
updateInfoLabel();
|
updateInfoLabel();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
@@ -123,11 +141,14 @@ class ControlBar
|
|||||||
private void updateInfoLabel() {
|
private void updateInfoLabel() {
|
||||||
double systemScaleFactor = UIScale.getSystemScaleFactor( getGraphicsConfiguration() );
|
double systemScaleFactor = UIScale.getSystemScaleFactor( getGraphicsConfiguration() );
|
||||||
float userScaleFactor = UIScale.getUserScaleFactor();
|
float userScaleFactor = UIScale.getUserScaleFactor();
|
||||||
infoLabel.setText( "(Java " + System.getProperty( "java.version" )
|
String newInfo = "(Java " + System.getProperty( "java.version" )
|
||||||
+ (systemScaleFactor != 1 ? ("; system scale factor " + systemScaleFactor) : "")
|
+ (systemScaleFactor != 1 ? ("; system scale factor " + systemScaleFactor) : "")
|
||||||
+ (userScaleFactor != 1 ? ("; user scale factor " + userScaleFactor) : "")
|
+ (userScaleFactor != 1 ? ("; user scale factor " + userScaleFactor) : "")
|
||||||
+ (systemScaleFactor == 1 && userScaleFactor == 1 ? "; no scaling" : "")
|
+ (systemScaleFactor == 1 && userScaleFactor == 1 ? "; no scaling" : "")
|
||||||
+ ")" );
|
+ ")";
|
||||||
|
|
||||||
|
if( !newInfo.equals( infoLabel.getText() ) )
|
||||||
|
infoLabel.setText( newInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerSwitchToLookAndFeel( int keyCode, String lafClassName ) {
|
private void registerSwitchToLookAndFeel( int keyCode, String lafClassName ) {
|
||||||
@@ -161,11 +182,8 @@ class ControlBar
|
|||||||
// change look and feel
|
// change look and feel
|
||||||
UIManager.setLookAndFeel( newLaf.className );
|
UIManager.setLookAndFeel( newLaf.className );
|
||||||
|
|
||||||
// update info label because user scale factor may change
|
|
||||||
updateInfoLabel();
|
|
||||||
|
|
||||||
// update all components
|
// update all components
|
||||||
SwingUtilities.updateComponentTreeUI( frame );
|
FlatLaf.updateUI();
|
||||||
|
|
||||||
// increase size of frame if necessary
|
// increase size of frame if necessary
|
||||||
int width = frame.getWidth();
|
int width = frame.getWidth();
|
||||||
|
|||||||
@@ -46,11 +46,7 @@ public class FlatLafDemo
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
|
||||||
// fallback
|
// fallback
|
||||||
try {
|
FlatLightLaf.install();
|
||||||
UIManager.setLookAndFeel( new FlatLightLaf() );
|
|
||||||
} catch( Exception ex2 ) {
|
|
||||||
ex2.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create frame
|
// create frame
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ class OptionPanePanel
|
|||||||
//---- warningOptionPane ----
|
//---- warningOptionPane ----
|
||||||
warningOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE);
|
warningOptionPane.setMessageType(JOptionPane.WARNING_MESSAGE);
|
||||||
warningOptionPane.setOptionType(JOptionPane.OK_CANCEL_OPTION);
|
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);
|
panel5.add(warningOptionPane, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
panel9.add(panel5, "cell 1 4");
|
panel9.add(panel5, "cell 1 4");
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ new FormModel {
|
|||||||
name: "warningOptionPane"
|
name: "warningOptionPane"
|
||||||
"messageType": 2
|
"messageType": 2
|
||||||
"optionType": 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 ) {
|
}, new FormLayoutConstraints( class java.lang.String ) {
|
||||||
"value": "Center"
|
"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
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
BIN
images/FlatDarkSwingXTest.png
Normal file
BIN
images/FlatDarkSwingXTest.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 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"
|
rootProject.name = "FlatLaf"
|
||||||
|
|
||||||
include( "flatlaf-core" )
|
include( "flatlaf-core" )
|
||||||
|
include( "flatlaf-swingx" )
|
||||||
include( "flatlaf-demo" )
|
include( "flatlaf-demo" )
|
||||||
|
|||||||
Reference in New Issue
Block a user