Compare commits

...

36 Commits
0.45 ... 0.46

Author SHA1 Message Date
Karl Tauber
073a25f381 release 0.46 2020-12-20 18:42:23 +01:00
Karl Tauber
40592ab876 FlatUIUtils: fixed javadoc warnings 2020-12-20 18:34:13 +01:00
Karl Tauber
bbfe624b51 Merge pull request #222 into master
AnimatedIcon
2020-12-20 18:26:09 +01:00
Karl Tauber
a2af9e4c65 JIDE: RangeSlider: clicking on track now immediately moves the thumb to mouse location and starts dragging the thumb 2020-12-20 18:24:40 +01:00
Karl Tauber
0123a8895f JIDE: updated UI defaults dumps for commit ef065d31a0 (support TristateCheckBox) 2020-12-20 17:33:42 +01:00
Karl Tauber
53854a4d13 Slider: snap to ticks is now done while dragging the thumb 2020-12-20 17:32:01 +01:00
Karl Tauber
4fdd44858f Slider: clicking on track now immediately moves the thumb to mouse location and starts dragging the thumb 2020-12-20 13:32:10 +01:00
Karl Tauber
3c58879ce5 Slider: fixed painting of colored track if JSlider.inverted is true 2020-12-19 17:01:34 +01:00
Karl Tauber
a7c6a881b3 Extras: FlatTriStateCheckBox reworked 2020-12-19 16:13:12 +01:00
Karl Tauber
ef065d31a0 JIDE: support TristateCheckBox 2020-12-19 13:34:53 +01:00
Karl Tauber
d059d6b448 README.md: new projects using FlatLaf:
- jEnTunnel
- JPass
- Linotte
- MEKA
- Shutter Encoder
- ThunderFocus
- lectureStudio
2020-12-18 16:05:56 +01:00
Karl Tauber
2d0a6f1bec README.md: new projects using FlatLaf:
- JOSM
- Novel-Grabber
- Android Tool
2020-12-18 16:04:43 +01:00
Karl Tauber
a3cc5a1938 README.md: added descriptions to projects using FlatLaf 2020-12-18 14:34:40 +01:00
Karl Tauber
435068515a always reset our graphics rendering hints
(this is usually not necessary because each component gets its own instance of Graphics when painting, but resetting may avoid side effects if our paint methods are invoked directly)
2020-12-18 13:35:17 +01:00
Karl Tauber
956001dbd7 avoid painting text with our rendering hints enabled to avoid antialiased text in some components if text antialiasing is disabled in system (issue #227) 2020-12-18 12:22:27 +01:00
Karl Tauber
460f0d9dee UIScale: fixed NPE in getSystemScaleFactor(Graphics2D) when using Batik SVGGraphics2D (issue #226) 2020-12-15 11:25:00 +01:00
Karl Tauber
5155ec93c9 ToolTip: fixed drop shadow for wide tooltips (issue #224; regression since fixed issue #142) 2020-12-15 11:19:30 +01:00
Karl Tauber
8bb8883e22 IntelliJ Themes: added flag whether a theme is dark to FlatAllIJThemes.INFOS. (issue #221) 2020-12-12 18:54:42 +01:00
Karl Tauber
ffb7a6dfbb README.md:
- added demo download section
- added link to javadoc of extras components
2020-12-12 14:45:08 +01:00
Karl Tauber
176de6f245 README.md: simplified download sections of subprojects 2020-12-12 14:21:07 +01:00
Karl Tauber
11f9740dbf Extras: added support for JComponent.outline client property (issue #117) 2020-12-12 13:59:58 +01:00
Karl Tauber
42a91ba26c Extras: renamed SVG utility class from com.formdev.flatlaf.extras.SVGUtils to com.formdev.flatlaf.extras.FlatSVGUtils 2020-12-12 12:21:48 +01:00
Karl Tauber
234003e2b1 Extras: Renamed tri-state check box class from
`com.formdev.flatlaf.extras.TriStateCheckBox` to
`com.formdev.flatlaf.extras.components.FlatTriStateCheckBox`
2020-12-12 00:33:51 +01:00
Karl Tauber
534384438b Extras: added extension class for JTabbedPane (issue #117) 2020-12-11 23:44:52 +01:00
Karl Tauber
ab51f35d5d Extras: added extension classes for JEditorPane, JSpinner, JTextArea and JTextPane; added minimumWidth and roundRect properties (issue #117) 2020-12-11 18:05:58 +01:00
Karl Tauber
511a4044d7 Extras: added extension classes for JButton and JToggleButton (issue #117) 2020-12-11 17:18:35 +01:00
Karl Tauber
821efaff40 Extras: removed duplicate enums in text components (issue #117) 2020-12-11 14:01:42 +01:00
Karl Tauber
91bc994532 Extras: made enums in text components public (issue #117) 2020-12-11 13:39:51 +01:00
Karl Tauber
1323b46ac7 Extras: added extension class for JProgressBar (issue #117) 2020-12-11 13:28:55 +01:00
Karl Tauber
3a8b30ca8e Extras: removed extension interfaces and moved methods to components classes because:
- Javadoc for components that implement extension interfaces are useless because they do not include default methods from the extension interface
- GUI builders do not recognize default methods from the extension interface and it is not possible to edit extension properties in GUI builder
- the idea of adding the extension interface to own components can be also achieved by changing superclass of own component

(issue #117)
2020-12-11 13:24:14 +01:00
Karl Tauber
923d58519f Extras: added extension interfaces and classes for JComboBox, JFormattedTextField, JPasswordField, JScrollBar, JScrollPane and JTextField (issue #117) 2020-12-10 20:30:27 +01:00
Karl Tauber
eabb1f84f6 Table and TableHeader: fixed missing right vertical grid line if using table as row header in scroll pane (issues #152 and #46) 2020-12-09 23:04:04 +01:00
Karl Tauber
cfbe44b946 TableHeader: fixed position of column separators in right-to-left component orientation; do not paint anything if column count is zero 2020-12-09 00:33:01 +01:00
Karl Tauber
81c35eab46 SwingX: fixed striping background highlighting color (e.g. alternating table rows) in dark themes
Table: made grid lines slightly darker/lighter
2020-12-07 12:28:31 +01:00
Karl Tauber
a1c7c29113 FlatComponents2Test: added SwingX JXTable and JXTreeTable to test extended/customized tables 2020-12-07 12:21:34 +01:00
Karl Tauber
1293e2a074 AnimatedIcon added (for future animations) (issue #66) 2020-12-05 17:57:06 +01:00
90 changed files with 5067 additions and 1020 deletions

View File

@@ -1,6 +1,48 @@
FlatLaf Change Log FlatLaf Change Log
================== ==================
## 0.46
#### New features and improvements
- Slider and JIDE RangeSlider: Clicking on track now immediately moves the thumb
to mouse location and starts dragging the thumb. Use `UIManager.put(
"Slider.scrollOnTrackClick", true )` to enable old behavior that scrolls the
thumb when clicking on track.
- Slider: Snap to ticks is now done while dragging the thumb. Use
`UIManager.put( "Slider.snapToTicksOnReleased", true )` to enable old behavior
that snaps to ticks on mouse released.
- Extras: Added standard component extension classes that provides easy access
to FlatLaf specific client properties (see package
`com.formdev.flatlaf.extras.components`).
- Extras: Renamed tri-state check box class from
`com.formdev.flatlaf.extras.TriStateCheckBox` to
`com.formdev.flatlaf.extras.components.FlatTriStateCheckBox`. Also
changed/improved API and added javadoc.
- Extras: Renamed SVG utility class from `com.formdev.flatlaf.extras.SVGUtils`
to `com.formdev.flatlaf.extras.FlatSVGUtils`.
- IntelliJ Themes: Added flag whether a theme is dark to
`FlatAllIJThemes.INFOS`. (issue #221)
- JIDE Common Layer: Support `TristateCheckBox`.
#### Fixed bugs
- Slider: Fixed painting of colored track if `JSlider.inverted` is `true`.
- Table and TableHeader: Fixed missing right vertical grid line if using table
as row header in scroll pane. (issues #152 and #46)
- TableHeader: Fixed position of column separators in right-to-left component
orientation.
- ToolTip: Fixed drop shadow for wide tooltips on Windows and Java 9+. (issue
#224)
- SwingX: Fixed striping background highlighting color (e.g. alternating table
rows) in dark themes.
- Fixed: If text antialiasing is disabled (in OS system settings or via
`-Dawt.useSystemAAFontSettings=off`), then some components still did use
antialiasing to render text (not-editable ComboBox, ProgressBar, Slider,
TabbedPane and multiline ToolTip). (issue #227)
## 0.45 ## 0.45
#### New features and improvements #### New features and improvements

View File

@@ -76,36 +76,76 @@ Addons
Projects using FlatLaf Projects using FlatLaf
---------------------- ----------------------
- [NetBeans](https://netbeans.apache.org/) 11.3 - [Apache NetBeans](https://netbeans.apache.org/) 11.3 - IDE for Java, PHP, HTML
and much more
- [jclasslib bytecode viewer](https://github.com/ingokegel/jclasslib) 5.5 - [jclasslib bytecode viewer](https://github.com/ingokegel/jclasslib) 5.5
- [KeyStore Explorer](https://keystore-explorer.org/) 5.4.3 - [KeyStore Explorer](https://keystore-explorer.org/) 5.4.3
- [OWASP Zed Attack Proxy (ZAP)](https://www.zaproxy.org/) (in weekly releases) - ![New](images/new.svg) [OWASP ZAP](https://www.zaproxy.org/) 2.10 - the worlds
- ![New](images/new.svg) [jAlbum](https://jalbum.net/) 21 (commercial) most widely used web app scanner
- ![New](images/new.svg) [JOSM](https://josm.openstreetmap.de/) - an extensible
editor for [OpenStreetMap](https://www.openstreetmap.org/) (requires FlatLaf
JOSM plugin)
- [jAlbum](https://jalbum.net/) 21 (commercial) - creates photo album websites
- [XMLmind XML Editor](https://www.xmlmind.com/xmleditor/) 9.3 (commercial) - [XMLmind XML Editor](https://www.xmlmind.com/xmleditor/) 9.3 (commercial)
- [Total Validator](https://www.totalvalidator.com/) 15 (commercial) - [Total Validator](https://www.totalvalidator.com/) 15 (commercial) - checks
- [j-lawyer](https://github.com/jlawyerorg/j-lawyer-org) your website
- [j-lawyer](https://github.com/jlawyerorg/j-lawyer-org) - Kanzleisoftware
- [MegaMek](https://github.com/MegaMek/megamek) v0.47.4 and - [MegaMek](https://github.com/MegaMek/megamek) v0.47.4 and
[MekHQ](https://github.com/MegaMek/mekhq) v0.47.5 [MekHQ](https://github.com/MegaMek/mekhq) v0.47.5 - a turn-based sci-fi board
game
- [GUIslice Builder](https://github.com/ImpulseAdventure/GUIslice-Builder) - [GUIslice Builder](https://github.com/ImpulseAdventure/GUIslice-Builder)
0.13.b024 0.13.b024 - GUI builder for
- [Rest Suite](https://github.com/supanadit/restsuite) [GUIslice](https://github.com/ImpulseAdventure/GUIslice), a lightweight GUI
- [ControllerBuddy](https://github.com/bwRavencl/ControllerBuddy) framework for embedded displays
- [SpringRemote](https://github.com/HaleyWang/SpringRemote) - [Rest Suite](https://github.com/supanadit/restsuite) - Rest API testing
- [ControllerBuddy](https://github.com/bwRavencl/ControllerBuddy) - advanced
gamepad mapping software
- [SpringRemote](https://github.com/HaleyWang/SpringRemote) - remote Linux SSH
connections manager
- ![New](images/new.svg) [jEnTunnel](https://github.com/ggrandes/jentunnel) -
manage SSH Tunnels made easy
- [mendelson AS2](https://sourceforge.net/projects/mec-as2/), - [mendelson AS2](https://sourceforge.net/projects/mec-as2/),
[AS4](https://sourceforge.net/projects/mendelson-as4/) and [AS4](https://sourceforge.net/projects/mendelson-as4/) and
[OFTP2](https://sourceforge.net/projects/mendelson-oftp2/) (open-source) and [OFTP2](https://sourceforge.net/projects/mendelson-oftp2/) (open-source) and
[mendelson AS2](https://mendelson-e-c.com/as2/), [mendelson AS2](https://mendelson-e-c.com/as2/),
[AS4](https://mendelson-e-c.com/as4/) and [AS4](https://mendelson-e-c.com/as4/) and
[OFTP2](https://mendelson-e-c.com/oftp2) (commercial) [OFTP2](https://mendelson-e-c.com/oftp2) (commercial)
- [MeteoInfo](https://github.com/meteoinfo/MeteoInfo) 2.2 - [MeteoInfo](https://github.com/meteoinfo/MeteoInfo) 2.2 - GIS and scientific
- [lsfusion platform](https://github.com/lsfusion/platform) computation environment for meteorological community
- [lsfusion platform](https://github.com/lsfusion/platform) - information
systems development platform
- ![New](images/new.svg) [JPass](https://github.com/gaborbata/jpass) - password
manager with strong encryption
- [Jes - Die Java-EÜR](https://www.jes-eur.de) - [Jes - Die Java-EÜR](https://www.jes-eur.de)
- [Mapton](https://mapton.org/) 2.0 - [Mapton](https://mapton.org/) 2.0
([source code](https://github.com/trixon/mapton)) based on NetBeans platform ([source code](https://github.com/trixon/mapton)) based on NetBeans platform -
- [Pseudo Assembler IDE](https://github.com/tomasz-herman/PseudoAssemblerIDE) some kind of map application
- [Sound Analysis](https://github.com/tomasz-herman/SoundAnalysis) - [Pseudo Assembler IDE](https://github.com/tomasz-herman/PseudoAssemblerIDE) -
- [RemoteLight](https://github.com/Drumber/RemoteLight) - Multifunctional LED IDE for Pseudo-Assembler
Control Software - ![New](images/new.svg) [Linotte](https://github.com/cpc6128/LangageLinotte)
3.1 - French programming language created to learn programming
- ![New](images/new.svg) [MEKA](https://github.com/Waikato/meka) 1.9.3 -
multi-label classifiers and evaluation procedures using the Weka machine
learning framework
- ![New](images/new.svg) [Shutter Encoder](https://www.shutterencoder.com/) 14.2
([source code](https://github.com/paulpacifico/shutter-encoder)) -
professional video converter and compression tool (screenshots show **old**
look)
- [Sound Analysis](https://github.com/tomasz-herman/SoundAnalysis) - analyze
sound files in time or frequency domain
- [RemoteLight](https://github.com/Drumber/RemoteLight) - multifunctional LED
control software
- ![New](images/new.svg)
[ThunderFocus](https://github.com/marcocipriani01/ThunderFocus) -
Arduino-based telescope focuser
- ![New](images/new.svg)
[Novel-Grabber](https://github.com/Flameish/Novel-Grabber) - download novels
from any webnovel and lightnovel site
- ![New](images/new.svg) [lectureStudio](https://www.lecturestudio.org/)
4.3.1060 - digitize your lectures with ease
- ![New](images/new.svg)
[Android Tool](https://github.com/fast-geek/Android-Tool) - makes popular adb
and fastboot commands easier to use
- and more... - and more...

View File

@@ -14,8 +14,8 @@
* limitations under the License. * limitations under the License.
*/ */
val releaseVersion = "0.45" val releaseVersion = "0.46"
val developmentVersion = "0.46-SNAPSHOT" val developmentVersion = "0.47-SNAPSHOT"
version = if( java.lang.Boolean.getBoolean( "release" ) ) releaseVersion else developmentVersion version = if( java.lang.Boolean.getBoolean( "release" ) ) releaseVersion else developmentVersion

View File

@@ -130,6 +130,15 @@ public interface FlatClientProperties
*/ */
String MINIMUM_HEIGHT = "JComponent.minimumHeight"; String MINIMUM_HEIGHT = "JComponent.minimumHeight";
/**
* Paint the component with round edges.
* <p>
* <strong>Components</strong> {@link javax.swing.JComboBox}, {@link javax.swing.JSpinner},
* {@link javax.swing.JTextField}, {@link javax.swing.JFormattedTextField} and {@link javax.swing.JPasswordField}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*/
String COMPONENT_ROUND_RECT = "JComponent.roundRect";
/** /**
* Specifies the outline color of the component border. * Specifies the outline color of the component border.
* <p> * <p>
@@ -161,15 +170,6 @@ public interface FlatClientProperties
*/ */
String OUTLINE_WARNING = "warning"; String OUTLINE_WARNING = "warning";
/**
* Paint the component with round edges.
* <p>
* <strong>Components</strong> {@link javax.swing.JComboBox}, {@link javax.swing.JSpinner},
* {@link javax.swing.JTextField}, {@link javax.swing.JFormattedTextField} and {@link javax.swing.JPasswordField}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*/
String COMPONENT_ROUND_RECT = "JComponent.roundRect";
//---- Popup -------------------------------------------------------------- //---- Popup --------------------------------------------------------------
/** /**
@@ -264,7 +264,7 @@ public interface FlatClientProperties
String TABBED_PANE_HAS_FULL_BORDER = "JTabbedPane.hasFullBorder"; String TABBED_PANE_HAS_FULL_BORDER = "JTabbedPane.hasFullBorder";
/** /**
* Specifies whether the tab area should be hidded if it contains only one tab. * Specifies whether the tab area should be hidden if it contains only one tab.
* <p> * <p>
* <strong>Component</strong> {@link javax.swing.JTabbedPane}<br> * <strong>Component</strong> {@link javax.swing.JTabbedPane}<br>
* <strong>Value type</strong> {@link java.lang.Boolean} * <strong>Value type</strong> {@link java.lang.Boolean}
@@ -349,7 +349,7 @@ public interface FlatClientProperties
* Specifies the callback that is invoked when a tab close button is clicked. * Specifies the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab. * The callback is responsible for closing the tab.
* <p> * <p>
* Either use a {@link java.util.function.IntConsumer} that received the tab index as parameter: * Either use a {@link java.util.function.IntConsumer} that receives the tab index as parameter:
* <pre>{@code * <pre>{@code
* myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback", * myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback",
* (IntConsumer) tabIndex -> { * (IntConsumer) tabIndex -> {
@@ -357,7 +357,7 @@ public interface FlatClientProperties
* } ); * } );
* }</pre> * }</pre>
* Or use a {@link java.util.function.BiConsumer}&lt;javax.swing.JTabbedPane, Integer&gt; * Or use a {@link java.util.function.BiConsumer}&lt;javax.swing.JTabbedPane, Integer&gt;
* that received the tabbed pane and the tab index as parameters: * that receives the tabbed pane and the tab index as parameters:
* <pre>{@code * <pre>{@code
* myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback", * myTabbedPane.putClientProperty( "JTabbedPane.tabCloseCallback",
* (BiConsumer<JTabbedPane, Integer>) (tabbedPane, tabIndex) -> { * (BiConsumer<JTabbedPane, Integer>) (tabbedPane, tabIndex) -> {

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.icons;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import com.formdev.flatlaf.util.AnimatedIcon;
/**
* Base class for animated icons that scales width and height, creates and initializes
* a scaled graphics context for icon painting.
* <p>
* Subclasses do not need to scale icon painting.
* <p>
* This class does not store any state information (needed for animation) in its instance.
* Instead a client property is set on the painted component.
* This makes it possible to use a share icon instance for multiple components.
*
* @author Karl Tauber
*/
public abstract class FlatAnimatedIcon
extends FlatAbstractIcon
implements AnimatedIcon
{
public FlatAnimatedIcon( int width, int height, Color color ) {
super( width, height, color );
}
@Override
public void paintIcon( Component c, Graphics g, int x, int y ) {
super.paintIcon( c, g, x, y );
AnimatedIcon.AnimationSupport.saveIconLocation( this, c, x, y );
}
@Override
protected void paintIcon( Component c, Graphics2D g ) {
AnimatedIcon.AnimationSupport.paintIcon( this, c, g, 0, 0 );
}
}

View File

@@ -166,8 +166,7 @@ public class FlatArrowButton
@Override @Override
public void paint( Graphics g ) { public void paint( Graphics g ) {
Graphics2D g2 = (Graphics2D)g; Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
FlatUIUtils.setRenderingHints( g2 );
// paint hover or pressed background // paint hover or pressed background
if( isEnabled() ) { if( isEnabled() ) {
@@ -179,7 +178,7 @@ public class FlatArrowButton
if( background != null ) { if( background != null ) {
g.setColor( deriveBackground( background ) ); g.setColor( deriveBackground( background ) );
paintBackground( g2 ); paintBackground( (Graphics2D) g );
} }
} }
@@ -191,7 +190,9 @@ public class FlatArrowButton
? hoverForeground ? hoverForeground
: foreground)) : foreground))
: disabledForeground ) ); : disabledForeground ) );
paintArrow( g2 ); paintArrow( (Graphics2D) g );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
protected void paintBackground( Graphics2D g ) { protected void paintBackground( Graphics2D g ) {

View File

@@ -352,7 +352,7 @@ public class FlatComboBoxUI
FlatUIUtils.paintParentBackground( g, c ); FlatUIUtils.paintParentBackground( g, c );
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
FlatUIUtils.setRenderingHints( g2 ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g2 );
int width = c.getWidth(); int width = c.getWidth();
int height = c.getHeight(); int height = c.getHeight();
@@ -386,6 +386,9 @@ public class FlatComboBoxUI
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2)) ); g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2)) );
} }
// avoid that the "current value" renderer is invoked with enabled antialiasing
FlatUIUtils.resetRenderingHints( g2, oldRenderingHints );
paint( g, c ); paint( g, c );
} }

View File

@@ -271,16 +271,17 @@ public class FlatPopupFactory
// increase tooltip size if necessary because it may be too small on HiDPI screens // increase tooltip size if necessary because it may be too small on HiDPI screens
// https://bugs.openjdk.java.net/browse/JDK-8213535 // https://bugs.openjdk.java.net/browse/JDK-8213535
if( contents instanceof JToolTip ) { if( contents instanceof JToolTip && popupWindow == null ) {
Container parent = contents.getParent(); Container parent = contents.getParent();
if( parent instanceof JPanel ) { if( parent instanceof JPanel ) {
Dimension prefSize = parent.getPreferredSize(); Dimension prefSize = parent.getPreferredSize();
if( !prefSize.equals( parent.getSize() ) ) { if( !prefSize.equals( parent.getSize() ) ) {
Container panel = SwingUtilities.getAncestorOfClass( Panel.class, parent ); Container mediumWeightPanel = SwingUtilities.getAncestorOfClass( Panel.class, parent );
if( panel != null ) Container c = (mediumWeightPanel != null)
panel.setSize( prefSize ); // for medium weight popup ? mediumWeightPanel // medium weight popup
else : parent; // light weight popup
parent.setSize( prefSize ); // for light weight popup c.setSize( prefSize );
c.validate();
} }
} }
} }

View File

@@ -155,7 +155,7 @@ public class FlatProgressBarUI
? 0 ? 0
: Math.min( UIScale.scale( this.arc ), horizontal ? height : width ); : Math.min( UIScale.scale( this.arc ), horizontal ? height : width );
FlatUIUtils.setRenderingHints( (Graphics2D) g ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
// paint track // paint track
RoundRectangle2D.Float trackShape = new RoundRectangle2D.Float( x, y, width, height, arc, arc ); RoundRectangle2D.Float trackShape = new RoundRectangle2D.Float( x, y, width, height, arc, arc );
@@ -163,6 +163,7 @@ public class FlatProgressBarUI
((Graphics2D)g).fill( trackShape ); ((Graphics2D)g).fill( trackShape );
// paint progress // paint progress
int amountFull = 0;
if( progressBar.isIndeterminate() ) { if( progressBar.isIndeterminate() ) {
boxRect = getBox( boxRect ); boxRect = getBox( boxRect );
if( boxRect != null ) { if( boxRect != null ) {
@@ -170,11 +171,8 @@ public class FlatProgressBarUI
((Graphics2D)g).fill( new RoundRectangle2D.Float( boxRect.x, boxRect.y, ((Graphics2D)g).fill( new RoundRectangle2D.Float( boxRect.x, boxRect.y,
boxRect.width, boxRect.height, arc, arc ) ); boxRect.width, boxRect.height, arc, arc ) );
} }
if( progressBar.isStringPainted() )
paintString( g, x, y, width, height, 0, insets );
} else { } else {
int amountFull = getAmountFull( insets, width, height ); amountFull = getAmountFull( insets, width, height );
RoundRectangle2D.Float progressShape = horizontal RoundRectangle2D.Float progressShape = horizontal
? new RoundRectangle2D.Float( c.getComponentOrientation().isLeftToRight() ? x : x + (width - amountFull), ? new RoundRectangle2D.Float( c.getComponentOrientation().isLeftToRight() ? x : x + (width - amountFull),
@@ -189,10 +187,12 @@ public class FlatProgressBarUI
((Graphics2D)g).fill( area ); ((Graphics2D)g).fill( area );
} else } else
((Graphics2D)g).fill( progressShape ); ((Graphics2D)g).fill( progressShape );
if( progressBar.isStringPainted() )
paintString( g, x, y, width, height, amountFull, insets );
} }
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
if( progressBar.isStringPainted() )
paintString( g, x, y, width, height, amountFull, insets );
} }
@Override @Override

View File

@@ -19,7 +19,6 @@ package com.formdev.flatlaf.ui;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
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.MouseAdapter; import java.awt.event.MouseAdapter;
@@ -221,8 +220,9 @@ public class FlatScrollBarUI
@Override @Override
public void paint( Graphics g, JComponent c ) { public void paint( Graphics g, JComponent c ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
super.paint( g, c ); super.paint( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
@Override @Override

View File

@@ -94,6 +94,8 @@ public class FlatSliderUI
protected boolean thumbHover; protected boolean thumbHover;
protected boolean thumbPressed; protected boolean thumbPressed;
private Object[] oldRenderingHints;
public static ComponentUI createUI( JComponent c ) { public static ComponentUI createUI( JComponent c ) {
return new FlatSliderUI(); return new FlatSliderUI();
} }
@@ -211,7 +213,7 @@ public class FlatSliderUI
@Override @Override
public void paint( Graphics g, JComponent c ) { public void paint( Graphics g, JComponent c ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g ); oldRenderingHints = FlatUIUtils.setRenderingHints( g );
/*debug /*debug
g.setColor( Color.gray ); g.setColor( Color.gray );
@@ -224,9 +226,23 @@ public class FlatSliderUI
g.drawRect( trackRect.x, trackRect.y, trackRect.width - 1, trackRect.height - 1 ); g.drawRect( trackRect.x, trackRect.y, trackRect.width - 1, trackRect.height - 1 );
g.setColor( Color.red ); g.setColor( Color.red );
g.drawRect( thumbRect.x, thumbRect.y, thumbRect.width - 1, thumbRect.height - 1 ); g.drawRect( thumbRect.x, thumbRect.y, thumbRect.width - 1, thumbRect.height - 1 );
g.setColor( Color.green );
g.drawRect( tickRect.x, tickRect.y, tickRect.width - 1, tickRect.height - 1 );
g.setColor( Color.red );
g.drawRect( labelRect.x, labelRect.y, labelRect.width - 1, labelRect.height - 1 );
debug*/ debug*/
super.paint( g, c ); super.paint( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
oldRenderingHints = null;
}
@Override
public void paintLabels( Graphics g ) {
FlatUIUtils.runWithoutRenderingHints( g, oldRenderingHints, () -> {
super.paintLabels( g );
} );
} }
@Override @Override
@@ -267,6 +283,12 @@ debug*/
} }
if( coloredTrack != null ) { if( coloredTrack != null ) {
if( slider.getInverted() ) {
RoundRectangle2D temp = track;
track = coloredTrack;
coloredTrack = temp;
}
g.setColor( trackValueColor ); g.setColor( trackValueColor );
((Graphics2D)g).fill( coloredTrack ); ((Graphics2D)g).fill( coloredTrack );
} }
@@ -484,7 +506,47 @@ debug*/
@Override @Override
public void mousePressed( MouseEvent e ) { public void mousePressed( MouseEvent e ) {
setThumbPressed( isOverThumb( e ) ); setThumbPressed( isOverThumb( e ) );
if( !slider.isEnabled() )
return;
// use "old" behavior when clicking on track
if( UIManager.getBoolean( "Slider.scrollOnTrackClick" ) ) {
super.mousePressed( e );
return;
}
// "new" behavior set thumb to mouse location when clicking on track
int x = e.getX();
int y = e.getY();
// clicked on thumb --> let super class do the work
calculateGeometry();
if( thumbRect.contains( x, y ) ) {
super.mousePressed( e );
return;
}
if( UIManager.getBoolean( "Slider.onlyLeftMouseButtonDrag" ) &&
!SwingUtilities.isLeftMouseButton( e ) )
return;
// move the mouse event coordinates to the center of the thumb
int tx = thumbRect.x + (thumbRect.width / 2) - x;
int ty = thumbRect.y + (thumbRect.height / 2) - y;
e.translatePoint( tx, ty );
// invoke super mousePressed() to start dragging thumb
super.mousePressed( e ); super.mousePressed( e );
// move the mouse event coordinates back to current mouse location
e.translatePoint( -tx, -ty );
// invoke mouseDragged() to update thumb location
mouseDragged( e );
setThumbPressed( true );
} }
@Override @Override
@@ -493,6 +555,20 @@ debug*/
super.mouseReleased( e ); super.mouseReleased( e );
} }
@Override
public void mouseDragged( MouseEvent e ) {
super.mouseDragged( e );
if( isDragging() &&
slider.getSnapToTicks() &&
slider.isEnabled() &&
!UIManager.getBoolean( "Slider.snapToTicksOnReleased" ) )
{
calculateThumbLocation();
slider.repaint();
}
}
protected void setThumbHover( boolean hover ) { protected void setThumbHover( boolean hover ) {
if( hover != thumbHover ) { if( hover != thumbHover ) {
thumbHover = hover; thumbHover = hover;

View File

@@ -264,7 +264,7 @@ public class FlatSpinnerUI
FlatUIUtils.paintParentBackground( g, c ); FlatUIUtils.paintParentBackground( g, c );
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
FlatUIUtils.setRenderingHints( g2 ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g2 );
int width = c.getWidth(); int width = c.getWidth();
int height = c.getHeight(); int height = c.getHeight();
@@ -303,6 +303,8 @@ public class FlatSpinnerUI
} }
paint( g, c ); paint( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
//---- class Handler ------------------------------------------------------ //---- class Handler ------------------------------------------------------

View File

@@ -20,7 +20,6 @@ import java.awt.Color;
import java.awt.Container; import java.awt.Container;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
@@ -148,10 +147,12 @@ public class FlatSplitPaneUI
if( "plain".equals( style ) ) if( "plain".equals( style ) )
return; return;
FlatUIUtils.setRenderingHints( (Graphics2D) g ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
g.setColor( gripColor ); g.setColor( gripColor );
paintGrip( g, 0, 0, getWidth(), getHeight() ); paintGrip( g, 0, 0, getWidth(), getHeight() );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
protected void paintGrip( Graphics g, int x, int y, int width, int height ) { protected void paintGrip( Graphics g, int x, int y, int width, int height ) {

View File

@@ -226,6 +226,8 @@ public class FlatTabbedPaneUI
private boolean rolloverTabClose; private boolean rolloverTabClose;
private boolean pressedTabClose; private boolean pressedTabClose;
private Object[] oldRenderingHints;
public static ComponentUI createUI( JComponent c ) { public static ComponentUI createUI( JComponent c ) {
return new FlatTabbedPaneUI(); return new FlatTabbedPaneUI();
} }
@@ -791,9 +793,12 @@ public class FlatTabbedPaneUI
@Override @Override
public void update( Graphics g, JComponent c ) { public void update( Graphics g, JComponent c ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g ); oldRenderingHints = FlatUIUtils.setRenderingHints( g );
super.update( g, c ); super.update( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
oldRenderingHints = null;
} }
@Override @Override
@@ -874,27 +879,29 @@ public class FlatTabbedPaneUI
{ {
g.setFont( font ); g.setFont( font );
// html FlatUIUtils.runWithoutRenderingHints( g, oldRenderingHints, () -> {
View view = getTextViewForTab( tabIndex ); // html
if( view != null ) { View view = getTextViewForTab( tabIndex );
view.paint( g, textRect ); if( view != null ) {
return; view.paint( g, textRect );
} return;
}
// plain text // plain text
Color color; Color color;
if( tabPane.isEnabled() && tabPane.isEnabledAt( tabIndex ) ) { if( tabPane.isEnabled() && tabPane.isEnabledAt( tabIndex ) ) {
color = tabPane.getForegroundAt( tabIndex ); color = tabPane.getForegroundAt( tabIndex );
if( isSelected && (color instanceof UIResource) && selectedForeground != null ) if( isSelected && (color instanceof UIResource) && selectedForeground != null )
color = selectedForeground; color = selectedForeground;
} else } else
color = disabledForeground; color = disabledForeground;
int mnemIndex = FlatLaf.isShowMnemonics() ? tabPane.getDisplayedMnemonicIndexAt( tabIndex ) : -1; 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,
textRect.x, textRect.y + metrics.getAscent() ); textRect.x, textRect.y + metrics.getAscent() );
} );
} }
@Override @Override

View File

@@ -31,6 +31,7 @@ import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JScrollPane; import javax.swing.JScrollPane;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.border.Border; import javax.swing.border.Border;
@@ -98,10 +99,13 @@ public class FlatTableHeaderUI
@Override @Override
public void paint( Graphics g, JComponent c ) { public void paint( Graphics g, JComponent c ) {
if( header.getColumnModel().getColumnCount() <= 0 )
return;
// do not paint borders if JTableHeader.setDefaultRenderer() was used // do not paint borders if JTableHeader.setDefaultRenderer() was used
TableCellRenderer defaultRenderer = header.getDefaultRenderer(); TableCellRenderer defaultRenderer = header.getDefaultRenderer();
boolean paintBorders = isSystemDefaultRenderer( defaultRenderer ); boolean paintBorders = isSystemDefaultRenderer( defaultRenderer );
if( !paintBorders && header.getColumnModel().getColumnCount() > 0 ) { if( !paintBorders ) {
// check whether the renderer delegates to the system default renderer // check whether the renderer delegates to the system default renderer
Component rendererComponent = defaultRenderer.getTableCellRendererComponent( Component rendererComponent = defaultRenderer.getTableCellRendererComponent(
header.getTable(), "", false, false, -1, 0 ); header.getTable(), "", false, false, -1, 0 );
@@ -145,6 +149,9 @@ public class FlatTableHeaderUI
float bottomLineIndent = lineWidth * 3; float bottomLineIndent = lineWidth * 3;
TableColumnModel columnModel = header.getColumnModel(); TableColumnModel columnModel = header.getColumnModel();
int columnCount = columnModel.getColumnCount(); int columnCount = columnModel.getColumnCount();
int sepCount = columnCount;
if( hideLastVerticalLine() )
sepCount--;
Graphics2D g2 = (Graphics2D) g.create(); Graphics2D g2 = (Graphics2D) g.create();
try { try {
@@ -157,23 +164,30 @@ public class FlatTableHeaderUI
// paint column separator lines // paint column separator lines
g2.setColor( separatorColor ); g2.setColor( separatorColor );
int sepCount = columnCount; float y = topLineIndent;
if( header.getTable() != null && header.getTable().getAutoResizeMode() != JTable.AUTO_RESIZE_OFF && !isVerticalScrollBarVisible() ) float h = height - bottomLineIndent;
sepCount--;
if( header.getComponentOrientation().isLeftToRight() ) { if( header.getComponentOrientation().isLeftToRight() ) {
int x = 0; int x = 0;
for( int i = 0; i < sepCount; i++ ) { for( int i = 0; i < sepCount; i++ ) {
x += columnModel.getColumn( i ).getWidth(); x += columnModel.getColumn( i ).getWidth();
g2.fill( new Rectangle2D.Float( x - lineWidth, topLineIndent, lineWidth, height - bottomLineIndent ) ); g2.fill( new Rectangle2D.Float( x - lineWidth, y, lineWidth, h ) );
} }
// paint trailing separator (on right side)
if( !hideTrailingVerticalLine() )
g2.fill( new Rectangle2D.Float( header.getWidth() - lineWidth, y, lineWidth, h ) );
} else { } else {
int x = width; Rectangle cellRect = header.getHeaderRect( 0 );
int x = cellRect.x + cellRect.width;
for( int i = 0; i < sepCount; i++ ) { for( int i = 0; i < sepCount; i++ ) {
x -= columnModel.getColumn( i ).getWidth(); x -= columnModel.getColumn( i ).getWidth();
g2.fill( new Rectangle2D.Float( x - (i < sepCount - 1 ? lineWidth : 0), g2.fill( new Rectangle2D.Float( x - (i < sepCount - 1 ? lineWidth : 0), y, lineWidth, h ) );
topLineIndent, lineWidth, height - bottomLineIndent ) );
} }
// paint trailing separator (on left side)
if( !hideTrailingVerticalLine() )
g2.fill( new Rectangle2D.Float( 0, y, lineWidth, h ) );
} }
} finally { } finally {
g2.dispose(); g2.dispose();
@@ -230,20 +244,30 @@ public class FlatTableHeaderUI
return size; return size;
} }
private boolean isVerticalScrollBarVisible() { protected boolean hideLastVerticalLine() {
JScrollPane scrollPane = getScrollPane(); Container viewport = header.getParent();
return (scrollPane != null && scrollPane.getVerticalScrollBar() != null) Container viewportParent = (viewport != null) ? viewport.getParent() : null;
? scrollPane.getVerticalScrollBar().isVisible() if( !(viewportParent instanceof JScrollPane) )
: false; return false;
Rectangle cellRect = header.getHeaderRect( header.getColumnModel().getColumnCount() - 1 );
// using component orientation of scroll pane here because it is also used in FlatTableUI
JScrollPane scrollPane = (JScrollPane) viewportParent;
return scrollPane.getComponentOrientation().isLeftToRight()
? cellRect.x + cellRect.width >= viewport.getWidth()
: cellRect.x <= 0;
} }
private JScrollPane getScrollPane() { protected boolean hideTrailingVerticalLine() {
Container parent = header.getParent(); Container viewport = header.getParent();
if( parent == null ) Container viewportParent = (viewport != null) ? viewport.getParent() : null;
return null; if( !(viewportParent instanceof JScrollPane) )
return false;
parent = parent.getParent(); JScrollPane scrollPane = (JScrollPane) viewportParent;
return (parent instanceof JScrollPane) ? (JScrollPane) parent : null; return viewport == scrollPane.getColumnHeader() &&
scrollPane.getCorner( ScrollPaneConstants.UPPER_TRAILING_CORNER ) == null;
} }
//---- class FlatTableCellHeaderRenderer ---------------------------------- //---- class FlatTableCellHeaderRenderer ----------------------------------

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.ui; package com.formdev.flatlaf.ui;
import java.awt.Color; import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.Graphics; import java.awt.Graphics;
@@ -26,8 +27,10 @@ import java.awt.event.FocusListener;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JTable; import javax.swing.JScrollPane;
import javax.swing.JViewport;
import javax.swing.LookAndFeel; import javax.swing.LookAndFeel;
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.BasicTableUI; import javax.swing.plaf.basic.BasicTableUI;
@@ -215,16 +218,11 @@ public class FlatTableUI
boolean verticalLines = table.getShowVerticalLines(); boolean verticalLines = table.getShowVerticalLines();
if( horizontalLines || verticalLines ) { if( horizontalLines || verticalLines ) {
// fix grid painting issues in BasicTableUI // fix grid painting issues in BasicTableUI
// - do not paint last vertical grid line if auto-resize mode is not off // - do not paint last vertical grid line if line is on right edge of scroll pane
// - in right-to-left component orientation, do not paint last vertical grid line
// in any auto-resize mode; can not paint on left side of table because
// cells are painted over left line
// - fix unstable grid line thickness when scaled at 125%, 150%, 175%, 225%, ... // - fix unstable grid line thickness when scaled at 125%, 150%, 175%, 225%, ...
// which paints either 1px or 2px lines depending on location // which paints either 1px or 2px lines depending on location
boolean hideLastVerticalLine = boolean hideLastVerticalLine = hideLastVerticalLine();
table.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF ||
!table.getComponentOrientation().isLeftToRight();
int tableWidth = table.getWidth(); int tableWidth = table.getWidth();
double systemScaleFactor = UIScale.getSystemScaleFactor( (Graphics2D) g ); double systemScaleFactor = UIScale.getSystemScaleFactor( (Graphics2D) g );
@@ -281,4 +279,26 @@ public class FlatTableUI
super.paint( g, c ); super.paint( g, c );
} }
protected boolean hideLastVerticalLine() {
Container viewport = SwingUtilities.getUnwrappedParent( table );
Container viewportParent = (viewport != null) ? viewport.getParent() : null;
if( !(viewportParent instanceof JScrollPane) )
return false;
// do not hide last vertical line if table is smaller than viewport
if( table.getX() + table.getWidth() < viewport.getWidth() )
return false;
// in left-to-right:
// - do not hide last vertical line if table used as row header in scroll pane
// in right-to-left:
// - hide last vertical line if table used as row header in scroll pane
// - do not hide last vertical line if table is in center and scroll pane has row header
JScrollPane scrollPane = (JScrollPane) viewportParent;
JViewport rowHeader = scrollPane.getRowHeader();
return scrollPane.getComponentOrientation().isLeftToRight()
? (viewport != rowHeader)
: (viewport == rowHeader || rowHeader == null);
}
} }

View File

@@ -106,13 +106,15 @@ public class FlatToolBarSeparatorUI
float lineWidth = scale( 1f ); float lineWidth = scale( 1f );
float offset = scale( 2f ); float offset = scale( 2f );
FlatUIUtils.setRenderingHints( (Graphics2D) g ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
g.setColor( separatorColor ); g.setColor( separatorColor );
if( isVertical( c ) ) if( isVertical( c ) )
((Graphics2D)g).fill( new Rectangle2D.Float( Math.round( (width - lineWidth) / 2f ), offset, lineWidth, height - (offset * 2) ) ); ((Graphics2D)g).fill( new Rectangle2D.Float( Math.round( (width - lineWidth) / 2f ), offset, lineWidth, height - (offset * 2) ) );
else else
((Graphics2D)g).fill( new Rectangle2D.Float( offset, Math.round( (height - lineWidth) / 2f ), width - (offset * 2), lineWidth ) ); ((Graphics2D)g).fill( new Rectangle2D.Float( offset, Math.round( (height - lineWidth) / 2f ), width - (offset * 2), lineWidth ) );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
private boolean isVertical( JComponent c ) { private boolean isVertical( JComponent c ) {

View File

@@ -116,7 +116,6 @@ public class FlatToolTipUI
FontMetrics fm = c.getFontMetrics( c.getFont() ); FontMetrics fm = c.getFontMetrics( c.getFont() );
Insets insets = c.getInsets(); Insets insets = c.getInsets();
FlatUIUtils.setRenderingHints( (Graphics2D) g );
g.setColor( c.getForeground() ); g.setColor( c.getForeground() );
List<String> lines = StringUtils.split( ((JToolTip)c).getTipText(), '\n' ); List<String> lines = StringUtils.split( ((JToolTip)c).getTipText(), '\n' );

View File

@@ -240,10 +240,57 @@ public class FlatUIUtils
/** /**
* Sets rendering hints used for painting. * Sets rendering hints used for painting.
*/ */
public static void setRenderingHints( Graphics2D g ) { public static Object[] setRenderingHints( Graphics g ) {
g.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); Graphics2D g2 = (Graphics2D) g;
g.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, Object[] oldRenderingHints = new Object[] {
g2.getRenderingHint( RenderingHints.KEY_ANTIALIASING ),
g2.getRenderingHint( RenderingHints.KEY_STROKE_CONTROL ),
};
g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
g2.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL,
MAC_USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE ); MAC_USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE );
return oldRenderingHints;
}
/**
* Resets rendering hints previously set with {@link #setRenderingHints}.
*/
public static void resetRenderingHints( Graphics g, Object[] oldRenderingHints ) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, oldRenderingHints[0] );
g2.setRenderingHint( RenderingHints.KEY_STROKE_CONTROL, oldRenderingHints[1] );
}
/**
* Temporary resets rendering hints set with {@link #setRenderingHints}
* and runs the given runnable.
* <p>
* This is intended for painting text while rendering hints are set.
* <p>
* If text antialiasing is disabled (in OS system settings or via
* {@code -Dawt.useSystemAAFontSettings=off}), but general antialiasing is enabled,
* then text is still painted using some kind of "grayscale" antialiasing,
* which may make the text look bold (depends on font and font size).
* To avoid this, temporary disable general antialiasing.
* This does not affect text rendering if text antialiasing is enabled (usually the default).
*/
public static void runWithoutRenderingHints( Graphics g, Object[] oldRenderingHints, Runnable runnable ) {
if( oldRenderingHints == null ) {
runnable.run();
return;
}
Graphics2D g2 = (Graphics2D) g;
Object[] oldRenderingHints2 = new Object[] {
g2.getRenderingHint( RenderingHints.KEY_ANTIALIASING ),
g2.getRenderingHint( RenderingHints.KEY_STROKE_CONTROL ),
};
resetRenderingHints( g2, oldRenderingHints );
runnable.run();
resetRenderingHints( g2, oldRenderingHints2 );
} }
public static Color deriveColor( Color color, Color baseColor ) { public static Color deriveColor( Color color, Color baseColor ) {

View File

@@ -0,0 +1,249 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.util;
import java.awt.Component;
import java.awt.Graphics;
import javax.swing.Icon;
import javax.swing.JComponent;
import com.formdev.flatlaf.util.Animator.Interpolator;
/**
* Icon that automatically animates painting on component value changes.
* <p>
* {@link #getValue(Component)} returns the value of the component.
* If the value changes, then {@link #paintIconAnimated(Component, Graphics, int, int, float)}
* is invoked multiple times with animated value (from old value to new value).
* <p>
* Example for an animated icon:
* <pre>
* private class AnimatedMinimalTestIcon
* implements AnimatedIcon
* {
* &#64;Override public int getIconWidth() { return 100; }
* &#64;Override public int getIconHeight() { return 20; }
*
* &#64;Override
* public void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue ) {
* int w = getIconWidth();
* int h = getIconHeight();
*
* g.setColor( Color.red );
* g.drawRect( x, y, w - 1, h - 1 );
* g.fillRect( x, y, Math.round( w * animatedValue ), h );
* }
*
* &#64;Override
* public float getValue( Component c ) {
* return ((AbstractButton)c).isSelected() ? 1 : 0;
* }
* }
*
* // sample usage
* JCheckBox checkBox = new JCheckBox( "test" );
* checkBox.setIcon( new AnimatedMinimalTestIcon() );
* </pre>
*
* Animation works only if the component passed to {@link #paintIcon(Component, Graphics, int, int)}
* is a instance of {@link JComponent}.
* A client property is set on the component to store the animation state.
*
* @author Karl Tauber
*/
public interface AnimatedIcon
extends Icon
{
@Override
public default void paintIcon( Component c, Graphics g, int x, int y ) {
AnimationSupport.paintIcon( this, c, g, x, y );
}
/**
* Paints the icon for the given animated value.
*
* @param c the component that this icon belongs to
* @param g the graphics context
* @param x the x coordinate of the icon
* @param y the y coordinate of the icon
* @param animatedValue the animated value, which is either equal to what {@link #getValue(Component)}
* returned, or somewhere between the previous value and the latest value
* that {@link #getValue(Component)} returned
*/
void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue );
/**
* Gets the value of the component.
* <p>
* This can be any value and depends on the component.
* If the value changes, then this class animates from the old value to the new one.
* <p>
* For a toggle button this could be {@code 0} for off and {@code 1} for on.
*/
float getValue( Component c );
/**
* Returns whether animation is enabled for this icon (default is {@code true}).
*/
default boolean isAnimationEnabled() {
return true;
}
/**
* Returns the duration of the animation in milliseconds (default is 150).
*/
default int getAnimationDuration() {
return 150;
}
/**
* Returns the resolution of the animation in milliseconds (default is 10).
* Resolution is the amount of time between timing events.
*/
default int getAnimationResolution() {
return 10;
}
/**
* Returns the interpolator for the animation.
* Default is {@link CubicBezierEasing#STANDARD_EASING}.
*/
default Interpolator getAnimationInterpolator() {
return CubicBezierEasing.STANDARD_EASING;
}
/**
* Returns the client property key used to store the animation support.
*/
default Object getClientPropertyKey() {
return getClass();
}
//---- class AnimationSupport ---------------------------------------------
/**
* Animation support class that stores the animation state and implements the animation.
*/
class AnimationSupport
{
private float startValue;
private float targetValue;
private float animatedValue;
private float fraction;
private Animator animator;
// last x,y coordinates of the icon needed to repaint while animating
private int x;
private int y;
public static void paintIcon( AnimatedIcon icon, Component c, Graphics g, int x, int y ) {
if( !isAnimationEnabled( icon, c ) ) {
// paint without animation if animation is disabled or
// component is not a JComponent and therefore does not support
// client properties, which are required to keep animation state
paintIconImpl( icon, c, g, x, y, null );
return;
}
JComponent jc = (JComponent) c;
Object key = icon.getClientPropertyKey();
AnimationSupport as = (AnimationSupport) jc.getClientProperty( key );
if( as == null ) {
// painted first time --> do not animate, but remember current component value
as = new AnimationSupport();
as.startValue = as.targetValue = as.animatedValue = icon.getValue( c );
as.x = x;
as.y = y;
jc.putClientProperty( key, as );
} else {
// get component value
float value = icon.getValue( c );
if( value != as.targetValue ) {
// value changed --> (re)start animation
if( as.animator == null ) {
// create animator
AnimationSupport as2 = as;
as.animator = new Animator( icon.getAnimationDuration(), fraction -> {
// check whether component was removed while animation is running
if( !c.isDisplayable() ) {
as2.animator.stop();
return;
}
// compute animated value
as2.animatedValue = as2.startValue + ((as2.targetValue - as2.startValue) * fraction);
as2.fraction = fraction;
// repaint icon
c.repaint( as2.x, as2.y, icon.getIconWidth(), icon.getIconHeight() );
}, () -> {
as2.startValue = as2.animatedValue = as2.targetValue;
as2.animator = null;
} );
}
if( as.animator.isRunning() ) {
// if animation is still running, restart it from the current
// animated value to the new target value with reduced duration
as.animator.cancel();
int duration2 = (int) (icon.getAnimationDuration() * as.fraction);
if( duration2 > 0 )
as.animator.setDuration( duration2 );
as.startValue = as.animatedValue;
} else {
// new animation
as.animator.setDuration( icon.getAnimationDuration() );
as.animator.setResolution( icon.getAnimationResolution() );
as.animator.setInterpolator( icon.getAnimationInterpolator() );
as.animatedValue = as.startValue;
}
as.targetValue = value;
as.animator.start();
}
as.x = x;
as.y = y;
}
paintIconImpl( icon, c, g, x, y, as );
}
private static void paintIconImpl( AnimatedIcon icon, Component c, Graphics g, int x, int y, AnimationSupport as ) {
float value = (as != null) ? as.animatedValue : icon.getValue( c );
icon.paintIconAnimated( c, g, x, y, value );
}
private static boolean isAnimationEnabled( AnimatedIcon icon, Component c ) {
return Animator.useAnimation() && icon.isAnimationEnabled() && c instanceof JComponent;
}
public static void saveIconLocation( AnimatedIcon icon, Component c, int x, int y ) {
if( !isAnimationEnabled( icon, c ) )
return;
AnimationSupport as = (AnimationSupport) ((JComponent)c).getClientProperty( icon.getClientPropertyKey() );
if( as != null ) {
as.x = x;
as.y = y;
}
}
}
}

View File

@@ -44,6 +44,38 @@ public class ColorFunctions
: value); : value);
} }
/**
* Returns a color that is a mixture of two colors.
*
* @param color1 first color
* @param color2 second color
* @param weight the weight (in range 0-1) to mix the two colors.
* Larger weight uses more of first color, smaller weight more of second color.
* @return mixture of colors
*/
public static Color mix( Color color1, Color color2, float weight ) {
if( weight >= 1 )
return color1;
if( weight <= 0 )
return color2;
int r1 = color1.getRed();
int g1 = color1.getGreen();
int b1 = color1.getBlue();
int a1 = color1.getAlpha();
int r2 = color2.getRed();
int g2 = color2.getGreen();
int b2 = color2.getBlue();
int a2 = color2.getAlpha();
return new Color(
Math.round( r2 + ((r1 - r2) * weight) ),
Math.round( g2 + ((g1 - g2) * weight) ),
Math.round( b2 + ((b1 - b2) * weight) ),
Math.round( a2 + ((a1 - a2) * weight) ) );
}
//---- interface ColorFunction -------------------------------------------- //---- interface ColorFunction --------------------------------------------
public interface ColorFunction { public interface ColorFunction {

View File

@@ -24,6 +24,13 @@ package com.formdev.flatlaf.util;
public class CubicBezierEasing public class CubicBezierEasing
implements Animator.Interpolator implements Animator.Interpolator
{ {
/**
* Standard easing as specified in Material design (0.4, 0, 0.2, 1).
*
* @see <a href="https://material.io/design/motion/speed.html#easing">https://material.io/design/motion/speed.html#easing</a>
*/
public static final CubicBezierEasing STANDARD_EASING = new CubicBezierEasing( 0.4f, 0f, 0.2f, 1f );
// common cubic-bezier easing functions (same as in CSS) // common cubic-bezier easing functions (same as in CSS)
// https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function // https://developer.mozilla.org/en-US/docs/Web/CSS/easing-function
public static final CubicBezierEasing EASE = new CubicBezierEasing( 0.25f, 0.1f, 0.25f, 1f ); public static final CubicBezierEasing EASE = new CubicBezierEasing( 0.25f, 0.1f, 0.25f, 1f );

View File

@@ -113,7 +113,7 @@ public class UIScale
} }
public static double getSystemScaleFactor( Graphics2D g ) { public static double getSystemScaleFactor( Graphics2D g ) {
return isSystemScalingEnabled() ? g.getDeviceConfiguration().getDefaultTransform().getScaleX() : 1; return isSystemScalingEnabled() ? getSystemScaleFactor( g.getDeviceConfiguration() ) : 1;
} }
public static double getSystemScaleFactor( GraphicsConfiguration gc ) { public static double getSystemScaleFactor( GraphicsConfiguration gc ) {

View File

@@ -275,7 +275,7 @@ TabbedPane.closePressedForeground=$TabbedPane.closeHoverForeground
#---- Table ---- #---- Table ----
Table.gridColor=lighten($Table.background,3%) Table.gridColor=lighten($Table.background,5%)
#---- TableHeader ---- #---- TableHeader ----

View File

@@ -287,7 +287,7 @@ TabbedPane.closePressedForeground=$TabbedPane.closeHoverForeground
#---- Table ---- #---- Table ----
Table.gridColor=darken($Table.background,3%) Table.gridColor=darken($Table.background,5%)
#---- TableHeader ---- #---- TableHeader ----

View File

@@ -2,3 +2,12 @@ FlatLaf Demo
============ ============
This sub-project contains the FlatLaf Demo source code. This sub-project contains the FlatLaf Demo source code.
Download
--------
[![Download Demo](https://download.formdev.com/flatlaf/images/download-demo.svg)](https://download.formdev.com/flatlaf/flatlaf-demo-latest.jar)
Run demo with `java -jar flatlaf-demo-<version>.jar` (or double-click it).
Requires Java 8 or newer.

View File

@@ -32,7 +32,7 @@ import com.formdev.flatlaf.demo.intellijthemes.*;
import com.formdev.flatlaf.extras.FlatAnimatedLafChange; import com.formdev.flatlaf.extras.FlatAnimatedLafChange;
import com.formdev.flatlaf.extras.FlatSVGIcon; import com.formdev.flatlaf.extras.FlatSVGIcon;
import com.formdev.flatlaf.extras.FlatUIDefaultsInspector; import com.formdev.flatlaf.extras.FlatUIDefaultsInspector;
import com.formdev.flatlaf.extras.SVGUtils; import com.formdev.flatlaf.extras.FlatSVGUtils;
import com.formdev.flatlaf.ui.JBRCustomDecorations; import com.formdev.flatlaf.ui.JBRCustomDecorations;
import net.miginfocom.layout.ConstraintParser; import net.miginfocom.layout.ConstraintParser;
import net.miginfocom.layout.LC; import net.miginfocom.layout.LC;
@@ -59,7 +59,7 @@ class DemoFrame
updateFontMenuItems(); updateFontMenuItems();
controlBar.initialize( this, tabbedPane ); controlBar.initialize( this, tabbedPane );
setIconImages( SVGUtils.createWindowIconImages( "/com/formdev/flatlaf/demo/FlatLaf.svg" ) ); setIconImages( FlatSVGUtils.createWindowIconImages( "/com/formdev/flatlaf/demo/FlatLaf.svg" ) );
if( tabIndex >= 0 && tabIndex < tabbedPane.getTabCount() && tabIndex != tabbedPane.getSelectedIndex() ) if( tabIndex >= 0 && tabIndex < tabbedPane.getTabCount() && tabIndex != tabbedPane.getSelectedIndex() )
tabbedPane.setSelectedIndex( tabIndex ); tabbedPane.setSelectedIndex( tabIndex );

View File

@@ -18,6 +18,7 @@ package com.formdev.flatlaf.demo.extras;
import javax.swing.*; import javax.swing.*;
import com.formdev.flatlaf.extras.*; import com.formdev.flatlaf.extras.*;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
/** /**
@@ -63,7 +64,7 @@ public class ExtrasPanel
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
label4 = new JLabel(); label4 = new JLabel();
label1 = new JLabel(); label1 = new JLabel();
triStateCheckBox1 = new TriStateCheckBox(); triStateCheckBox1 = new FlatTriStateCheckBox();
triStateLabel1 = new JLabel(); triStateLabel1 = new JLabel();
label2 = new JLabel(); label2 = new JLabel();
svgIconsPanel = new JPanel(); svgIconsPanel = new JPanel();
@@ -124,7 +125,7 @@ public class ExtrasPanel
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JLabel label4; private JLabel label4;
private JLabel label1; private JLabel label1;
private TriStateCheckBox triStateCheckBox1; private FlatTriStateCheckBox triStateCheckBox1;
private JLabel triStateLabel1; private JLabel triStateLabel1;
private JLabel label2; private JLabel label2;
private JPanel svgIconsPanel; private JPanel svgIconsPanel;

View File

@@ -21,7 +21,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1" "value": "cell 0 1"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox1" name: "triStateCheckBox1"
"text": "Three States" "text": "Three States"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) )

View File

@@ -108,7 +108,8 @@ public class IJThemesClassGenerator
allInfos.append( THEME_TEMPLATE allInfos.append( THEME_TEMPLATE
.replace( "${subPackage}", subPackage ) .replace( "${subPackage}", subPackage )
.replace( "${themeClass}", themeClass ) .replace( "${themeClass}", themeClass )
.replace( "${themeName}", themeName ) ); .replace( "${themeName}", themeName )
.replace( "${dark}", Boolean.toString( ti.dark ) ) );
markdownTable.append( String.format( "[%s](%s) | `com.formdev.flatlaf.intellijthemes%s.%s`\n", markdownTable.append( String.format( "[%s](%s) | `com.formdev.flatlaf.intellijthemes%s.%s`\n",
themeName, ti.sourceCodeUrl, subPackage, themeClass ) ); themeName, ti.sourceCodeUrl, subPackage, themeClass ) );
@@ -189,11 +190,28 @@ public class IJThemesClassGenerator
" */\n" + " */\n" +
"public class FlatAllIJThemes\n" + "public class FlatAllIJThemes\n" +
"{\n" + "{\n" +
" public static final LookAndFeelInfo[] INFOS = {\n" + " public static final FlatIJLookAndFeelInfo[] INFOS = {\n" +
"${allInfos}\n" + "${allInfos}\n" +
" };\n" + " };\n" +
"\n" +
" //---- class FlatIJLookAndFeelInfo ----------------------------------------\n" +
"\n" +
" public static class FlatIJLookAndFeelInfo\n" +
" extends LookAndFeelInfo\n" +
" {\n" +
" private final boolean dark;\n" +
"\n" +
" public FlatIJLookAndFeelInfo( String name, String className, boolean dark ) {\n" +
" super( name, className );\n" +
" this.dark = dark;\n" +
" }\n" +
"\n" +
" public boolean isDark() {\n" +
" return dark;\n" +
" }\n" +
" }\n" +
"}\n"; "}\n";
private static final String THEME_TEMPLATE = private static final String THEME_TEMPLATE =
" new LookAndFeelInfo( \"${themeName}\", \"com.formdev.flatlaf.intellijthemes${subPackage}.${themeClass}\" ),"; " new FlatIJLookAndFeelInfo( \"${themeName}\", \"com.formdev.flatlaf.intellijthemes${subPackage}.${themeClass}\", ${dark} ),";
} }

View File

@@ -7,9 +7,12 @@ This sub-project provides some additional components and classes:
An icon that displays SVG using An icon that displays SVG using
[svgSalamander](https://github.com/JFormDesigner/svgSalamander).\ [svgSalamander](https://github.com/JFormDesigner/svgSalamander).\
![FlatSVGIcon.png](../images/extras-FlatSVGIcon.png) ![FlatSVGIcon.png](../images/extras-FlatSVGIcon.png)
- [TriStateCheckBox](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/TriStateCheckBox.html): - [FlatTriStateCheckBox](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/components/FlatTriStateCheckBox.html):
A tri-state check box.\ A tri-state check box.\
![TriStateCheckBox.png](../images/extras-TriStateCheckBox.png) ![TriStateCheckBox.png](../images/extras-TriStateCheckBox.png)
- Extension classes of standard Swing components that provide easy access to
FlatLaf specific client properties (see package
[com.formdev.flatlaf.extras.components](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/components/package-summary.html)).
- [FlatAnimatedLafChange](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/FlatAnimatedLafChange.html): - [FlatAnimatedLafChange](https://www.javadoc.io/doc/com.formdev/flatlaf-extras/latest/com/formdev/flatlaf/extras/FlatAnimatedLafChange.html):
Animated Laf (theme) changing. Animated Laf (theme) changing.
- [FlatInspector](#ui-inspector): A simple UI inspector that shows information - [FlatInspector](#ui-inspector): A simple UI inspector that shows information
@@ -35,10 +38,8 @@ Otherwise download `flatlaf-extras-<version>.jar` here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-extras/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-extras/_latestVersion) [![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-extras/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-extras/_latestVersion)
You also need `flatlaf-<version>.jar` and `svgSalamander-<version>.jar`, which If SVG classes are used, `svgSalamander-<version>.jar` is also required:
you can download here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf/_latestVersion)
[![Download](https://api.bintray.com/packages/jformdesigner/svgSalamander/svgSalamander/images/download.svg)](https://bintray.com/jformdesigner/svgSalamander/svgSalamander/_latestVersion) [![Download](https://api.bintray.com/packages/jformdesigner/svgSalamander/svgSalamander/images/download.svg)](https://bintray.com/jformdesigner/svgSalamander/svgSalamander/_latestVersion)

View File

@@ -40,6 +40,7 @@ tasks {
this as StandardJavadocDocletOptions this as StandardJavadocDocletOptions
use( true ) use( true )
tags = listOf( "uiDefault", "clientProperty" ) tags = listOf( "uiDefault", "clientProperty" )
addStringOption( "Xdoclint:all,-missing", "-Xdoclint:all,-missing" )
} }
isFailOnError = false isFailOnError = false
} }

View File

@@ -24,7 +24,6 @@ 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.KeyboardFocusManager; import java.awt.KeyboardFocusManager;
import java.awt.LayoutManager; import java.awt.LayoutManager;
@@ -348,8 +347,9 @@ public class FlatInspector
@Override @Override
protected void paintBorder( Graphics g ) { protected void paintBorder( Graphics g ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
super.paintBorder( g ); super.paintBorder( g );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
}; };
c.setBackground( new Color( 255, 0, 0, 32 ) ); c.setBackground( new Color( 255, 0, 0, 32 ) );

View File

@@ -34,7 +34,7 @@ import com.kitfox.svg.SVGException;
* *
* @author Karl Tauber * @author Karl Tauber
*/ */
public class SVGUtils public class FlatSVGUtils
{ {
/** /**
* Creates from the given SVG a list of icon images with different sizes that * Creates from the given SVG a list of icon images with different sizes that
@@ -131,7 +131,7 @@ public class SVGUtils
*/ */
private static SVGDiagram loadSVG( String svgName ) { private static SVGDiagram loadSVG( String svgName ) {
try { try {
URL url = SVGUtils.class.getResource( svgName ); URL url = FlatSVGUtils.class.getResource( svgName );
return SVGCache.getSVGUniverse().getDiagram( url.toURI() ); return SVGCache.getSVGUniverse().getDiagram( url.toURI() );
} catch( URISyntaxException ex ) { } catch( URISyntaxException ex ) {
throw new RuntimeException( ex ); throw new RuntimeException( ex );

View File

@@ -1,141 +0,0 @@
/*
* 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.extras;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ItemEvent;
import javax.swing.JCheckBox;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import com.formdev.flatlaf.FlatLaf;
/**
* A tri-state check box.
* <p>
* To display the third state, this component requires an LaF that supports painting
* the indeterminate state if client property {@code "JButton.selectedState"} has the
* value {@code "indeterminate"}.
* <p>
* FlatLaf and Mac Aqua LaF support the third state.
* For other LaFs a magenta rectangle is painted around the component for the third state.
*
* @author Karl Tauber
*/
public class TriStateCheckBox
extends JCheckBox
{
public enum State { INDETERMINATE, SELECTED, UNSELECTED }
private State state;
private boolean thirdStateEnabled = true;
public TriStateCheckBox() {
this( null );
}
public TriStateCheckBox( String text ) {
this( text, State.INDETERMINATE );
}
public TriStateCheckBox( String text, State initialState ) {
super( text );
setModel( new ToggleButtonModel() {
@Override
public boolean isSelected() {
return state != State.UNSELECTED;
}
@Override
public void setSelected( boolean b ) {
switch( state ) {
case INDETERMINATE: setState( State.SELECTED ); break;
case SELECTED: setState( State.UNSELECTED ); break;
case UNSELECTED: setState( thirdStateEnabled ? State.INDETERMINATE : State.SELECTED ); break;
}
fireStateChanged();
fireItemStateChanged( new ItemEvent( this, ItemEvent.ITEM_STATE_CHANGED, this,
isSelected() ? ItemEvent.SELECTED : ItemEvent.DESELECTED ) );
}
} );
setState( initialState );
}
public State getState() {
return state;
}
public void setState( State state ) {
if( this.state == state )
return;
State oldState = this.state;
this.state = state;
putClientProperty( "JButton.selectedState", state == State.INDETERMINATE ? "indeterminate" : null );
firePropertyChange( "state", oldState, state );
repaint();
}
public Boolean getValue() {
switch( state ) {
default:
case INDETERMINATE: return null;
case SELECTED: return true;
case UNSELECTED: return false;
}
}
public void setValue( Boolean value ) {
setState( value == null ? State.INDETERMINATE : (value ? State.SELECTED : State.UNSELECTED) );
}
public boolean isThirdStateEnabled() {
return thirdStateEnabled;
}
public void setThirdStateEnabled( boolean thirdStateEnabled ) {
this.thirdStateEnabled = thirdStateEnabled;
if( state == State.INDETERMINATE )
setState( State.UNSELECTED );
}
@Override
public void setSelected( boolean b ) {
setState( b ? State.SELECTED : State.UNSELECTED );
}
@Override
protected void paintComponent( Graphics g ) {
super.paintComponent( g );
if( state == State.INDETERMINATE && !isThirdStateSupported() ) {
g.setColor( Color.magenta );
g.drawRect( 0, 0, getWidth() - 1, getHeight() - 1 );
}
}
private boolean isThirdStateSupported() {
LookAndFeel laf = UIManager.getLookAndFeel();
return laf instanceof FlatLaf || laf.getClass().getName().equals( "com.apple.laf.AquaLookAndFeel" );
}
}

View File

@@ -0,0 +1,120 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JButton;
/**
* Subclass of {@link JButton} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatButton
extends JButton
implements FlatComponentExtension
{
// NOTE: enum names must be equal to allowed strings
public enum ButtonType { none, square, roundRect, tab, help, toolBarButton };
/**
* Returns type of a button.
*/
public ButtonType getButtonType() {
return getClientPropertyEnumString( BUTTON_TYPE, ButtonType.class, null, ButtonType.none );
}
/**
* Specifies type of a button.
*/
public void setButtonType( ButtonType buttonType ) {
if( buttonType == ButtonType.none )
buttonType = null;
putClientPropertyEnumString( BUTTON_TYPE, buttonType );
}
/**
* Returns whether the button preferred size will be made square (quadratically).
*/
public boolean isSquareSize() {
return getClientPropertyBoolean( SQUARE_SIZE, false );
}
/**
* Specifies whether the button preferred size will be made square (quadratically).
*/
public void setSquareSize( boolean squareSize ) {
putClientPropertyBoolean( SQUARE_SIZE, squareSize, false );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Button.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns minimum height of a component.
*/
public int getMinimumHeight() {
return getClientPropertyInt( MINIMUM_HEIGHT, 0 );
}
/**
* Specifies minimum height of a component.
*/
public void setMinimumHeight( int minimumHeight ) {
putClientProperty( MINIMUM_HEIGHT, (minimumHeight >= 0) ? minimumHeight : null );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,100 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JComboBox;
/**
* Subclass of {@link JComboBox} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatComboBox<E>
extends JComboBox<E>
implements FlatComponentExtension
{
/**
* Returns the placeholder text that is only painted if the editable combo box is empty.
*/
public String getPlaceholderText() {
return (String) getClientProperty( PLACEHOLDER_TEXT );
}
/**
* Sets the placeholder text that is only painted if the editable combo box is empty.
*/
public void setPlaceholderText( String placeholderText ) {
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "ComboBox.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import java.awt.Color;
import java.awt.Insets;
import javax.swing.JComponent;
import javax.swing.UIManager;
/**
* Base interface for all FlatLaf component extensions.
* Extensions use client properties to store property values in components.
*
* @author Karl Tauber
*/
public interface FlatComponentExtension
{
/**
* Overrides {@link JComponent#getClientProperty(Object)}.
*/
Object getClientProperty( Object key );
/**
* Overrides {@link JComponent#putClientProperty(Object, Object)}.
*/
void putClientProperty( Object key, Object value );
default boolean getClientPropertyBoolean( Object key, String defaultValueKey ) {
Object value = getClientProperty( key );
return (value instanceof Boolean) ? (boolean) value : UIManager.getBoolean( defaultValueKey );
}
default boolean getClientPropertyBoolean( Object key, boolean defaultValue ) {
Object value = getClientProperty( key );
return (value instanceof Boolean) ? (boolean) value : defaultValue;
}
default void putClientPropertyBoolean( Object key, boolean value, boolean defaultValue ) {
putClientProperty( key, (value != defaultValue) ? value : null );
}
default int getClientPropertyInt( Object key, String defaultValueKey ) {
Object value = getClientProperty( key );
return (value instanceof Integer) ? (int) value : UIManager.getInt( defaultValueKey );
}
default int getClientPropertyInt( Object key, int defaultValue ) {
Object value = getClientProperty( key );
return (value instanceof Integer) ? (int) value : defaultValue;
}
default Color getClientPropertyColor( Object key, String defaultValueKey ) {
Object value = getClientProperty( key );
return (value instanceof Color) ? (Color) value : UIManager.getColor( defaultValueKey );
}
default Insets getClientPropertyInsets( Object key, String defaultValueKey ) {
Object value = getClientProperty( key );
return (value instanceof Insets) ? (Insets) value : UIManager.getInsets( defaultValueKey );
}
default <T extends Enum<T>> T getClientPropertyEnumString( Object key, Class<T> enumType,
String defaultValueKey, T defaultValue )
{
Object value = getClientProperty( key );
if( !(value instanceof String) && defaultValueKey != null )
value = UIManager.getString( defaultValueKey );
if( value instanceof String ) {
try {
return Enum.valueOf( enumType, (String) value );
} catch( IllegalArgumentException ex ) {
ex.printStackTrace();
}
}
return defaultValue;
}
default <T extends Enum<T>> void putClientPropertyEnumString( Object key, Enum<T> value ) {
putClientProperty( key, (value != null) ? value.toString() : null );
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JEditorPane;
/**
* Subclass of {@link JEditorPane} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatEditorPane
extends JEditorPane
implements FlatComponentExtension
{
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JFormattedTextField;
import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy;
/**
* Subclass of {@link JFormattedTextField} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatFormattedTextField
extends JFormattedTextField
implements FlatComponentExtension
{
/**
* Returns the placeholder text that is only painted if the text field is empty.
*/
public String getPlaceholderText() {
return (String) getClientProperty( PLACEHOLDER_TEXT );
}
/**
* Sets the placeholder text that is only painted if the text field is empty.
*/
public void setPlaceholderText( String placeholderText ) {
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
}
/**
* Returns whether all text is selected when the text component gains focus.
*/
public SelectAllOnFocusPolicy getSelectAllOnFocusPolicy() {
return getClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, SelectAllOnFocusPolicy.class,
"TextComponent.selectAllOnFocusPolicy", SelectAllOnFocusPolicy.once );
}
/**
* Specifies whether all text is selected when the text component gains focus.
*/
public void setSelectAllOnFocusPolicy( SelectAllOnFocusPolicy selectAllOnFocusPolicy ) {
putClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, selectAllOnFocusPolicy );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JPasswordField;
import com.formdev.flatlaf.extras.components.FlatTextField.SelectAllOnFocusPolicy;
/**
* Subclass of {@link JPasswordField} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatPasswordField
extends JPasswordField
implements FlatComponentExtension
{
/**
* Returns the placeholder text that is only painted if the text field is empty.
*/
public String getPlaceholderText() {
return (String) getClientProperty( PLACEHOLDER_TEXT );
}
/**
* Sets the placeholder text that is only painted if the text field is empty.
*/
public void setPlaceholderText( String placeholderText ) {
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
}
/**
* Returns whether all text is selected when the text component gains focus.
*/
public SelectAllOnFocusPolicy getSelectAllOnFocusPolicy() {
return getClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, SelectAllOnFocusPolicy.class,
"TextComponent.selectAllOnFocusPolicy", SelectAllOnFocusPolicy.once );
}
/**
* Specifies whether all text is selected when the text component gains focus.
*/
public void setSelectAllOnFocusPolicy( SelectAllOnFocusPolicy selectAllOnFocusPolicy ) {
putClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, selectAllOnFocusPolicy );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JProgressBar;
/**
* Subclass of {@link JProgressBar} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatProgressBar
extends JProgressBar
implements FlatComponentExtension
{
/**
* Returns whether the progress bar has always the larger height even if no string is painted.
*/
public boolean isLargeHeight() {
return getClientPropertyBoolean( PROGRESS_BAR_LARGE_HEIGHT, false );
}
/**
* Specifies whether the progress bar has always the larger height even if no string is painted.
*/
public void setLargeHeight( boolean largeHeight ) {
putClientPropertyBoolean( PROGRESS_BAR_LARGE_HEIGHT, largeHeight, false );
}
/**
* Returns whether the progress bar is paint with square edges.
*/
public boolean isSquare() {
return getClientPropertyBoolean( PROGRESS_BAR_SQUARE, false );
}
/**
* Specifies whether the progress bar is paint with square edges.
*/
public void setSquare( boolean square ) {
putClientPropertyBoolean( PROGRESS_BAR_SQUARE, square, false );
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JScrollBar;
/**
* Subclass of {@link JScrollBar} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatScrollBar
extends JScrollBar
implements FlatComponentExtension
{
/**
* Returns whether the decrease/increase arrow buttons of a scrollbar are shown.
*/
public boolean isShowButtons() {
return getClientPropertyBoolean( SCROLL_BAR_SHOW_BUTTONS, "ScrollBar.showButtons" );
}
/**
* Specifies whether the decrease/increase arrow buttons of a scrollbar are shown.
*/
public void setShowButtons( boolean showButtons ) {
putClientProperty( SCROLL_BAR_SHOW_BUTTONS, showButtons );
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JScrollPane;
/**
* Subclass of {@link JScrollPane} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatScrollPane
extends JScrollPane
implements FlatComponentExtension
{
/**
* Returns whether the decrease/increase arrow buttons of a scrollbar are shown.
*/
public boolean isShowButtons() {
return getClientPropertyBoolean( SCROLL_BAR_SHOW_BUTTONS, "ScrollBar.showButtons" );
}
/**
* Specifies whether the decrease/increase arrow buttons of a scrollbar are shown.
*/
public void setShowButtons( boolean showButtons ) {
putClientProperty( SCROLL_BAR_SHOW_BUTTONS, showButtons );
}
/**
* Returns whether the scroll pane uses smooth scrolling.
*/
public boolean isSmoothScrolling() {
return getClientPropertyBoolean( SCROLL_PANE_SMOOTH_SCROLLING, "ScrollPane.smoothScrolling" );
}
/**
* Specifies whether the scroll pane uses smooth scrolling.
*/
public void setSmoothScrolling( boolean smoothScrolling ) {
putClientProperty( SCROLL_PANE_SMOOTH_SCROLLING, smoothScrolling );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,85 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JSpinner;
/**
* Subclass of {@link JSpinner} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatSpinner
extends JSpinner
implements FlatComponentExtension
{
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,537 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Component;
import java.awt.Insets;
import java.util.function.BiConsumer;
import javax.swing.JComponent;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;
/**
* Subclass of {@link JTabbedPane} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatTabbedPane
extends JTabbedPane
implements FlatComponentExtension
{
/**
* Returns whether separators are shown between tabs.
*/
public boolean isShowTabSeparators() {
return getClientPropertyBoolean( TABBED_PANE_SHOW_TAB_SEPARATORS, "TabbedPane.showTabSeparators" );
}
/**
* Specifies whether separators are shown between tabs.
*/
public void setShowTabSeparators( boolean showTabSeparators ) {
putClientProperty( TABBED_PANE_SHOW_TAB_SEPARATORS, showTabSeparators );
}
/**
* Returns whether the separator between tabs area and content area should be shown.
*/
public boolean isShowContentSeparators() {
return getClientPropertyBoolean( TABBED_PANE_SHOW_CONTENT_SEPARATOR, true );
}
/**
* Specifies whether the separator between tabs area and content area should be shown.
*/
public void setShowContentSeparators( boolean showContentSeparators ) {
putClientPropertyBoolean( TABBED_PANE_SHOW_CONTENT_SEPARATOR, showContentSeparators, true );
}
/**
* Returns whether a full border is painted around a tabbed pane.
*/
public boolean isHasFullBorder() {
return getClientPropertyBoolean( TABBED_PANE_HAS_FULL_BORDER, "TabbedPane.hasFullBorder" );
}
/**
* Specifies whether a full border is painted around a tabbed pane.
*/
public void setHasFullBorder( boolean hasFullBorder ) {
putClientProperty( TABBED_PANE_HAS_FULL_BORDER, hasFullBorder );
}
/**
* Returns whether the tab area should be hidden if it contains only one tab.
*/
public boolean isHideTabAreaWithOneTab() {
return getClientPropertyBoolean( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, false );
}
/**
* Specifies whether the tab area should be hidden if it contains only one tab.
*/
public void setHideTabAreaWithOneTab( boolean hideTabAreaWithOneTab ) {
putClientPropertyBoolean( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, hideTabAreaWithOneTab, false );
}
/**
* Returns the minimum width of a tab.
*/
public int getMinimumTabWidth() {
return getClientPropertyInt( TABBED_PANE_MINIMUM_TAB_WIDTH, "TabbedPane.minimumTabWidth" );
}
/**
* Specifies the minimum width of a tab.
*/
public void setMinimumTabWidth( int minimumTabWidth ) {
putClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, (minimumTabWidth >= 0) ? minimumTabWidth : null );
}
/**
* Returns the minimum width of the tab at the given tab index.
*/
public int getMinimumTabWidth( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return clientPropertyInt( c, TABBED_PANE_MINIMUM_TAB_WIDTH, 0 );
}
/**
* Specifies the minimum width of the tab at the given tab index.
*/
public void setMinimumTabWidth( int tabIndex, int minimumTabWidth ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, (minimumTabWidth >= 0) ? minimumTabWidth : null );
}
/**
* Returns the maximum width of a tab.
*/
public int getMaximumTabWidth() {
return getClientPropertyInt( TABBED_PANE_MAXIMUM_TAB_WIDTH, "TabbedPane.maximumTabWidth" );
}
/**
* Specifies the maximum width of a tab.
* <p>
* Applied only if tab does not have a custom tab component
* (see {@link javax.swing.JTabbedPane#setTabComponentAt(int, java.awt.Component)}).
*/
public void setMaximumTabWidth( int maximumTabWidth ) {
putClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, (maximumTabWidth >= 0) ? maximumTabWidth : null );
}
/**
* Returns the maximum width of the tab at the given tab index.
*/
public int getMaximumTabWidth( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return clientPropertyInt( c, TABBED_PANE_MAXIMUM_TAB_WIDTH, 0 );
}
/**
* Specifies the maximum width of the tab at the given tab index.
* <p>
* Applied only if tab does not have a custom tab component
* (see {@link javax.swing.JTabbedPane#setTabComponentAt(int, java.awt.Component)}).
*/
public void setMaximumTabWidth( int tabIndex, int maximumTabWidth ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, (maximumTabWidth >= 0) ? maximumTabWidth : null );
}
/**
* Returns the height of a tab.
*/
public int getTabHeight() {
return getClientPropertyInt( TABBED_PANE_TAB_HEIGHT, "TabbedPane.tabHeight" );
}
/**
* Specifies the height of a tab.
*/
public void setTabHeight( int tabHeight ) {
putClientProperty( TABBED_PANE_TAB_HEIGHT, (tabHeight >= 0) ? tabHeight : null );
}
/**
* Returns the insets of a tab.
*/
public Insets getTabInsets() {
return getClientPropertyInsets( TABBED_PANE_TAB_INSETS, "TabbedPane.tabInsets" );
}
/**
* Specifies the insets of a tab.
*/
public void setTabInsets( Insets tabInsets ) {
putClientProperty( TABBED_PANE_TAB_INSETS, tabInsets );
}
/**
* Returns the insets of the tab at the given tab index.
*/
public Insets getTabInsets( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return (Insets) c.getClientProperty( TABBED_PANE_TAB_INSETS );
}
/**
* Specifies the insets of the tab at the given tab index.
*/
public void setTabInsets( int tabIndex, Insets tabInsets ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_INSETS, tabInsets );
}
/**
* Returns the insets of the tab area.
*/
public Insets getTabAreaInsets() {
return getClientPropertyInsets( TABBED_PANE_TAB_AREA_INSETS, "TabbedPane.tabAreaInsets" );
}
/**
* Specifies the insets of the tab area.
*/
public void setTabAreaInsets( Insets tabAreaInsets ) {
putClientProperty( TABBED_PANE_TAB_AREA_INSETS, tabAreaInsets );
}
/**
* Returns whether all tabs are closable.
*/
public boolean isTabsClosable() {
return getClientPropertyBoolean( TABBED_PANE_TAB_CLOSABLE, false );
}
/**
* Specifies whether all tabs are closable.
* If set to {@code true}, all tabs in that tabbed pane are closable.
* To make individual tabs closable, use {@link #setTabClosable(int, boolean)}.
* <p>
* Note that you have to specify a callback (see {@link #setTabCloseCallback(BiConsumer)})
* that is invoked when the user clicks a tab close button.
* The callback is responsible for closing the tab.
*/
public void setTabsClosable( boolean tabClosable ) {
putClientPropertyBoolean( TABBED_PANE_TAB_CLOSABLE, tabClosable, false );
}
/**
* Returns whether the tab at the given tab index is closable.
*/
public Boolean isTabClosable( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
Object value = c.getClientProperty( TABBED_PANE_TAB_CLOSABLE );
return (value instanceof Boolean) ? (boolean) value : isTabsClosable();
}
/**
* Specifies whether the tab at the given tab index is closable.
* To make all tabs closable, use {@link #setTabsClosable(boolean)}.
* <p>
* Note that you have to specify a callback (see {@link #setTabCloseCallback(BiConsumer)})
* that is invoked when the user clicks a tab close button.
* The callback is responsible for closing the tab.
*/
public void setTabClosable( int tabIndex, boolean tabClosable ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_CLOSABLE, tabClosable );
}
/**
* Returns the tooltip text used for tab close buttons.
*/
public String getTabCloseToolTipText() {
return (String) getClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT );
}
/**
* Specifies the tooltip text used for tab close buttons.
*/
public void setTabCloseToolTipText( String tabCloseToolTipText ) {
putClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, tabCloseToolTipText );
}
/**
* Returns the tooltip text used for tab close button at the given tab index.
*/
public String getTabCloseToolTipText( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return (String) c.getClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT );
}
/**
* Specifies the tooltip text used for tab close button at the given tab index.
*/
public void setTabCloseToolTipText( int tabIndex, String tabCloseToolTipText ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, tabCloseToolTipText );
}
/**
* Returns the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab.
*/
@SuppressWarnings( "unchecked" )
public BiConsumer<JTabbedPane, Integer> getTabCloseCallback() {
return (BiConsumer<JTabbedPane, Integer>) getClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK );
}
/**
* Specifies the callback that is invoked when a tab close button is clicked.
* The callback is responsible for closing the tab.
* <p>
* Use a {@link java.util.function.BiConsumer}&lt;javax.swing.JTabbedPane, Integer&gt;
* that receives the tabbed pane and the tab index as parameters:
* <pre>{@code
* myTabbedPane.setTabCloseCallback( (tabbedPane, tabIndex) -> {
* // close tab here
* } );
* }</pre>
* If you need to check whether a modifier key (e.g. Alt or Shift) was pressed
* while the user clicked the tab close button, use {@link java.awt.EventQueue#getCurrentEvent}
* to get current event, check whether it is a {@link java.awt.event.MouseEvent}
* and invoke its methods. E.g.
* <pre>{@code
* AWTEvent e = EventQueue.getCurrentEvent();
* boolean shift = (e instanceof MouseEvent) ? ((MouseEvent)e).isShiftDown() : false;
* }</pre>
*/
public void setTabCloseCallback( BiConsumer<JTabbedPane, Integer> tabCloseCallback ) {
putClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK, tabCloseCallback );
}
/**
* Returns the callback that is invoked when the tab close button at the given tab index is clicked.
* The callback is responsible for closing the tab.
*/
@SuppressWarnings( "unchecked" )
public BiConsumer<JTabbedPane, Integer> getTabCloseCallback( int tabIndex ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
return (BiConsumer<JTabbedPane, Integer>) c.getClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK );
}
/**
* Specifies the callback that is invoked when the tab close button at the given tab index is clicked.
* The callback is responsible for closing the tab.
*
* @see #setTabCloseCallback(BiConsumer)
*/
public void setTabCloseCallback( int tabIndex, BiConsumer<JTabbedPane, Integer> tabCloseCallback ) {
JComponent c = (JComponent) getComponentAt( tabIndex );
c.putClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK, tabCloseCallback );
}
// NOTE: enum names must be equal to allowed strings
public enum TabsPopupPolicy { never, asNeeded };
/**
* Returns the display policy for the "more tabs" button,
* which shows a popup menu with the (partly) hidden tabs.
*/
public TabsPopupPolicy getTabsPopupPolicy() {
return getClientPropertyEnumString( TABBED_PANE_TABS_POPUP_POLICY, TabsPopupPolicy.class,
"TabbedPane.tabsPopupPolicy", TabsPopupPolicy.asNeeded );
}
/**
* Specifies the display policy for the "more tabs" button,
* which shows a popup menu with the (partly) hidden tabs.
*/
public void setTabsPopupPolicy( TabsPopupPolicy tabsPopupPolicy ) {
putClientPropertyEnumString( TABBED_PANE_TABS_POPUP_POLICY, tabsPopupPolicy );
}
// NOTE: enum names must be equal to allowed strings
public enum ScrollButtonsPolicy { never, asNeeded, asNeededSingle };
/**
* Returns the display policy for the forward/backward scroll arrow buttons.
*/
public ScrollButtonsPolicy getScrollButtonsPolicy() {
return getClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_POLICY, ScrollButtonsPolicy.class,
"TabbedPane.scrollButtonsPolicy", ScrollButtonsPolicy.asNeededSingle );
}
/**
* Specifies the display policy for the forward/backward scroll arrow buttons.
*/
public void setScrollButtonsPolicy( ScrollButtonsPolicy scrollButtonsPolicy ) {
putClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_POLICY, scrollButtonsPolicy );
}
// NOTE: enum names must be equal to allowed strings
public enum ScrollButtonsPlacement { both, trailing };
/**
* Returns the placement of the forward/backward scroll arrow buttons.
*/
public ScrollButtonsPlacement getScrollButtonsPlacement() {
return getClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_PLACEMENT, ScrollButtonsPlacement.class,
"TabbedPane.scrollButtonsPlacement", ScrollButtonsPlacement.both );
}
/**
* Specifies the placement of the forward/backward scroll arrow buttons.
*/
public void setScrollButtonsPlacement( ScrollButtonsPlacement scrollButtonsPlacement ) {
putClientPropertyEnumString( TABBED_PANE_SCROLL_BUTTONS_PLACEMENT, scrollButtonsPlacement );
}
// NOTE: enum names must be equal to allowed strings
public enum TabAreaAlignment { leading, trailing, center, fill };
/**
* Returns the alignment of the tab area.
*/
public TabAreaAlignment getTabAreaAlignment() {
return getClientPropertyEnumString( TABBED_PANE_TAB_AREA_ALIGNMENT, TabAreaAlignment.class,
"TabbedPane.tabAreaAlignment", TabAreaAlignment.leading );
}
/**
* Specifies the alignment of the tab area.
*/
public void setTabAreaAlignment( TabAreaAlignment tabAreaAlignment ) {
putClientPropertyEnumString( TABBED_PANE_TAB_AREA_ALIGNMENT, tabAreaAlignment );
}
// NOTE: enum names must be equal to allowed strings
public enum TabAlignment { leading, trailing, center };
/**
* Returns the horizontal alignment of the tab title and icon.
*/
public TabAlignment getTabAlignment() {
return getClientPropertyEnumString( TABBED_PANE_TAB_ALIGNMENT, TabAlignment.class,
"TabbedPane.tabAlignment", TabAlignment.center );
}
/**
* Specifies the horizontal alignment of the tab title and icon.
*/
public void setTabAlignment( TabAlignment tabAlignment ) {
putClientPropertyEnumString( TABBED_PANE_TAB_ALIGNMENT, tabAlignment );
}
// NOTE: enum names must be equal to allowed strings
public enum TabWidthMode { preferred, equal, compact };
/**
* Returns how the tabs should be sized.
*/
public TabWidthMode getTabWidthMode() {
return getClientPropertyEnumString( TABBED_PANE_TAB_WIDTH_MODE, TabWidthMode.class,
"TabbedPane.tabWidthMode", TabWidthMode.preferred );
}
/**
* Specifies how the tabs should be sized.
*/
public void setTabWidthMode( TabWidthMode tabWidthMode ) {
putClientPropertyEnumString( TABBED_PANE_TAB_WIDTH_MODE, tabWidthMode );
}
/**
* Returns the tab icon placement (relative to tab title).
*/
public int getTabIconPlacement() {
return getClientPropertyInt( TABBED_PANE_TAB_ICON_PLACEMENT, SwingConstants.LEADING );
}
/**
* Specifies the tab icon placement (relative to tab title).
* <p>
* Allowed Values are:
* <ul>
* <li>{@link SwingConstants#LEADING} (default)
* <li>{@link SwingConstants#TRAILING}
* <li>{@link SwingConstants#TOP}
* <li>{@link SwingConstants#BOTTOM}
* </ul>
*/
public void setTabIconPlacement( int tabIconPlacement ) {
putClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, (tabIconPlacement >= 0) ? tabIconPlacement : null );
}
/**
* Returns a component that will be placed at the leading edge of the tabs area.
*/
public Component getLeadingComponent() {
return (Component) getClientProperty( TABBED_PANE_LEADING_COMPONENT );
}
/**
* Specifies a component that will be placed at the leading edge of the tabs area.
* <p>
* For top and bottom tab placement, the layed out component size will be
* the preferred component width and the tab area height.<br>
* For left and right tab placement, the layed out component size will be
* the tab area width and the preferred component height.
*/
public void setLeadingComponent( Component leadingComponent ) {
putClientProperty( TABBED_PANE_LEADING_COMPONENT, leadingComponent );
}
/**
* Returns a component that will be placed at the trailing edge of the tabs area.
*/
public Component getTrailingComponent() {
return (Component) getClientProperty( TABBED_PANE_TRAILING_COMPONENT );
}
/**
* Specifies a component that will be placed at the trailing edge of the tabs area.
* <p>
* For top and bottom tab placement, the layed out component size will be
* the available horizontal space (minimum is preferred component width) and the tab area height.<br>
* For left and right tab placement, the layed out component size will be
* the tab area width and the available vertical space (minimum is preferred component height).
*/
public void setTrailingComponent( Component trailingComponent ) {
putClientProperty( TABBED_PANE_TRAILING_COMPONENT, trailingComponent );
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JTextArea;
/**
* Subclass of {@link JTextArea} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatTextArea
extends JTextArea
implements FlatComponentExtension
{
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
}

View File

@@ -0,0 +1,119 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JTextField;
/**
* Subclass of {@link JTextField} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatTextField
extends JTextField
implements FlatComponentExtension
{
/**
* Returns the placeholder text that is only painted if the text field is empty.
*/
public String getPlaceholderText() {
return (String) getClientProperty( PLACEHOLDER_TEXT );
}
/**
* Sets the placeholder text that is only painted if the text field is empty.
*/
public void setPlaceholderText( String placeholderText ) {
putClientProperty( PLACEHOLDER_TEXT, placeholderText );
}
// NOTE: enum names must be equal to allowed strings
public enum SelectAllOnFocusPolicy { never, once, always };
/**
* Returns whether all text is selected when the text component gains focus.
*/
public SelectAllOnFocusPolicy getSelectAllOnFocusPolicy() {
return getClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, SelectAllOnFocusPolicy.class,
"TextComponent.selectAllOnFocusPolicy", SelectAllOnFocusPolicy.once );
}
/**
* Specifies whether all text is selected when the text component gains focus.
*/
public void setSelectAllOnFocusPolicy( SelectAllOnFocusPolicy selectAllOnFocusPolicy ) {
putClientPropertyEnumString( SELECT_ALL_ON_FOCUS_POLICY, selectAllOnFocusPolicy );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns whether the component is painted with round edges.
*/
public boolean isRoundRect() {
return getClientPropertyBoolean( COMPONENT_ROUND_RECT, false );
}
/**
* Specifies whether the component is painted with round edges.
*/
public void setRoundRect( boolean roundRect ) {
putClientPropertyBoolean( COMPONENT_ROUND_RECT, roundRect, false );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import javax.swing.JTextPane;
/**
* Subclass of {@link JTextPane} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatTextPane
extends JTextPane
implements FlatComponentExtension
{
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "Component.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
}

View File

@@ -0,0 +1,163 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import javax.swing.JToggleButton;
import com.formdev.flatlaf.extras.components.FlatButton.ButtonType;
/**
* Subclass of {@link JToggleButton} that provides easy access to FlatLaf specific client properties.
*
* @author Karl Tauber
*/
public class FlatToggleButton
extends JToggleButton
implements FlatComponentExtension
{
/**
* Returns type of a button.
*/
public ButtonType getButtonType() {
return getClientPropertyEnumString( BUTTON_TYPE, ButtonType.class, null, ButtonType.none );
}
/**
* Specifies type of a button.
*/
public void setButtonType( ButtonType buttonType ) {
if( buttonType == ButtonType.none )
buttonType = null;
putClientPropertyEnumString( BUTTON_TYPE, buttonType );
}
/**
* Returns whether the button preferred size will be made square (quadratically).
*/
public boolean isSquareSize() {
return getClientPropertyBoolean( SQUARE_SIZE, false );
}
/**
* Specifies whether the button preferred size will be made square (quadratically).
*/
public void setSquareSize( boolean squareSize ) {
putClientPropertyBoolean( SQUARE_SIZE, squareSize, false );
}
/**
* Returns minimum width of a component.
*/
public int getMinimumWidth() {
return getClientPropertyInt( MINIMUM_WIDTH, "ToggleButton.minimumWidth" );
}
/**
* Specifies minimum width of a component.
*/
public void setMinimumWidth( int minimumWidth ) {
putClientProperty( MINIMUM_WIDTH, (minimumWidth >= 0) ? minimumWidth : null );
}
/**
* Returns minimum height of a component.
*/
public int getMinimumHeight() {
return getClientPropertyInt( MINIMUM_HEIGHT, 0 );
}
/**
* Specifies minimum height of a component.
*/
public void setMinimumHeight( int minimumHeight ) {
putClientProperty( MINIMUM_HEIGHT, (minimumHeight >= 0) ? minimumHeight : null );
}
/**
* Returns the outline color of the component border.
*/
public Object getOutline() {
return getClientProperty( OUTLINE );
}
/**
* Specifies the outline color of the component border.
* <p>
* Allowed Values are:
* <ul>
* <li>{@code null}
* <li>string {@code "error"}
* <li>string {@code "warning"}
* <li>any color (type {@link Color})
* <li>an array of two colors (type {@link Color}[2]) where the first color
* is for focused state and the second for unfocused state
* </ul>
*/
public void setOutline( Object outline ) {
putClientProperty( OUTLINE, outline );
}
/**
* Returns height of underline if toggle button type is {@link ButtonType#tab}.
*/
public int getTabUnderlineHeight() {
return getClientPropertyInt( TAB_BUTTON_UNDERLINE_HEIGHT, "ToggleButton.tab.underlineHeight" );
}
/**
* Specifies height of underline if toggle button type is {@link ButtonType#tab}.
*/
public void setTabUnderlineHeight( int tabUnderlineHeight ) {
putClientProperty( TAB_BUTTON_UNDERLINE_HEIGHT, (tabUnderlineHeight >= 0) ? tabUnderlineHeight : null );
}
/**
* Returns color of underline if toggle button type is {@link ButtonType#tab}.
*/
public Color getTabUnderlineColor() {
return getClientPropertyColor( TAB_BUTTON_UNDERLINE_COLOR, "ToggleButton.tab.underlineColor" );
}
/**
* Specifies color of underline if toggle button type is {@link ButtonType#tab}.
*/
public void setTabUnderlineColor( Color tabUnderlineColor ) {
putClientProperty( TAB_BUTTON_UNDERLINE_COLOR, tabUnderlineColor );
}
/**
* Returns background color if selected and toggle button type is {@link ButtonType#tab}.
*/
public Color getTabSelectedBackground() {
return getClientPropertyColor( TAB_BUTTON_SELECTED_BACKGROUND, "ToggleButton.tab.selectedBackground" );
}
/**
* Specifies background color if selected and toggle button type is {@link ButtonType#tab}.
*/
public void setTabSelectedBackground( Color tabSelectedBackground ) {
putClientProperty( TAB_BUTTON_SELECTED_BACKGROUND, tabSelectedBackground );
}
}

View File

@@ -0,0 +1,255 @@
/*
* 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.extras.components;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ItemEvent;
import javax.swing.JCheckBox;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import com.formdev.flatlaf.FlatLaf;
/**
* A tri-state check box.
* <p>
* The initial state is {@link State#INDETERMINATE}.
* <p>
* By default the third state is allowed and clicking on the checkbox cycles thru all
* three states. If you want that the user can cycle only thru two states, disallow
* intermediate state using {@link #setAllowIndeterminate(boolean)}. Then you can still
* set the indeterminate state via API if necessary, but the user can not.
* <p>
* The default state cycle order is {@link State#UNSELECTED} to {@link State#INDETERMINATE}
* to {@link State#SELECTED}.
* This is the same order as used by macOS, win32, IntelliJ IDEA and on the web as recommended by W3C in
* <a href="https://www.w3.org/TR/wai-aria-practices-1.1/examples/checkbox/checkbox-2/checkbox-2.html">Tri-State Checkbox Example</a>).
* <p>
* If {@link #isAltStateCycleOrder()} returns {@code true},
* the state cycle order is {@link State#UNSELECTED} to {@link State#SELECTED}
* to {@link State#INDETERMINATE}. This order is used by Windows 10 UWP apps.
* <p>
* If you prefer the alternative state cycle order for all tri-state check boxes, enable it using:
* <pre>
* UIManager.put( "FlatTriStateCheckBox.altStateCycleOrder", true );
* </pre>
* <p>
* To display the third state, this component requires an LaF that supports painting
* the indeterminate state if client property {@code "JButton.selectedState"} has the
* value {@code "indeterminate"}.
* FlatLaf and macOS Aqua LaF support the third state.
* For other LaFs a magenta rectangle is painted around the component for the third state.
*
* @author Karl Tauber
*/
public class FlatTriStateCheckBox
extends JCheckBox
{
public enum State { UNSELECTED, INDETERMINATE, SELECTED }
private State state;
private boolean allowIndeterminate = true;
private boolean altStateCycleOrder = UIManager.getBoolean( "FlatTriStateCheckBox.altStateCycleOrder" );
public FlatTriStateCheckBox() {
this( null );
}
public FlatTriStateCheckBox( String text ) {
this( text, State.INDETERMINATE );
}
public FlatTriStateCheckBox( String text, State initialState ) {
super( text );
setModel( new ToggleButtonModel() {
@Override
public boolean isSelected() {
return state != State.UNSELECTED;
}
@Override
public void setSelected( boolean b ) {
setState( nextState( state ) );
fireStateChanged();
fireItemStateChanged( new ItemEvent( this, ItemEvent.ITEM_STATE_CHANGED, this,
isSelected() ? ItemEvent.SELECTED : ItemEvent.DESELECTED ) );
}
} );
setState( initialState );
}
/**
* Returns the state as {@link State} enum.
* <p>
* Alternatively you can use {@link #getChecked()} to get all three states as {@link Boolean}
* or {@link #isIndeterminate()} to check only for indeterminate state.
*/
public State getState() {
return state;
}
/**
* Sets the state as {@link State} enum.
*/
public void setState( State state ) {
if( this.state == state )
return;
State oldState = this.state;
this.state = state;
putClientProperty( SELECTED_STATE, (state == State.INDETERMINATE) ? SELECTED_STATE_INDETERMINATE : null );
firePropertyChange( "state", oldState, state );
repaint();
}
/**
* Returns the next state that follows the given state, depending on
* {@link #isAllowIndeterminate()} and {@link #isAltStateCycleOrder()}.
*/
protected State nextState( State state ) {
if( !altStateCycleOrder ) {
// default cycle order: UNSELECTED --> INDETERMINATE --> SELECTED
switch( state ) {
default:
case UNSELECTED: return allowIndeterminate ? State.INDETERMINATE : State.SELECTED;
case INDETERMINATE: return State.SELECTED;
case SELECTED: return State.UNSELECTED;
}
} else {
// alternative cycle order: INDETERMINATE --> UNSELECTED --> SELECTED
switch( state ) {
default:
case UNSELECTED: return State.SELECTED;
case INDETERMINATE: return State.UNSELECTED;
case SELECTED: return allowIndeterminate ? State.INDETERMINATE : State.UNSELECTED;
}
}
}
/**
* Returns the state as {@link Boolean}.
* Returns {@code null} if the state is {@link State#INDETERMINATE}.
* <p>
* Alternatively you can use {@link #getState()} to get state as {@link State} enum
* or {@link #isIndeterminate()} to check only for indeterminate state.
*/
public Boolean getChecked() {
switch( state ) {
default:
case UNSELECTED: return false;
case INDETERMINATE: return null;
case SELECTED: return true;
}
}
/**
* Sets the state as {@link Boolean}.
* Passing {@code null} sets state to {@link State#INDETERMINATE}.
*/
public void setChecked( Boolean value ) {
setState( (value == null) ? State.INDETERMINATE : (value ? State.SELECTED : State.UNSELECTED) );
}
@Override
public void setSelected( boolean b ) {
setState( b ? State.SELECTED : State.UNSELECTED );
}
/**
* Returns whether state is indeterminate.
*/
public boolean isIndeterminate() {
return state == State.INDETERMINATE;
}
/**
* Sets indeterminate state.
*/
public void setIndeterminate( boolean indeterminate ) {
if( indeterminate )
setState( State.INDETERMINATE );
else if( state == State.INDETERMINATE )
setState( State.UNSELECTED );
}
/**
* Returns whether indeterminate state is allowed.
* <p>
* This affects only the user when clicking on the checkbox.
* Setting state to indeterminate via API is always allowed.
*/
public boolean isAllowIndeterminate() {
return allowIndeterminate;
}
/**
* Sets whether indeterminate state is allowed.
* <p>
* This affects only the user when clicking on the checkbox.
* Setting state to indeterminate via API is always allowed.
*/
public void setAllowIndeterminate( boolean allowIndeterminate ) {
this.allowIndeterminate = allowIndeterminate;
}
/**
* Returns whether alternative state cycle order should be used.
*/
public boolean isAltStateCycleOrder() {
return altStateCycleOrder;
}
/**
* Sets whether alternative state cycle order should be used.
*/
public void setAltStateCycleOrder( boolean altStateCycleOrder ) {
this.altStateCycleOrder = altStateCycleOrder;
}
@Override
protected void paintComponent( Graphics g ) {
super.paintComponent( g );
if( state == State.INDETERMINATE && !isIndeterminateStateSupported() )
paintIndeterminateState( g );
}
/**
* Paints the indeterminate state if the current LaF does not support displaying
* the indeterminate state.
* The default implementation draws a magenta rectangle around the component.
*/
protected void paintIndeterminateState( Graphics g ) {
g.setColor( Color.magenta );
g.drawRect( 0, 0, getWidth() - 1, getHeight() - 1 );
}
/**
* Returns whether the current LaF supports displaying the indeterminate state.
* Returns {@code true} for FlatLaf and macOS Aqua.
*/
protected boolean isIndeterminateStateSupported() {
LookAndFeel laf = UIManager.getLookAndFeel();
return laf instanceof FlatLaf || laf.getClass().getName().equals( "com.apple.laf.AquaLookAndFeel" );
}
}

View File

@@ -25,10 +25,6 @@ Otherwise download `flatlaf-intellij-themes-<version>.jar` here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-intellij-themes/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-intellij-themes/_latestVersion) [![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-intellij-themes/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-intellij-themes/_latestVersion)
You also need `flatlaf-<version>.jar`, which you can download here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf/_latestVersion)
How to use? How to use?
----------- -----------

View File

@@ -28,65 +28,82 @@ import javax.swing.UIManager.LookAndFeelInfo;
*/ */
public class FlatAllIJThemes public class FlatAllIJThemes
{ {
public static final LookAndFeelInfo[] INFOS = { public static final FlatIJLookAndFeelInfo[] INFOS = {
new LookAndFeelInfo( "Arc", "com.formdev.flatlaf.intellijthemes.FlatArcIJTheme" ), new FlatIJLookAndFeelInfo( "Arc", "com.formdev.flatlaf.intellijthemes.FlatArcIJTheme", false ),
new LookAndFeelInfo( "Arc - Orange", "com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme" ), new FlatIJLookAndFeelInfo( "Arc - Orange", "com.formdev.flatlaf.intellijthemes.FlatArcOrangeIJTheme", false ),
new LookAndFeelInfo( "Arc Dark", "com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme" ), new FlatIJLookAndFeelInfo( "Arc Dark", "com.formdev.flatlaf.intellijthemes.FlatArcDarkIJTheme", true ),
new LookAndFeelInfo( "Arc Dark - Orange", "com.formdev.flatlaf.intellijthemes.FlatArcDarkOrangeIJTheme" ), new FlatIJLookAndFeelInfo( "Arc Dark - Orange", "com.formdev.flatlaf.intellijthemes.FlatArcDarkOrangeIJTheme", true ),
new LookAndFeelInfo( "Carbon", "com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme" ), new FlatIJLookAndFeelInfo( "Carbon", "com.formdev.flatlaf.intellijthemes.FlatCarbonIJTheme", true ),
new LookAndFeelInfo( "Cobalt 2", "com.formdev.flatlaf.intellijthemes.FlatCobalt2IJTheme" ), new FlatIJLookAndFeelInfo( "Cobalt 2", "com.formdev.flatlaf.intellijthemes.FlatCobalt2IJTheme", true ),
new LookAndFeelInfo( "Cyan light", "com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme" ), new FlatIJLookAndFeelInfo( "Cyan light", "com.formdev.flatlaf.intellijthemes.FlatCyanLightIJTheme", false ),
new LookAndFeelInfo( "Dark Flat", "com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme" ), new FlatIJLookAndFeelInfo( "Dark Flat", "com.formdev.flatlaf.intellijthemes.FlatDarkFlatIJTheme", true ),
new LookAndFeelInfo( "Dark purple", "com.formdev.flatlaf.intellijthemes.FlatDarkPurpleIJTheme" ), new FlatIJLookAndFeelInfo( "Dark purple", "com.formdev.flatlaf.intellijthemes.FlatDarkPurpleIJTheme", true ),
new LookAndFeelInfo( "Dracula", "com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme" ), new FlatIJLookAndFeelInfo( "Dracula", "com.formdev.flatlaf.intellijthemes.FlatDraculaIJTheme", true ),
new LookAndFeelInfo( "Gradianto Dark Fuchsia", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDarkFuchsiaIJTheme" ), new FlatIJLookAndFeelInfo( "Gradianto Dark Fuchsia", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDarkFuchsiaIJTheme", true ),
new LookAndFeelInfo( "Gradianto Deep Ocean", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDeepOceanIJTheme" ), new FlatIJLookAndFeelInfo( "Gradianto Deep Ocean", "com.formdev.flatlaf.intellijthemes.FlatGradiantoDeepOceanIJTheme", true ),
new LookAndFeelInfo( "Gradianto Midnight Blue", "com.formdev.flatlaf.intellijthemes.FlatGradiantoMidnightBlueIJTheme" ), new FlatIJLookAndFeelInfo( "Gradianto Midnight Blue", "com.formdev.flatlaf.intellijthemes.FlatGradiantoMidnightBlueIJTheme", true ),
new LookAndFeelInfo( "Gradianto Nature Green", "com.formdev.flatlaf.intellijthemes.FlatGradiantoNatureGreenIJTheme" ), new FlatIJLookAndFeelInfo( "Gradianto Nature Green", "com.formdev.flatlaf.intellijthemes.FlatGradiantoNatureGreenIJTheme", true ),
new LookAndFeelInfo( "Gray", "com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme" ), new FlatIJLookAndFeelInfo( "Gray", "com.formdev.flatlaf.intellijthemes.FlatGrayIJTheme", false ),
new LookAndFeelInfo( "Gruvbox Dark Hard", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkHardIJTheme" ), new FlatIJLookAndFeelInfo( "Gruvbox Dark Hard", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkHardIJTheme", true ),
new LookAndFeelInfo( "Gruvbox Dark Medium", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkMediumIJTheme" ), new FlatIJLookAndFeelInfo( "Gruvbox Dark Medium", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkMediumIJTheme", true ),
new LookAndFeelInfo( "Gruvbox Dark Soft", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkSoftIJTheme" ), new FlatIJLookAndFeelInfo( "Gruvbox Dark Soft", "com.formdev.flatlaf.intellijthemes.FlatGruvboxDarkSoftIJTheme", true ),
new LookAndFeelInfo( "Hiberbee Dark", "com.formdev.flatlaf.intellijthemes.FlatHiberbeeDarkIJTheme" ), new FlatIJLookAndFeelInfo( "Hiberbee Dark", "com.formdev.flatlaf.intellijthemes.FlatHiberbeeDarkIJTheme", true ),
new LookAndFeelInfo( "High contrast", "com.formdev.flatlaf.intellijthemes.FlatHighContrastIJTheme" ), new FlatIJLookAndFeelInfo( "High contrast", "com.formdev.flatlaf.intellijthemes.FlatHighContrastIJTheme", true ),
new LookAndFeelInfo( "Light Flat", "com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme" ), new FlatIJLookAndFeelInfo( "Light Flat", "com.formdev.flatlaf.intellijthemes.FlatLightFlatIJTheme", false ),
new LookAndFeelInfo( "Material Design Dark", "com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme" ), new FlatIJLookAndFeelInfo( "Material Design Dark", "com.formdev.flatlaf.intellijthemes.FlatMaterialDesignDarkIJTheme", true ),
new LookAndFeelInfo( "Monocai", "com.formdev.flatlaf.intellijthemes.FlatMonocaiIJTheme" ), new FlatIJLookAndFeelInfo( "Monocai", "com.formdev.flatlaf.intellijthemes.FlatMonocaiIJTheme", true ),
new LookAndFeelInfo( "Nord", "com.formdev.flatlaf.intellijthemes.FlatNordIJTheme" ), new FlatIJLookAndFeelInfo( "Nord", "com.formdev.flatlaf.intellijthemes.FlatNordIJTheme", true ),
new LookAndFeelInfo( "One Dark", "com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme" ), new FlatIJLookAndFeelInfo( "One Dark", "com.formdev.flatlaf.intellijthemes.FlatOneDarkIJTheme", true ),
new LookAndFeelInfo( "Solarized Dark", "com.formdev.flatlaf.intellijthemes.FlatSolarizedDarkIJTheme" ), new FlatIJLookAndFeelInfo( "Solarized Dark", "com.formdev.flatlaf.intellijthemes.FlatSolarizedDarkIJTheme", true ),
new LookAndFeelInfo( "Solarized Light", "com.formdev.flatlaf.intellijthemes.FlatSolarizedLightIJTheme" ), new FlatIJLookAndFeelInfo( "Solarized Light", "com.formdev.flatlaf.intellijthemes.FlatSolarizedLightIJTheme", false ),
new LookAndFeelInfo( "Spacegray", "com.formdev.flatlaf.intellijthemes.FlatSpacegrayIJTheme" ), new FlatIJLookAndFeelInfo( "Spacegray", "com.formdev.flatlaf.intellijthemes.FlatSpacegrayIJTheme", true ),
new LookAndFeelInfo( "Vuesion", "com.formdev.flatlaf.intellijthemes.FlatVuesionIJTheme" ), new FlatIJLookAndFeelInfo( "Vuesion", "com.formdev.flatlaf.intellijthemes.FlatVuesionIJTheme", true ),
new LookAndFeelInfo( "Arc Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkIJTheme" ), new FlatIJLookAndFeelInfo( "Arc Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkIJTheme", true ),
new LookAndFeelInfo( "Arc Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Arc Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatArcDarkContrastIJTheme", true ),
new LookAndFeelInfo( "Atom One Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkIJTheme" ), new FlatIJLookAndFeelInfo( "Atom One Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkIJTheme", true ),
new LookAndFeelInfo( "Atom One Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Atom One Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneDarkContrastIJTheme", true ),
new LookAndFeelInfo( "Atom One Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme" ), new FlatIJLookAndFeelInfo( "Atom One Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightIJTheme", false ),
new LookAndFeelInfo( "Atom One Light Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Atom One Light Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatAtomOneLightContrastIJTheme", false ),
new LookAndFeelInfo( "Dracula (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaIJTheme" ), new FlatIJLookAndFeelInfo( "Dracula (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaIJTheme", true ),
new LookAndFeelInfo( "Dracula Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Dracula Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatDraculaContrastIJTheme", true ),
new LookAndFeelInfo( "GitHub (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme" ), new FlatIJLookAndFeelInfo( "GitHub (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubIJTheme", false ),
new LookAndFeelInfo( "GitHub Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubContrastIJTheme" ), new FlatIJLookAndFeelInfo( "GitHub Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatGitHubContrastIJTheme", false ),
new LookAndFeelInfo( "Light Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlIJTheme" ), new FlatIJLookAndFeelInfo( "Light Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlIJTheme", false ),
new LookAndFeelInfo( "Light Owl Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Light Owl Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatLightOwlContrastIJTheme", false ),
new LookAndFeelInfo( "Material Darker (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerIJTheme" ), new FlatIJLookAndFeelInfo( "Material Darker (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerIJTheme", true ),
new LookAndFeelInfo( "Material Darker Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Material Darker Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDarkerContrastIJTheme", true ),
new LookAndFeelInfo( "Material Deep Ocean (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanIJTheme" ), new FlatIJLookAndFeelInfo( "Material Deep Ocean (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanIJTheme", true ),
new LookAndFeelInfo( "Material Deep Ocean Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Material Deep Ocean Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialDeepOceanContrastIJTheme", true ),
new LookAndFeelInfo( "Material Lighter (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterIJTheme" ), new FlatIJLookAndFeelInfo( "Material Lighter (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterIJTheme", false ),
new LookAndFeelInfo( "Material Lighter Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Material Lighter Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialLighterContrastIJTheme", false ),
new LookAndFeelInfo( "Material Oceanic (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicIJTheme" ), new FlatIJLookAndFeelInfo( "Material Oceanic (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicIJTheme", true ),
new LookAndFeelInfo( "Material Oceanic Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Material Oceanic Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialOceanicContrastIJTheme", true ),
new LookAndFeelInfo( "Material Palenight (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightIJTheme" ), new FlatIJLookAndFeelInfo( "Material Palenight (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightIJTheme", true ),
new LookAndFeelInfo( "Material Palenight Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Material Palenight Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMaterialPalenightContrastIJTheme", true ),
new LookAndFeelInfo( "Monokai Pro (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProIJTheme" ), new FlatIJLookAndFeelInfo( "Monokai Pro (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProIJTheme", true ),
new LookAndFeelInfo( "Monokai Pro Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Monokai Pro Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatMonokaiProContrastIJTheme", true ),
new LookAndFeelInfo( "Night Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlIJTheme" ), new FlatIJLookAndFeelInfo( "Night Owl (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlIJTheme", true ),
new LookAndFeelInfo( "Night Owl Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Night Owl Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatNightOwlContrastIJTheme", true ),
new LookAndFeelInfo( "Solarized Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkIJTheme" ), new FlatIJLookAndFeelInfo( "Solarized Dark (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkIJTheme", true ),
new LookAndFeelInfo( "Solarized Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Solarized Dark Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedDarkContrastIJTheme", true ),
new LookAndFeelInfo( "Solarized Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightIJTheme" ), new FlatIJLookAndFeelInfo( "Solarized Light (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightIJTheme", false ),
new LookAndFeelInfo( "Solarized Light Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightContrastIJTheme" ), new FlatIJLookAndFeelInfo( "Solarized Light Contrast (Material)", "com.formdev.flatlaf.intellijthemes.materialthemeuilite.FlatSolarizedLightContrastIJTheme", false ),
}; };
//---- class FlatIJLookAndFeelInfo ----------------------------------------
public static class FlatIJLookAndFeelInfo
extends LookAndFeelInfo
{
private final boolean dark;
public FlatIJLookAndFeelInfo( String name, String className, boolean dark ) {
super( name, className );
this.dark = dark;
}
public boolean isDark() {
return dark;
}
}
} }

View File

@@ -8,6 +8,7 @@ Following JIDE Common Layer components are currently supported by this addon:
- `JideTabbedPane` - `JideTabbedPane`
- `RangeSlider` - `RangeSlider`
- `TristateCheckBox`
**Note**: We have currently no plans to support additional components. If you're **Note**: We have currently no plans to support additional components. If you're
@@ -32,7 +33,3 @@ build script:
Otherwise download `flatlaf-jide-oss-<version>.jar` here: Otherwise download `flatlaf-jide-oss-<version>.jar` here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-jide-oss/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-jide-oss/_latestVersion) [![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-jide-oss/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-jide-oss/_latestVersion)
You also need `flatlaf-<version>.jar`, which you can download here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf/_latestVersion)

View File

@@ -19,6 +19,7 @@ package com.formdev.flatlaf.jideoss;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.swing.LookAndFeel;
import javax.swing.UIDefaults; import javax.swing.UIDefaults;
import com.formdev.flatlaf.FlatDefaultsAddon; import com.formdev.flatlaf.FlatDefaultsAddon;
import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.FlatLaf;
@@ -46,6 +47,14 @@ public class FlatJideOssDefaultsAddon
return super.getDefaults( lafClass ); return super.getDefaults( lafClass );
} }
@Override
public void afterDefaultsLoading( LookAndFeel laf, UIDefaults defaults ) {
// TristateCheckBox
defaults.put( "TristateCheckBox.icon", null );
defaults.put( "TristateCheckBox.setMixed.clientProperty", new Object[] { "JButton.selectedState", "indeterminate" } );
defaults.put( "TristateCheckBox.clearMixed.clientProperty", new Object[] { "JButton.selectedState", null } );
}
@Override @Override
public int getPriority() { public int getPriority() {
return 11; return 11;
@@ -71,6 +80,7 @@ public class FlatJideOssDefaultsAddon
Object key = e.getKey(); Object key = e.getKey();
if( key instanceof String && if( key instanceof String &&
(((String)key).startsWith( "Jide" ) || (((String)key).startsWith( "Jide" ) ||
((String)key).startsWith( "TristateCheckBox." ) ||
key.equals( "RangeSliderUI" ) || key.equals( "RangeSliderUI" ) ||
key.equals( "Resizable.resizeBorder" )) ) key.equals( "Resizable.resizeBorder" )) )
{ {
@@ -85,6 +95,9 @@ public class FlatJideOssDefaultsAddon
defaults.putAll( jideDefaults ); defaults.putAll( jideDefaults );
jideDefaults = null; jideDefaults = null;
} }
// TristateCheckBox
defaults.put( "TristateCheckBox.icon", null );
} }
} }
} }

View File

@@ -21,6 +21,7 @@ import static com.formdev.flatlaf.FlatClientProperties.clientPropertyBoolean;
import static com.formdev.flatlaf.util.UIScale.scale; import static com.formdev.flatlaf.util.UIScale.scale;
import java.awt.Color; import java.awt.Color;
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;
@@ -62,6 +63,8 @@ public class FlatJideTabbedPaneUI
protected boolean hasFullBorder; protected boolean hasFullBorder;
protected boolean tabsOverlapBorder; protected boolean tabsOverlapBorder;
private Object[] oldRenderingHints;
public static ComponentUI createUI( JComponent c ) { public static ComponentUI createUI( JComponent c ) {
return new FlatJideTabbedPaneUI(); return new FlatJideTabbedPaneUI();
} }
@@ -193,9 +196,12 @@ public class FlatJideTabbedPaneUI
@Override @Override
public void update( Graphics g, JComponent c ) { public void update( Graphics g, JComponent c ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g ); oldRenderingHints = FlatUIUtils.setRenderingHints( g );
super.update( g, c ); super.update( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
oldRenderingHints = null;
} }
@Override @Override
@@ -222,6 +228,15 @@ public class FlatJideTabbedPaneUI
g.fillRect( x, y, w, h ); g.fillRect( x, y, w, h );
} }
@Override
protected void paintText( Graphics g, int tabPlacement, Font font, FontMetrics metrics,
int tabIndex, String title, Rectangle textRect, boolean isSelected )
{
FlatUIUtils.runWithoutRenderingHints( g, oldRenderingHints, () -> {
super.paintText( g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected );
} );
}
@Override @Override
protected void paintTabBorder( Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, protected void paintTabBorder( Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h,
boolean isSelected ) boolean isSelected )

View File

@@ -23,12 +23,14 @@ import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.geom.RoundRectangle2D; import java.awt.geom.RoundRectangle2D;
import java.util.Dictionary; import java.util.Dictionary;
import java.util.Enumeration; import java.util.Enumeration;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JSlider; import javax.swing.JSlider;
import javax.swing.LookAndFeel; import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI; import javax.swing.plaf.ComponentUI;
import com.formdev.flatlaf.ui.FlatSliderUI; import com.formdev.flatlaf.ui.FlatSliderUI;
@@ -60,6 +62,8 @@ public class FlatRangeSliderUI
protected Color disabledThumbColor; protected Color disabledThumbColor;
protected Color disabledThumbBorderColor; protected Color disabledThumbBorderColor;
private Object[] oldRenderingHints;
public static ComponentUI createUI( JComponent c ) { public static ComponentUI createUI( JComponent c ) {
return new FlatRangeSliderUI(); return new FlatRangeSliderUI();
} }
@@ -142,6 +146,11 @@ public class FlatRangeSliderUI
disabledThumbBorderColor = null; disabledThumbBorderColor = null;
} }
@Override
protected TrackListener createTrackListener( JSlider slider ) {
return new FlatRangeTrackListener( super.createTrackListener( slider ) );
}
@Override @Override
public int getBaseline( JComponent c, int width, int height ) { public int getBaseline( JComponent c, int width, int height ) {
if( c == null ) if( c == null )
@@ -190,7 +199,7 @@ public class FlatRangeSliderUI
@Override @Override
public void paint( Graphics g, JComponent c ) { public void paint( Graphics g, JComponent c ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g ); oldRenderingHints = FlatUIUtils.setRenderingHints( g );
/*debug /*debug
g.setColor( Color.gray ); g.setColor( Color.gray );
@@ -209,6 +218,16 @@ public class FlatRangeSliderUI
debug*/ debug*/
super.paint( g, c ); super.paint( g, c );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
oldRenderingHints = null;
}
@Override
public void paintLabels( Graphics g ) {
FlatUIUtils.runWithoutRenderingHints( g, oldRenderingHints, () -> {
super.paintLabels( g );
} );
} }
@Override @Override
@@ -288,4 +307,64 @@ debug*/
protected boolean isRoundThumb() { protected boolean isRoundThumb() {
return !slider.getPaintTicks() && !slider.getPaintLabels(); return !slider.getPaintTicks() && !slider.getPaintLabels();
} }
//---- class FlatRangeTrackListener ---------------------------------------
protected class FlatRangeTrackListener
extends RangeTrackListener
{
public FlatRangeTrackListener( TrackListener listener ) {
super( listener );
}
@Override
public void mousePressed( MouseEvent e ) {
if( !slider.isEnabled() )
return;
// use "old" behavior when clicking on track
if( UIManager.getBoolean( "Slider.scrollOnTrackClick" ) ) {
super.mousePressed( e );
return;
}
// "new" behavior set thumb to mouse location when clicking on track
int x = e.getX();
int y = e.getY();
int handle = getMouseHandle( x, y );
// clicked on thumb --> let super class do the work
if( handle != MOUSE_HANDLE_LOWER && handle != MOUSE_HANDLE_UPPER ) {
super.mousePressed( e );
return;
}
if( UIManager.getBoolean( "Slider.onlyLeftMouseButtonDrag" ) &&
!SwingUtilities.isLeftMouseButton( e ) )
return;
// get low or high thumb rectangle
Rectangle thumbRect = FlatRangeSliderUI.this.thumbRect;
if( handle == MOUSE_HANDLE_UPPER ) {
Point p = adjustThumbForHighValue();
thumbRect = new Rectangle( FlatRangeSliderUI.this.thumbRect );
restoreThumbForLowValue( p );
}
// move the mouse event coordinates to the center of the thumb
int tx = thumbRect.x + (thumbRect.width / 2) - x;
int ty = thumbRect.y + (thumbRect.height / 2) - y;
e.translatePoint( tx, ty );
// invoke super mousePressed() to start dragging thumb
super.mousePressed( e );
// move the mouse event coordinates back to current mouse location
e.translatePoint( -tx, -ty );
// invoke mouseDragged() to update thumb location
mouseDragged( e );
}
}
} }

View File

@@ -38,7 +38,3 @@ build script:
Otherwise download `flatlaf-swingx-<version>.jar` here: Otherwise download `flatlaf-swingx-<version>.jar` here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-swingx/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-swingx/_latestVersion) [![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf-swingx/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf-swingx/_latestVersion)
You also need `flatlaf-<version>.jar`, which you can download here:
[![Download](https://api.bintray.com/packages/jformdesigner/flatlaf/flatlaf/images/download.svg)](https://bintray.com/jformdesigner/flatlaf/flatlaf/_latestVersion)

View File

@@ -218,7 +218,7 @@ public class FlatDatePickerUI
FlatUIUtils.paintParentBackground( g, c ); FlatUIUtils.paintParentBackground( g, c );
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
FlatUIUtils.setRenderingHints( g2 ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g2 );
int width = c.getWidth(); int width = c.getWidth();
int height = c.getHeight(); int height = c.getHeight();
@@ -252,6 +252,8 @@ public class FlatDatePickerUI
g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2) ) ); g2.fill( new Rectangle2D.Float( lx, focusWidth, lw, height - 1 - (focusWidth * 2) ) );
paint( g, c ); paint( g, c );
FlatUIUtils.resetRenderingHints( g2, oldRenderingHints );
} }
//---- class DefaultEditor ------------------------------------------------ //---- class DefaultEditor ------------------------------------------------

View File

@@ -60,13 +60,6 @@ public class FlatHyperlinkUI
disabledText = null; disabledText = null;
} }
@Override
public void paint( Graphics g, JComponent c ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g );
super.paint( g, c );
}
@Override @Override
protected void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text ) { protected void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text ) {
FlatButtonUI.paintText( g, b, textRect, text, b.isEnabled() ? b.getForeground() : disabledText ); FlatButtonUI.paintText( g, b, textRect, text, b.isEnabled() ? b.getForeground() : disabledText );
@@ -78,8 +71,12 @@ public class FlatHyperlinkUI
private void paintUnderline( Graphics g, Rectangle rect ) { private void paintUnderline( Graphics g, Rectangle rect ) {
int descent = g.getFontMetrics().getDescent(); int descent = g.getFontMetrics().getDescent();
Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
((Graphics2D)g).fill( new Rectangle2D.Float( ((Graphics2D)g).fill( new Rectangle2D.Float(
rect.x, (rect.y + rect.height) - descent + UIScale.scale( 1f ), rect.x, (rect.y + rect.height) - descent + UIScale.scale( 1f ),
rect.width, UIScale.scale( 1f ) ) ); rect.width, UIScale.scale( 1f ) ) );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
} }

View File

@@ -146,7 +146,7 @@ public class FlatTaskPaneUI
if( color == null ) if( color == null )
return; return;
FlatUIUtils.setRenderingHints( (Graphics2D) g ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
g.setColor( color ); g.setColor( color );
@@ -155,6 +155,8 @@ public class FlatTaskPaneUI
path.append( new Rectangle2D.Float( x, y, width, height ), false ); path.append( new Rectangle2D.Float( x, y, width, height ), false );
path.append( new Rectangle2D.Float( x + lineWidth, y, width - (lineWidth * 2), height - lineWidth ), false ); path.append( new Rectangle2D.Float( x + lineWidth, y, width - (lineWidth * 2), height - lineWidth ), false );
((Graphics2D)g).fill( path ); ((Graphics2D)g).fill( path );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
@Override @Override
@@ -179,9 +181,11 @@ public class FlatTaskPaneUI
{ {
@Override @Override
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) { public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) {
FlatUIUtils.setRenderingHints( (Graphics2D) g ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g );
super.paintBorder( c, g, x, y, width, height ); super.paintBorder( c, g, x, y, width, height );
FlatUIUtils.resetRenderingHints( g, oldRenderingHints );
} }
@Override @Override

View File

@@ -26,6 +26,11 @@ JXHeader.background=@background
JXHeader.startBackground=#4c5052 JXHeader.startBackground=#4c5052
#---- HighlighterFactory ----
UIColorHighlighter.stripingBackground=lighten(@textComponentBackground,5%)
#---- Hyperlink ---- #---- Hyperlink ----
Hyperlink.linkColor=#589df6 Hyperlink.linkColor=#589df6

View File

@@ -26,6 +26,11 @@ JXHeader.background=@background
JXHeader.startBackground=#fff JXHeader.startBackground=#fff
#---- HighlighterFactory ----
UIColorHighlighter.stripingBackground=darken(@textComponentBackground,5%)
#---- Hyperlink ---- #---- Hyperlink ----
Hyperlink.linkColor=$Component.linkColor Hyperlink.linkColor=$Component.linkColor

View File

@@ -995,7 +995,7 @@ Table.focusCellHighlightBorder [lazy] 2,3,2,3 false com.formdev.flatlaf.ui.F
Table.focusSelectedCellHighlightBorder [lazy] 2,3,2,3 false com.formdev.flatlaf.ui.FlatTableCellBorder$Selected [UI] lineColor=#000000 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 Table.focusSelectedCellHighlightBorder [lazy] 2,3,2,3 false com.formdev.flatlaf.ui.FlatTableCellBorder$Selected [UI] lineColor=#000000 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000
Table.font [active] $defaultFont [UI] Table.font [active] $defaultFont [UI]
Table.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI] Table.foreground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
Table.gridColor #4c5152 javax.swing.plaf.ColorUIResource [UI] Table.gridColor #515657 javax.swing.plaf.ColorUIResource [UI]
Table.intercellSpacing 0,0 javax.swing.plaf.DimensionUIResource [UI] Table.intercellSpacing 0,0 javax.swing.plaf.DimensionUIResource [UI]
Table.rowHeight 20 Table.rowHeight 20
Table.scrollPaneBorder [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatBorder [UI] Table.scrollPaneBorder [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatBorder [UI]
@@ -1273,6 +1273,21 @@ Tree.wideSelection true
TreeUI com.formdev.flatlaf.ui.FlatTreeUI TreeUI com.formdev.flatlaf.ui.FlatTreeUI
#---- TristateCheckBox ----
TristateCheckBox.clearMixed.clientProperty length=2 [Ljava.lang.Object;
[0] JButton.selectedState
[1] null
TristateCheckBox.setMixed.clientProperty length=2 [Ljava.lang.Object;
[0] JButton.selectedState
[1] indeterminate
#---- UIColorHighlighter ----
UIColorHighlighter.stripingBackground #515657 javax.swing.plaf.ColorUIResource [UI]
#---- Viewport ---- #---- Viewport ----
Viewport.background #3c3f41 javax.swing.plaf.ColorUIResource [UI] Viewport.background #3c3f41 javax.swing.plaf.ColorUIResource [UI]

View File

@@ -1000,7 +1000,7 @@ Table.focusCellHighlightBorder [lazy] 2,3,2,3 false com.formdev.flatlaf.ui.F
Table.focusSelectedCellHighlightBorder [lazy] 2,3,2,3 false com.formdev.flatlaf.ui.FlatTableCellBorder$Selected [UI] lineColor=#000000 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000 Table.focusSelectedCellHighlightBorder [lazy] 2,3,2,3 false com.formdev.flatlaf.ui.FlatTableCellBorder$Selected [UI] lineColor=#000000 javax.swing.plaf.ColorUIResource [UI] lineThickness=1.000000
Table.font [active] $defaultFont [UI] Table.font [active] $defaultFont [UI]
Table.foreground #000000 javax.swing.plaf.ColorUIResource [UI] Table.foreground #000000 javax.swing.plaf.ColorUIResource [UI]
Table.gridColor #f7f7f7 javax.swing.plaf.ColorUIResource [UI] Table.gridColor #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
Table.intercellSpacing 0,0 javax.swing.plaf.DimensionUIResource [UI] Table.intercellSpacing 0,0 javax.swing.plaf.DimensionUIResource [UI]
Table.rowHeight 20 Table.rowHeight 20
Table.scrollPaneBorder [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatBorder [UI] Table.scrollPaneBorder [lazy] 1,1,1,1 false com.formdev.flatlaf.ui.FlatBorder [UI]
@@ -1278,6 +1278,21 @@ Tree.wideSelection true
TreeUI com.formdev.flatlaf.ui.FlatTreeUI TreeUI com.formdev.flatlaf.ui.FlatTreeUI
#---- TristateCheckBox ----
TristateCheckBox.clearMixed.clientProperty length=2 [Ljava.lang.Object;
[0] JButton.selectedState
[1] null
TristateCheckBox.setMixed.clientProperty length=2 [Ljava.lang.Object;
[0] JButton.selectedState
[1] indeterminate
#---- UIColorHighlighter ----
UIColorHighlighter.stripingBackground #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
#---- Viewport ---- #---- Viewport ----
Viewport.background #f2f2f2 javax.swing.plaf.ColorUIResource [UI] Viewport.background #f2f2f2 javax.swing.plaf.ColorUIResource [UI]

View File

@@ -1274,6 +1274,16 @@ Tree.wideSelection true
TreeUI com.formdev.flatlaf.ui.FlatTreeUI TreeUI com.formdev.flatlaf.ui.FlatTreeUI
#---- TristateCheckBox ----
TristateCheckBox.clearMixed.clientProperty length=2 [Ljava.lang.Object;
[0] JButton.selectedState
[1] null
TristateCheckBox.setMixed.clientProperty length=2 [Ljava.lang.Object;
[0] JButton.selectedState
[1] indeterminate
#---- Viewport ---- #---- Viewport ----
Viewport.background #ccffcc javax.swing.plaf.ColorUIResource [UI] Viewport.background #ccffcc javax.swing.plaf.ColorUIResource [UI]

View File

@@ -0,0 +1,254 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.testing;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import javax.swing.*;
import com.formdev.flatlaf.icons.FlatAnimatedIcon;
import com.formdev.flatlaf.util.AnimatedIcon;
import com.formdev.flatlaf.util.ColorFunctions;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatAnimatedIconTest
extends FlatTestPanel
{
public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatAnimatedIconTest" );
frame.showFrame( FlatAnimatedIconTest::new );
} );
}
FlatAnimatedIconTest() {
initComponents();
AnimatedRadioButtonIcon radioIcon = new AnimatedRadioButtonIcon();
radioButton1.setIcon( radioIcon );
radioButton2.setIcon( radioIcon );
radioButton3.setIcon( radioIcon );
checkBox1.setIcon( new AnimatedSwitchIcon() );
checkBox2.setIcon( new AnimatedMinimalTestIcon() );
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
radioButton1 = new JRadioButton();
radioButton2 = new JRadioButton();
radioButton3 = new JRadioButton();
checkBox1 = new JCheckBox();
checkBox2 = new JCheckBox();
durationLabel = new JLabel();
durationField = new JSpinner();
//======== this ========
setLayout(new MigLayout(
"insets dialog,hidemode 3",
// columns
"[]para" +
"[fill]",
// rows
"[]" +
"[]" +
"[]para" +
"[]" +
"[]" +
"[grow]" +
"[]"));
//---- radioButton1 ----
radioButton1.setText("radio 1");
radioButton1.setSelected(true);
add(radioButton1, "cell 0 0");
//---- radioButton2 ----
radioButton2.setText("radio 2");
add(radioButton2, "cell 0 1");
//---- radioButton3 ----
radioButton3.setText("radio 3");
add(radioButton3, "cell 0 2");
//---- checkBox1 ----
checkBox1.setText("switch");
add(checkBox1, "cell 0 3");
//---- checkBox2 ----
checkBox2.setText("minimal");
add(checkBox2, "cell 0 4");
//---- durationLabel ----
durationLabel.setText("Duration:");
add(durationLabel, "cell 0 6 2 1");
//---- durationField ----
durationField.setModel(new SpinnerNumberModel(200, 100, null, 50));
add(durationField, "cell 0 6 2 1");
//---- buttonGroup1 ----
ButtonGroup buttonGroup1 = new ButtonGroup();
buttonGroup1.add(radioButton1);
buttonGroup1.add(radioButton2);
buttonGroup1.add(radioButton3);
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JRadioButton radioButton1;
private JRadioButton radioButton2;
private JRadioButton radioButton3;
private JCheckBox checkBox1;
private JCheckBox checkBox2;
private JLabel durationLabel;
private JSpinner durationField;
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- class AnimatedRadioButtonIcon --------------------------------------
/**
* Experimental radio button icon that:
* - fades icon color from off to on color
* - animates size of center dot from zero to full size
*/
private class AnimatedRadioButtonIcon
extends FlatAnimatedIcon
{
private static final int SIZE = 16;
private static final int BORDER_SIZE = 2;
private static final int DOT_SIZE = 8;
private final Color offColor = Color.lightGray;
private final Color onColor = Color.red;
public AnimatedRadioButtonIcon() {
super( SIZE, SIZE, null );
}
@Override
public void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue ) {
Color color = ColorFunctions.mix( onColor, offColor, animatedValue );;
// border
g.setColor( color );
g.fillOval( 0, 0, SIZE, SIZE );
// background
g.setColor( c.getBackground() );
int bwh = SIZE - (BORDER_SIZE * 2);
g.fillOval( BORDER_SIZE, BORDER_SIZE, bwh, bwh );
// dot
float dotDiameter = DOT_SIZE * animatedValue;
float xy = (SIZE - dotDiameter) / 2f;
g.setColor( color );
((Graphics2D)g).fill( new Ellipse2D.Float( xy, xy, dotDiameter, dotDiameter ) );
}
@Override
public float getValue( Component c ) {
return ((JRadioButton)c).isSelected() ? 1 : 0;
}
@Override
public int getAnimationDuration() {
return (Integer) durationField.getValue();
}
}
//---- class AnimatedSwitchIcon -------------------------------------------
public class AnimatedSwitchIcon
extends FlatAnimatedIcon
{
private final Color offColor = Color.lightGray;
private final Color onColor = Color.red;
public AnimatedSwitchIcon() {
super( 28, 16, null );
}
@Override
public void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue ) {
Color color = ColorFunctions.mix( onColor, offColor, animatedValue );;
g.setColor( color );
g.fillRoundRect( x, y, width, height, height, height );
int thumbSize = height - 4;
int thumbX = x + 2 + Math.round( (width - 4 - thumbSize) * animatedValue );
int thumbY = y + 2;
g.setColor( Color.white );
g.fillOval( thumbX, thumbY, thumbSize, thumbSize );
}
@Override
public float getValue( Component c ) {
return ((AbstractButton)c).isSelected() ? 1 : 0;
}
@Override
public int getAnimationDuration() {
return (Integer) durationField.getValue();
}
}
//---- class AnimatedMinimalTestIcon --------------------------------------
/**
* Minimal example for an animated icon.
*/
private class AnimatedMinimalTestIcon
implements AnimatedIcon
{
@Override
public int getIconWidth() {
return 100;
}
@Override
public int getIconHeight() {
return 20;
}
@Override
public void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue ) {
int w = getIconWidth();
int h = getIconHeight();
g.setColor( Color.red );
g.drawRect( x, y, w - 1, h - 1 );
g.fillRect( x, y, Math.round( w * animatedValue ), h );
}
@Override
public float getValue( Component c ) {
return ((AbstractButton)c).isSelected() ? 1 : 0;
}
@Override
public int getAnimationDuration() {
return (Integer) durationField.getValue();
}
}
}

View File

@@ -0,0 +1,72 @@
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets dialog,hidemode 3"
"$columnConstraints": "[]para[fill]"
"$rowConstraints": "[][][]para[][][grow][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "radioButton1"
"text": "radio 1"
"$buttonGroup": new FormReference( "buttonGroup1" )
"selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "radioButton2"
"text": "radio 2"
"$buttonGroup": new FormReference( "buttonGroup1" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JRadioButton" ) {
name: "radioButton3"
"text": "radio 3"
"$buttonGroup": new FormReference( "buttonGroup1" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "checkBox1"
"text": "switch"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "checkBox2"
"text": "minimal"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "durationLabel"
"text": "Duration:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6 2 1"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "durationField"
"model": new javax.swing.SpinnerNumberModel {
minimum: 100
stepSize: 50
value: 200
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6 2 1"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 415, 350 )
} )
add( new FormNonVisual( "javax.swing.ButtonGroup" ) {
name: "buttonGroup1"
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 360 )
} )
}
}

View File

@@ -17,22 +17,37 @@
package com.formdev.flatlaf.testing; package com.formdev.flatlaf.testing;
import java.awt.Color; import java.awt.Color;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.io.File;
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.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.*; import javax.swing.table.*;
import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import com.formdev.flatlaf.icons.FlatMenuArrowIcon; import com.formdev.flatlaf.icons.FlatMenuArrowIcon;
import com.formdev.flatlaf.util.UIScale;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.JXTreeTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
import org.jdesktop.swingx.decorator.HighlighterFactory;
import org.jdesktop.swingx.decorator.PatternPredicate;
import org.jdesktop.swingx.decorator.ShadingColorHighlighter;
import org.jdesktop.swingx.treetable.FileSystemModel;
/** /**
* @author Karl Tauber * @author Karl Tauber
@@ -43,6 +58,7 @@ public class FlatComponents2Test
public static void main( String[] args ) { public static void main( String[] args ) {
SwingUtilities.invokeLater( () -> { SwingUtilities.invokeLater( () -> {
FlatTestFrame frame = FlatTestFrame.create( args, "FlatComponents2Test" ); FlatTestFrame frame = FlatTestFrame.create( args, "FlatComponents2Test" );
frame.useApplyComponentOrientation = true;
frame.showFrame( FlatComponents2Test::new ); frame.showFrame( FlatComponents2Test::new );
} ); } );
} }
@@ -50,6 +66,9 @@ public class FlatComponents2Test
private final TestListModel listModel; private final TestListModel listModel;
private final TestTreeModel treeModel; private final TestTreeModel treeModel;
private final TestTableModel tableModel; private final TestTableModel tableModel;
private final List<JTable> allTables = new ArrayList<>();
private final List<JTable> allTablesInclRowHeader = new ArrayList<>();
private JTable rowHeaderTable1;
FlatComponents2Test() { FlatComponents2Test() {
initComponents(); initComponents();
@@ -67,9 +86,35 @@ public class FlatComponents2Test
// table model // table model
tableModel = new TestTableModel( (Integer) tableRowCountSpinner.getValue() ); tableModel = new TestTableModel( (Integer) tableRowCountSpinner.getValue() );
table1.setModel( tableModel ); table1.setModel( tableModel );
xTable1.setModel( tableModel );
// table column editors // table column editors
TableColumnModel cm = table1.getColumnModel(); initTableEditors( table1 );
initTableEditors( xTable1 );
// JXTable
Highlighter simpleStriping = HighlighterFactory.createSimpleStriping();
PatternPredicate patternPredicate = new PatternPredicate( "^J", 2 );
ColorHighlighter magenta = new ColorHighlighter( patternPredicate, null, Color.MAGENTA, null, Color.MAGENTA );
ColorHighlighter rollover = new ColorHighlighter( HighlightPredicate.ROLLOVER_ROW, Color.cyan, null );
Highlighter shading = new ShadingColorHighlighter( new HighlightPredicate.ColumnHighlightPredicate( 1 ) );
xTable1.setHighlighters( simpleStriping, magenta, rollover, shading );
// JXTreeTable
xTreeTable1.setTreeTableModel( new FileSystemModel( new File( "." ) ) );
xTreeTable1.setHighlighters( simpleStriping, magenta, rollover, shading );
allTables.add( table1 );
allTables.add( xTable1 );
allTables.add( xTreeTable1 );
allTablesInclRowHeader.addAll( allTables );
expandTree( tree1 );
expandTree( tree2 );
}
private void initTableEditors( JTable table ) {
TableColumnModel cm = table.getColumnModel();
String[] months = new String[] { String[] months = new String[] {
"January", "February", "March", "April", "May", "June", "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December" "July", "August", "September", "October", "November", "December"
@@ -78,9 +123,6 @@ public class FlatComponents2Test
JComboBox<String> editableComboBox = new JComboBox<>( months ); JComboBox<String> editableComboBox = new JComboBox<>( months );
editableComboBox.setEditable( true ); editableComboBox.setEditable( true );
cm.getColumn(3).setCellEditor( new DefaultCellEditor( editableComboBox ) ); cm.getColumn(3).setCellEditor( new DefaultCellEditor( editableComboBox ) );
expandTree( tree1 );
expandTree( tree2 );
} }
private void expandTree( JTree tree ) { private void expandTree( JTree tree ) {
@@ -133,7 +175,8 @@ public class FlatComponents2Test
case "allColumns": autoResizeMode = JTable.AUTO_RESIZE_ALL_COLUMNS; break; case "allColumns": autoResizeMode = JTable.AUTO_RESIZE_ALL_COLUMNS; break;
} }
} }
table1.setAutoResizeMode( autoResizeMode ); for( JTable table : allTables )
table.setAutoResizeMode( autoResizeMode );
} }
private void dndChanged() { private void dndChanged() {
@@ -143,11 +186,15 @@ public class FlatComponents2Test
tree1.setDragEnabled( dnd ); tree1.setDragEnabled( dnd );
tree2.setDragEnabled( dnd ); tree2.setDragEnabled( dnd );
table1.setDragEnabled( dnd ); table1.setDragEnabled( dnd );
xTable1.setDragEnabled( dnd );
xTreeTable1.setDragEnabled( dnd );
DropMode dropMode = dnd ? DropMode.ON_OR_INSERT : DropMode.USE_SELECTION; DropMode dropMode = dnd ? DropMode.ON_OR_INSERT : DropMode.USE_SELECTION;
list1.setDropMode( dropMode ); list1.setDropMode( dropMode );
tree1.setDropMode( dropMode ); tree1.setDropMode( dropMode );
table1.setDropMode( dropMode ); table1.setDropMode( dropMode );
xTable1.setDropMode( dropMode );
xTreeTable1.setDropMode( dropMode );
String key = "FlatLaf.oldTransferHandler"; String key = "FlatLaf.oldTransferHandler";
if( dnd ) { if( dnd ) {
@@ -158,48 +205,114 @@ public class FlatComponents2Test
tree1.setTransferHandler( new DummyTransferHandler() ); tree1.setTransferHandler( new DummyTransferHandler() );
table1.putClientProperty( key, table1.getTransferHandler() ); table1.putClientProperty( key, table1.getTransferHandler() );
xTable1.putClientProperty( key, xTable1.getTransferHandler() );
xTreeTable1.putClientProperty( key, xTreeTable1.getTransferHandler() );
table1.setTransferHandler( new DummyTransferHandler() ); table1.setTransferHandler( new DummyTransferHandler() );
xTable1.setTransferHandler( new DummyTransferHandler() );
xTreeTable1.setTransferHandler( new DummyTransferHandler() );
} else { } else {
list1.setTransferHandler( (TransferHandler) list1.getClientProperty( key ) ); list1.setTransferHandler( (TransferHandler) list1.getClientProperty( key ) );
tree1.setTransferHandler( (TransferHandler) tree1.getClientProperty( key ) ); tree1.setTransferHandler( (TransferHandler) tree1.getClientProperty( key ) );
table1.setTransferHandler( (TransferHandler) table1.getClientProperty( key ) ); table1.setTransferHandler( (TransferHandler) table1.getClientProperty( key ) );
xTable1.setTransferHandler( (TransferHandler) xTable1.getClientProperty( key ) );
xTreeTable1.setTransferHandler( (TransferHandler) xTreeTable1.getClientProperty( key ) );
} }
} }
private void tableHeaderButtonChanged() { private void tableHeaderButtonChanged() {
tableHeaderButtonChanged( table1ScrollPane );
tableHeaderButtonChanged( xTable1ScrollPane );
tableHeaderButtonChanged( xTreeTable1ScrollPane );
}
private void tableHeaderButtonChanged( JScrollPane scrollPane ) {
boolean show = tableHeaderButtonCheckBox.isSelected(); boolean show = tableHeaderButtonCheckBox.isSelected();
JButton button = null; JButton button = null;
if( show ) { if( show ) {
button = new JButton( new FlatMenuArrowIcon() ); button = new JButton( new FlatMenuArrowIcon() );
button.applyComponentOrientation( getComponentOrientation() );
button.addActionListener( e -> { button.addActionListener( e -> {
JOptionPane.showMessageDialog( this, "hello" ); JOptionPane.showMessageDialog( this, "hello" );
} ); } );
} }
scrollPane5.setCorner( JScrollPane.UPPER_TRAILING_CORNER, button ); scrollPane.setCorner( JScrollPane.UPPER_TRAILING_CORNER, button );
} }
private void rowSelectionChanged() { private void rowSelectionChanged() {
table1.setRowSelectionAllowed( rowSelectionCheckBox.isSelected() ); for( JTable table : allTables )
table.setRowSelectionAllowed( rowSelectionCheckBox.isSelected() );
} }
private void columnSelectionChanged() { private void columnSelectionChanged() {
table1.setColumnSelectionAllowed( columnSelectionCheckBox.isSelected() ); for( JTable table : allTables )
table.setColumnSelectionAllowed( columnSelectionCheckBox.isSelected() );
} }
private void showHorizontalLinesChanged() { private void showHorizontalLinesChanged() {
table1.setShowHorizontalLines( showHorizontalLinesCheckBox.isSelected() ); for( JTable table : allTablesInclRowHeader )
table.setShowHorizontalLines( showHorizontalLinesCheckBox.isSelected() );
} }
private void showVerticalLinesChanged() { private void showVerticalLinesChanged() {
table1.setShowVerticalLines( showVerticalLinesCheckBox.isSelected() ); for( JTable table : allTablesInclRowHeader )
table.setShowVerticalLines( showVerticalLinesCheckBox.isSelected() );
} }
private void intercellSpacingChanged() { private void intercellSpacingChanged() {
table1.setIntercellSpacing( intercellSpacingCheckBox.isSelected() ? new Dimension( 1, 1 ) : new Dimension() ); for( JTable table : allTablesInclRowHeader )
table.setIntercellSpacing( intercellSpacingCheckBox.isSelected() ? new Dimension( 1, 1 ) : new Dimension() );
} }
private void redGridColorChanged() { private void redGridColorChanged() {
table1.setGridColor( redGridColorCheckBox.isSelected() ? Color.red : UIManager.getColor( "Table.gridColor" ) ); for( JTable table : allTablesInclRowHeader )
table.setGridColor( redGridColorCheckBox.isSelected() ? Color.red : UIManager.getColor( "Table.gridColor" ) );
}
private void rowHeaderChanged() {
if( rowHeaderCheckBox.isSelected() ) {
TestTableRowHeaderModel rowHeaderModel = new TestTableRowHeaderModel( tableModel );
rowHeaderTable1 = new JTable( rowHeaderModel );
rowHeaderTable1.setPreferredScrollableViewportSize( UIScale.scale( new Dimension( 50, 50 ) ) );
rowHeaderTable1.setSelectionModel( table1.getSelectionModel() );
DefaultTableCellRenderer rowHeaderRenderer = new DefaultTableCellRenderer();
rowHeaderRenderer.setHorizontalAlignment( JLabel.CENTER );
rowHeaderTable1.setDefaultRenderer( Object.class, rowHeaderRenderer );
table1ScrollPane.setRowHeaderView( rowHeaderTable1 );
JViewport headerViewport = new JViewport();
headerViewport.setView( rowHeaderTable1.getTableHeader() );
table1ScrollPane.setCorner( ScrollPaneConstants.UPPER_LEADING_CORNER, headerViewport );
table1ScrollPane.applyComponentOrientation( getComponentOrientation() );
allTablesInclRowHeader.add( rowHeaderTable1 );
showHorizontalLinesChanged();
showVerticalLinesChanged();
intercellSpacingChanged();
redGridColorChanged();
} else {
table1ScrollPane.setRowHeader( null );
table1ScrollPane.setCorner( ScrollPaneConstants.UPPER_LEADING_CORNER, null );
allTablesInclRowHeader.remove( rowHeaderTable1 );
((TestTableRowHeaderModel)rowHeaderTable1.getModel()).dispose();
rowHeaderTable1 = null;
}
}
@Override
public void applyComponentOrientation( ComponentOrientation o ) {
super.applyComponentOrientation( o );
// swap upper right and left corners (other corners are not used in this app)
Component leftCorner = table1ScrollPane.getCorner( ScrollPaneConstants.UPPER_LEFT_CORNER );
Component rightCorner = table1ScrollPane.getCorner( ScrollPaneConstants.UPPER_RIGHT_CORNER );
table1ScrollPane.setCorner( ScrollPaneConstants.UPPER_LEFT_CORNER, null );
table1ScrollPane.setCorner( ScrollPaneConstants.UPPER_RIGHT_CORNER, null );
table1ScrollPane.setCorner( ScrollPaneConstants.UPPER_LEFT_CORNER, rightCorner );
table1ScrollPane.setCorner( ScrollPaneConstants.UPPER_RIGHT_CORNER, leftCorner );
} }
@Override @Override
@@ -218,31 +331,35 @@ public class FlatComponents2Test
JLabel textFieldLabel = new JLabel(); JLabel textFieldLabel = new JLabel();
JTextField textField1 = new JTextField(); JTextField textField1 = new JTextField();
JTextField textField2 = new JTextField(); JTextField textField2 = new JTextField();
JTextField textField3 = new JTextField();
JTextField textField4 = new JTextField();
JPanel panel1 = new JPanel();
JLabel listLabel = new JLabel(); JLabel listLabel = new JLabel();
JLabel listRowCountLabel = new JLabel();
listRowCountSpinner = new JSpinner();
JScrollPane scrollPane1 = new JScrollPane(); JScrollPane scrollPane1 = new JScrollPane();
list1 = new JList<>(); list1 = new JList<>();
JScrollPane scrollPane2 = new JScrollPane(); JScrollPane scrollPane2 = new JScrollPane();
list2 = new JList<>(); list2 = new JList<>();
JPanel listOptionsPanel = new JPanel(); JPanel panel2 = new JPanel();
JLabel listRowCountLabel = new JLabel();
listRowCountSpinner = new JSpinner();
JLabel treeLabel = new JLabel(); JLabel treeLabel = new JLabel();
JLabel treeRowCountLabel = new JLabel();
treeRowCountSpinner = new JSpinner();
JScrollPane scrollPane3 = new JScrollPane(); JScrollPane scrollPane3 = new JScrollPane();
tree1 = new JTree(); tree1 = new JTree();
JScrollPane scrollPane4 = new JScrollPane(); JScrollPane scrollPane4 = new JScrollPane();
tree2 = new JTree(); tree2 = new JTree();
JPanel treeOptionsPanel = new JPanel(); JPanel panel3 = new JPanel();
JLabel treeRowCountLabel = new JLabel();
treeRowCountSpinner = new JSpinner();
JLabel tableLabel = new JLabel(); JLabel tableLabel = new JLabel();
scrollPane5 = new JScrollPane();
table1 = new JTable();
JPanel tableOptionsPanel = new JPanel();
JLabel tableRowCountLabel = new JLabel(); JLabel tableRowCountLabel = new JLabel();
tableRowCountSpinner = new JSpinner(); tableRowCountSpinner = new JSpinner();
table1ScrollPane = new JScrollPane();
table1 = new JTable();
JPanel tableOptionsPanel = new JPanel();
JLabel autoResizeModeLabel = new JLabel(); JLabel autoResizeModeLabel = new JLabel();
autoResizeModeField = new JComboBox<>(); autoResizeModeField = new JComboBox<>();
showHorizontalLinesCheckBox = new JCheckBox(); showHorizontalLinesCheckBox = new JCheckBox();
rowHeaderCheckBox = new JCheckBox();
showVerticalLinesCheckBox = new JCheckBox(); showVerticalLinesCheckBox = new JCheckBox();
intercellSpacingCheckBox = new JCheckBox(); intercellSpacingCheckBox = new JCheckBox();
redGridColorCheckBox = new JCheckBox(); redGridColorCheckBox = new JCheckBox();
@@ -250,15 +367,23 @@ public class FlatComponents2Test
columnSelectionCheckBox = new JCheckBox(); columnSelectionCheckBox = new JCheckBox();
dndCheckBox = new JCheckBox(); dndCheckBox = new JCheckBox();
tableHeaderButtonCheckBox = new JCheckBox(); tableHeaderButtonCheckBox = new JCheckBox();
JLabel label1 = new JLabel();
xTable1ScrollPane = new JScrollPane();
xTable1 = new JXTable();
JLabel label2 = new JLabel();
xTreeTable1ScrollPane = new JScrollPane();
xTreeTable1 = new JXTreeTable();
//======== this ======== //======== this ========
setLayout(new MigLayout( setLayout(new MigLayout(
"ltr,insets dialog,hidemode 3", "ltr,insets dialog,hidemode 3",
// columns // columns
"[]" + "[]" +
"[200,fill]" + "[200,grow,sizegroup 1,fill]" +
"[200,fill]" + "[200,grow,sizegroup 1,fill]" +
"[fill]", "[fill]" +
"[200,grow,sizegroup 1,fill]" +
"[200,grow,sizegroup 1,fill]",
// rows // rows
"[]" + "[]" +
"[150,grow,sizegroup 1,fill]" + "[150,grow,sizegroup 1,fill]" +
@@ -278,9 +403,41 @@ public class FlatComponents2Test
textField2.setEnabled(false); textField2.setEnabled(false);
add(textField2, "cell 2 0,growx"); add(textField2, "cell 2 0,growx");
//---- listLabel ---- //---- textField3 ----
listLabel.setText("JList:"); textField3.setText("editable");
add(listLabel, "cell 0 1,aligny top,growy 0"); add(textField3, "cell 4 0,growx");
//---- textField4 ----
textField4.setText("disabled");
textField4.setEnabled(false);
add(textField4, "cell 5 0,growx");
//======== panel1 ========
{
panel1.setLayout(new MigLayout(
"ltr,insets 0,hidemode 3",
// columns
"[fill]",
// rows
"[]" +
"[grow]" +
"[]" +
"[]"));
//---- listLabel ----
listLabel.setText("JList:");
panel1.add(listLabel, "cell 0 0,aligny top,growy 0");
//---- listRowCountLabel ----
listRowCountLabel.setText("Row count:");
panel1.add(listRowCountLabel, "cell 0 2");
//---- listRowCountSpinner ----
listRowCountSpinner.setModel(new SpinnerNumberModel(20, 0, null, 10));
listRowCountSpinner.addChangeListener(e -> listRowCountChanged());
panel1.add(listRowCountSpinner, "cell 0 3");
}
add(panel1, "cell 0 1");
//======== scrollPane1 ======== //======== scrollPane1 ========
{ {
@@ -297,30 +454,32 @@ public class FlatComponents2Test
} }
add(scrollPane2, "cell 2 1"); add(scrollPane2, "cell 2 1");
//======== listOptionsPanel ======== //======== panel2 ========
{ {
listOptionsPanel.setLayout(new MigLayout( panel2.setLayout(new MigLayout(
"hidemode 3", "insets 0,hidemode 3",
// columns // columns
"[fill]" + "[fill]",
"[90,fill]",
// rows // rows
"[]" +
"[grow]" +
"[]" +
"[]")); "[]"));
//---- listRowCountLabel ---- //---- treeLabel ----
listRowCountLabel.setText("Row count:"); treeLabel.setText("JTree:");
listOptionsPanel.add(listRowCountLabel, "cell 0 0"); panel2.add(treeLabel, "cell 0 0,aligny top,growy 0");
//---- listRowCountSpinner ---- //---- treeRowCountLabel ----
listRowCountSpinner.setModel(new SpinnerNumberModel(20, 0, null, 10)); treeRowCountLabel.setText("Row count:");
listRowCountSpinner.addChangeListener(e -> listRowCountChanged()); panel2.add(treeRowCountLabel, "cell 0 2");
listOptionsPanel.add(listRowCountSpinner, "cell 1 0");
//---- treeRowCountSpinner ----
treeRowCountSpinner.setModel(new SpinnerNumberModel(20, 20, null, 20));
treeRowCountSpinner.addChangeListener(e -> treeRowCountChanged());
panel2.add(treeRowCountSpinner, "cell 0 3");
} }
add(listOptionsPanel, "cell 3 1"); add(panel2, "cell 3 1");
//---- treeLabel ----
treeLabel.setText("JTree:");
add(treeLabel, "cell 0 2,aligny top,growy 0");
//======== scrollPane3 ======== //======== scrollPane3 ========
{ {
@@ -330,7 +489,7 @@ public class FlatComponents2Test
tree1.setEditable(true); tree1.setEditable(true);
scrollPane3.setViewportView(tree1); scrollPane3.setViewportView(tree1);
} }
add(scrollPane3, "cell 1 2"); add(scrollPane3, "cell 4 1");
//======== scrollPane4 ======== //======== scrollPane4 ========
{ {
@@ -339,41 +498,43 @@ public class FlatComponents2Test
tree2.setEnabled(false); tree2.setEnabled(false);
scrollPane4.setViewportView(tree2); scrollPane4.setViewportView(tree2);
} }
add(scrollPane4, "cell 2 2"); add(scrollPane4, "cell 5 1");
//======== treeOptionsPanel ======== //======== panel3 ========
{ {
treeOptionsPanel.setLayout(new MigLayout( panel3.setLayout(new MigLayout(
"hidemode 3", "insets 0,hidemode 3",
// columns // columns
"[fill]" + "[fill]",
"[90,fill]",
// rows // rows
"[]" +
"[grow]" +
"[]" +
"[]")); "[]"));
//---- treeRowCountLabel ---- //---- tableLabel ----
treeRowCountLabel.setText("Row count:"); tableLabel.setText("JTable:");
treeOptionsPanel.add(treeRowCountLabel, "cell 0 0"); panel3.add(tableLabel, "cell 0 0");
//---- treeRowCountSpinner ---- //---- tableRowCountLabel ----
treeRowCountSpinner.setModel(new SpinnerNumberModel(20, 20, null, 20)); tableRowCountLabel.setText("Row count:");
treeRowCountSpinner.addChangeListener(e -> treeRowCountChanged()); panel3.add(tableRowCountLabel, "cell 0 2");
treeOptionsPanel.add(treeRowCountSpinner, "cell 1 0");
//---- tableRowCountSpinner ----
tableRowCountSpinner.setModel(new SpinnerNumberModel(20, 0, null, 5));
tableRowCountSpinner.addChangeListener(e -> tableRowCountChanged());
panel3.add(tableRowCountSpinner, "cell 0 3");
} }
add(treeOptionsPanel, "cell 3 2"); add(panel3, "cell 0 2");
//---- tableLabel ---- //======== table1ScrollPane ========
tableLabel.setText("JTable:");
add(tableLabel, "cell 0 3,aligny top,growy 0");
//======== scrollPane5 ========
{ {
//---- table1 ---- //---- table1 ----
table1.setAutoCreateRowSorter(true); table1.setAutoCreateRowSorter(true);
scrollPane5.setViewportView(table1); table1ScrollPane.setViewportView(table1);
} }
add(scrollPane5, "cell 1 3 2 1,width 300"); add(table1ScrollPane, "cell 1 2 2 1,width 300");
//======== tableOptionsPanel ======== //======== tableOptionsPanel ========
{ {
@@ -381,10 +542,9 @@ public class FlatComponents2Test
"hidemode 3", "hidemode 3",
// columns // columns
"[]" + "[]" +
"[90,fill]", "[]",
// rows // rows
"[]" + "[]" +
"[]" +
"[]0" + "[]0" +
"[]0" + "[]0" +
"[]0" + "[]0" +
@@ -394,18 +554,9 @@ public class FlatComponents2Test
"[]0" + "[]0" +
"[]")); "[]"));
//---- tableRowCountLabel ----
tableRowCountLabel.setText("Row count:");
tableOptionsPanel.add(tableRowCountLabel, "cell 0 0");
//---- tableRowCountSpinner ----
tableRowCountSpinner.setModel(new SpinnerNumberModel(20, 0, null, 10));
tableRowCountSpinner.addChangeListener(e -> tableRowCountChanged());
tableOptionsPanel.add(tableRowCountSpinner, "cell 1 0");
//---- autoResizeModeLabel ---- //---- autoResizeModeLabel ----
autoResizeModeLabel.setText("Auto resize mode:"); autoResizeModeLabel.setText("Auto resize mode:");
tableOptionsPanel.add(autoResizeModeLabel, "cell 0 1"); tableOptionsPanel.add(autoResizeModeLabel, "cell 0 0");
//---- autoResizeModeField ---- //---- autoResizeModeField ----
autoResizeModeField.setModel(new DefaultComboBoxModel<>(new String[] { autoResizeModeField.setModel(new DefaultComboBoxModel<>(new String[] {
@@ -417,66 +568,92 @@ public class FlatComponents2Test
})); }));
autoResizeModeField.setSelectedIndex(2); autoResizeModeField.setSelectedIndex(2);
autoResizeModeField.addActionListener(e -> autoResizeModeChanged()); autoResizeModeField.addActionListener(e -> autoResizeModeChanged());
tableOptionsPanel.add(autoResizeModeField, "cell 1 1"); tableOptionsPanel.add(autoResizeModeField, "cell 1 0");
//---- showHorizontalLinesCheckBox ---- //---- showHorizontalLinesCheckBox ----
showHorizontalLinesCheckBox.setText("show horizontal lines"); showHorizontalLinesCheckBox.setText("show horizontal lines");
showHorizontalLinesCheckBox.addActionListener(e -> showHorizontalLinesChanged()); showHorizontalLinesCheckBox.addActionListener(e -> showHorizontalLinesChanged());
tableOptionsPanel.add(showHorizontalLinesCheckBox, "cell 0 2 2 1"); tableOptionsPanel.add(showHorizontalLinesCheckBox, "cell 0 1");
//---- rowHeaderCheckBox ----
rowHeaderCheckBox.setText("row header");
rowHeaderCheckBox.addActionListener(e -> rowHeaderChanged());
tableOptionsPanel.add(rowHeaderCheckBox, "cell 1 1");
//---- showVerticalLinesCheckBox ---- //---- showVerticalLinesCheckBox ----
showVerticalLinesCheckBox.setText("show vertical lines"); showVerticalLinesCheckBox.setText("show vertical lines");
showVerticalLinesCheckBox.addActionListener(e -> showVerticalLinesChanged()); showVerticalLinesCheckBox.addActionListener(e -> showVerticalLinesChanged());
tableOptionsPanel.add(showVerticalLinesCheckBox, "cell 0 3 2 1"); tableOptionsPanel.add(showVerticalLinesCheckBox, "cell 0 2");
//---- intercellSpacingCheckBox ---- //---- intercellSpacingCheckBox ----
intercellSpacingCheckBox.setText("intercell spacing"); intercellSpacingCheckBox.setText("intercell spacing");
intercellSpacingCheckBox.addActionListener(e -> intercellSpacingChanged()); intercellSpacingCheckBox.addActionListener(e -> intercellSpacingChanged());
tableOptionsPanel.add(intercellSpacingCheckBox, "cell 0 4 2 1"); tableOptionsPanel.add(intercellSpacingCheckBox, "cell 0 3");
//---- redGridColorCheckBox ---- //---- redGridColorCheckBox ----
redGridColorCheckBox.setText("red grid color"); redGridColorCheckBox.setText("red grid color");
redGridColorCheckBox.addActionListener(e -> redGridColorChanged()); redGridColorCheckBox.addActionListener(e -> redGridColorChanged());
tableOptionsPanel.add(redGridColorCheckBox, "cell 0 5 2 1"); tableOptionsPanel.add(redGridColorCheckBox, "cell 0 4");
//---- rowSelectionCheckBox ---- //---- rowSelectionCheckBox ----
rowSelectionCheckBox.setText("row selection"); rowSelectionCheckBox.setText("row selection");
rowSelectionCheckBox.setSelected(true); rowSelectionCheckBox.setSelected(true);
rowSelectionCheckBox.addActionListener(e -> rowSelectionChanged()); rowSelectionCheckBox.addActionListener(e -> rowSelectionChanged());
tableOptionsPanel.add(rowSelectionCheckBox, "cell 0 6 2 1"); tableOptionsPanel.add(rowSelectionCheckBox, "cell 0 5");
//---- columnSelectionCheckBox ---- //---- columnSelectionCheckBox ----
columnSelectionCheckBox.setText("column selection"); columnSelectionCheckBox.setText("column selection");
columnSelectionCheckBox.addActionListener(e -> columnSelectionChanged()); columnSelectionCheckBox.addActionListener(e -> columnSelectionChanged());
tableOptionsPanel.add(columnSelectionCheckBox, "cell 0 7 2 1"); tableOptionsPanel.add(columnSelectionCheckBox, "cell 0 6");
//---- dndCheckBox ---- //---- dndCheckBox ----
dndCheckBox.setText("enable drag and drop"); dndCheckBox.setText("enable drag and drop");
dndCheckBox.setMnemonic('D'); dndCheckBox.setMnemonic('D');
dndCheckBox.addActionListener(e -> dndChanged()); dndCheckBox.addActionListener(e -> dndChanged());
tableOptionsPanel.add(dndCheckBox, "cell 0 8 2 1"); tableOptionsPanel.add(dndCheckBox, "cell 0 7");
//---- tableHeaderButtonCheckBox ---- //---- tableHeaderButtonCheckBox ----
tableHeaderButtonCheckBox.setText("show button in table header"); tableHeaderButtonCheckBox.setText("show button in table header");
tableHeaderButtonCheckBox.addActionListener(e -> tableHeaderButtonChanged()); tableHeaderButtonCheckBox.addActionListener(e -> tableHeaderButtonChanged());
tableOptionsPanel.add(tableHeaderButtonCheckBox, "cell 0 9 2 1"); tableOptionsPanel.add(tableHeaderButtonCheckBox, "cell 0 8 2 1");
} }
add(tableOptionsPanel, "cell 3 3"); add(tableOptionsPanel, "cell 4 2 2 1");
//---- label1 ----
label1.setText("JXTable:");
add(label1, "cell 0 3,aligny top,growy 0");
//======== xTable1ScrollPane ========
{
xTable1ScrollPane.setViewportView(xTable1);
}
add(xTable1ScrollPane, "cell 1 3 2 1");
//---- label2 ----
label2.setText("JXTreeTable:");
add(label2, "cell 3 3,aligny top,growy 0");
//======== xTreeTable1ScrollPane ========
{
xTreeTable1ScrollPane.setViewportView(xTreeTable1);
}
add(xTreeTable1ScrollPane, "cell 4 3 2 1");
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
} }
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JSpinner listRowCountSpinner;
private JList<String> list1; private JList<String> list1;
private JList<String> list2; private JList<String> list2;
private JSpinner listRowCountSpinner; private JSpinner treeRowCountSpinner;
private JTree tree1; private JTree tree1;
private JTree tree2; private JTree tree2;
private JSpinner treeRowCountSpinner;
private JScrollPane scrollPane5;
private JTable table1;
private JSpinner tableRowCountSpinner; private JSpinner tableRowCountSpinner;
private JScrollPane table1ScrollPane;
private JTable table1;
private JComboBox<String> autoResizeModeField; private JComboBox<String> autoResizeModeField;
private JCheckBox showHorizontalLinesCheckBox; private JCheckBox showHorizontalLinesCheckBox;
private JCheckBox rowHeaderCheckBox;
private JCheckBox showVerticalLinesCheckBox; private JCheckBox showVerticalLinesCheckBox;
private JCheckBox intercellSpacingCheckBox; private JCheckBox intercellSpacingCheckBox;
private JCheckBox redGridColorCheckBox; private JCheckBox redGridColorCheckBox;
@@ -484,6 +661,10 @@ public class FlatComponents2Test
private JCheckBox columnSelectionCheckBox; private JCheckBox columnSelectionCheckBox;
private JCheckBox dndCheckBox; private JCheckBox dndCheckBox;
private JCheckBox tableHeaderButtonCheckBox; private JCheckBox tableHeaderButtonCheckBox;
private JScrollPane xTable1ScrollPane;
private JXTable xTable1;
private JScrollPane xTreeTable1ScrollPane;
private JXTreeTable xTreeTable1;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
private final String[] randomRowStrings = new String[1000]; private final String[] randomRowStrings = new String[1000];
@@ -770,4 +951,56 @@ public class FlatComponents2Test
fireTableCellUpdated( rowIndex, columnIndex ); fireTableCellUpdated( rowIndex, columnIndex );
} }
} }
//---- TestTableRowHeaderModel --------------------------------------------
private class TestTableRowHeaderModel
extends AbstractTableModel
implements TableModelListener
{
private final TableModel model;
TestTableRowHeaderModel( TableModel model ) {
this.model = model;
model.addTableModelListener( this );
}
void dispose() {
model.removeTableModelListener( this );
}
@Override
public int getRowCount() {
return model.getRowCount();
}
@Override
public int getColumnCount() {
return 1;
}
@Override
public String getColumnName( int columnIndex ) {
return "Row #";
}
@Override
public Object getValueAt( int rowIndex, int columnIndex ) {
return rowIndex + 1;
}
@Override
public void tableChanged( TableModelEvent e ) {
switch( e.getType() ) {
case TableModelEvent.INSERT:
fireTableRowsInserted( e.getFirstRow(), e.getLastRow() );
break;
case TableModelEvent.DELETE:
fireTableRowsDeleted( e.getFirstRow(), e.getLastRow() );
break;
}
}
}
} }

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8" JFDML JFormDesigner: "7.0.3.0.337" Java: "15" encoding: "UTF-8"
new FormModel { new FormModel {
contentType: "form/swing" contentType: "form/swing"
@@ -8,7 +8,7 @@ new FormModel {
} }
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3" "$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[][200,fill][200,fill][fill]" "$columnConstraints": "[][200,grow,sizegroup 1,fill][200,grow,sizegroup 1,fill][fill][200,grow,sizegroup 1,fill][200,grow,sizegroup 1,fill]"
"$rowConstraints": "[][150,grow,sizegroup 1,fill][150,grow,sizegroup 1,fill][150,grow,sizegroup 1,fill]" "$rowConstraints": "[][150,grow,sizegroup 1,fill][150,grow,sizegroup 1,fill][150,grow,sizegroup 1,fill]"
} ) { } ) {
name: "this" name: "this"
@@ -31,11 +31,53 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0,growx" "value": "cell 2 0,growx"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JTextField" ) {
name: "listLabel" name: "textField3"
"text": "JList:" "text": "editable"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1,aligny top,growy 0" "value": "cell 4 0,growx"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField4"
"text": "disabled"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 0,growx"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[fill]"
"$rowConstraints": "[][grow][][]"
"$layoutConstraints": "ltr,insets 0,hidemode 3"
} ) {
name: "panel1"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "listLabel"
"text": "JList:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "listRowCountLabel"
"text": "Row count:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "listRowCountSpinner"
"model": new javax.swing.SpinnerNumberModel {
minimum: 0
stepSize: 10
value: 20
}
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "listRowCountChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} ) } )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane1" name: "scrollPane1"
@@ -63,76 +105,22 @@ new FormModel {
"value": "cell 2 1" "value": "cell 2 1"
} ) } )
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": "hidemode 3" "$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[fill][90,fill]" "$columnConstraints": "[fill]"
"$rowConstraints": "[]" "$rowConstraints": "[][grow][][]"
} ) { } ) {
name: "listOptionsPanel" name: "panel2"
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "listRowCountLabel" name: "treeLabel"
"text": "Row count:" "text": "JTree:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0" "value": "cell 0 0,aligny top,growy 0"
} ) } )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "listRowCountSpinner"
"model": &SpinnerNumberModel0 new javax.swing.SpinnerNumberModel {
minimum: 0
stepSize: 10
value: 20
}
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "listRowCountChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "treeLabel"
"text": "JTree:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2,aligny top,growy 0"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane3"
add( new FormComponent( "javax.swing.JTree" ) {
name: "tree1"
"showsRootHandles": true
"editable": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane4"
add( new FormComponent( "javax.swing.JTree" ) {
name: "tree2"
"enabled": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "hidemode 3"
"$columnConstraints": "[fill][90,fill]"
"$rowConstraints": "[]"
} ) {
name: "treeOptionsPanel"
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "treeRowCountLabel" name: "treeRowCountLabel"
"text": "Row count:" "text": "Row count:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0" "value": "cell 0 2"
} ) } )
add( new FormComponent( "javax.swing.JSpinner" ) { add( new FormComponent( "javax.swing.JSpinner" ) {
name: "treeRowCountSpinner" name: "treeRowCountSpinner"
@@ -146,19 +134,73 @@ new FormModel {
} }
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "treeRowCountChanged", false ) ) addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "treeRowCountChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0" "value": "cell 0 3"
} ) } )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 2" "value": "cell 3 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "tableLabel"
"text": "JTable:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3,aligny top,growy 0"
} ) } )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane5" name: "scrollPane3"
add( new FormComponent( "javax.swing.JTree" ) {
name: "tree1"
"showsRootHandles": true
"editable": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 1"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane4"
add( new FormComponent( "javax.swing.JTree" ) {
name: "tree2"
"enabled": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 1"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[fill]"
"$rowConstraints": "[][grow][][]"
} ) {
name: "panel3"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "tableLabel"
"text": "JTable:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "tableRowCountLabel"
"text": "Row count:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "tableRowCountSpinner"
"model": new javax.swing.SpinnerNumberModel {
minimum: 0
stepSize: 5
value: 20
}
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "tableRowCountChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "table1ScrollPane"
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
} }
@@ -170,35 +212,19 @@ new FormModel {
} }
} ) } )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3 2 1,width 300" "value": "cell 1 2 2 1,width 300"
} ) } )
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": "hidemode 3" "$layoutConstraints": "hidemode 3"
"$columnConstraints": "[][90,fill]" "$columnConstraints": "[][]"
"$rowConstraints": "[][][]0[]0[]0[]0[]0[]0[]0[]" "$rowConstraints": "[][]0[]0[]0[]0[]0[]0[]0[]"
} ) { } ) {
name: "tableOptionsPanel" name: "tableOptionsPanel"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "tableRowCountLabel"
"text": "Row count:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "tableRowCountSpinner"
"model": #SpinnerNumberModel0
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "tableRowCountChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "autoResizeModeLabel" name: "autoResizeModeLabel"
"text": "Auto resize mode:" "text": "Auto resize mode:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1" "value": "cell 0 0"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "javax.swing.JComboBox" ) {
name: "autoResizeModeField" name: "autoResizeModeField"
@@ -217,7 +243,7 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "autoResizeModeChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "autoResizeModeChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1" "value": "cell 1 0"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "showHorizontalLinesCheckBox" name: "showHorizontalLinesCheckBox"
@@ -227,7 +253,17 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showHorizontalLinesChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showHorizontalLinesChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2 2 1" "value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "rowHeaderCheckBox"
"text": "row header"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "rowHeaderChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "showVerticalLinesCheckBox" name: "showVerticalLinesCheckBox"
@@ -237,7 +273,7 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showVerticalLinesChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showVerticalLinesChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3 2 1" "value": "cell 0 2"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "intercellSpacingCheckBox" name: "intercellSpacingCheckBox"
@@ -247,7 +283,7 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "intercellSpacingChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "intercellSpacingChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4 2 1" "value": "cell 0 3"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "redGridColorCheckBox" name: "redGridColorCheckBox"
@@ -257,7 +293,7 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "redGridColorChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "redGridColorChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5 2 1" "value": "cell 0 4"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "rowSelectionCheckBox" name: "rowSelectionCheckBox"
@@ -268,7 +304,7 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "rowSelectionChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "rowSelectionChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6 2 1" "value": "cell 0 5"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "columnSelectionCheckBox" name: "columnSelectionCheckBox"
@@ -278,7 +314,7 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "columnSelectionChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "columnSelectionChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7 2 1" "value": "cell 0 6"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "dndCheckBox" name: "dndCheckBox"
@@ -289,7 +325,7 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "dndChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "dndChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 8 2 1" "value": "cell 0 7"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "tableHeaderButtonCheckBox" name: "tableHeaderButtonCheckBox"
@@ -299,10 +335,50 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tableHeaderButtonChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tableHeaderButtonChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 9 2 1" "value": "cell 0 8 2 1"
} ) } )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 3" "value": "cell 4 2 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "JXTable:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3,aligny top,growy 0"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "xTable1ScrollPane"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormComponent( "org.jdesktop.swingx.JXTable" ) {
name: "xTable1"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3 2 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "JXTreeTable:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 3,aligny top,growy 0"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "xTreeTable1ScrollPane"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormComponent( "org.jdesktop.swingx.JXTreeTable" ) {
name: "xTreeTable1"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 3 2 1"
} ) } )
}, new FormLayoutConstraints( null ) { }, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 ) "location": new java.awt.Point( 0, 0 )

View File

@@ -19,7 +19,10 @@ package com.formdev.flatlaf.testing;
import java.awt.*; import java.awt.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import javax.swing.event.ChangeListener;
import com.formdev.flatlaf.FlatClientProperties; import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.extras.components.*;
import com.formdev.flatlaf.extras.components.FlatButton.ButtonType;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
/** /**
@@ -35,8 +38,27 @@ public class FlatComponentsTest
} ); } );
} }
private final JSlider[] allSliders;
private final JSlider[] roundSliders;
private final JSlider[] directionalSliders;
FlatComponentsTest() { FlatComponentsTest() {
initComponents(); initComponents();
buttonTypeComboBox.init( ButtonType.class, true );
allSliders = new JSlider[] { slider1, slider2, slider3, slider4, slider5, slider6 };
roundSliders = new JSlider[] { slider1, slider2, slider6 };
directionalSliders = new JSlider[] { slider3, slider4, slider5 };
ChangeListener sliderChanged = e -> {
JSlider slider = (JSlider) e.getSource();
String text = slider.getValue() + " " + slider.getValueIsAdjusting();
sliderValueLabel.setText( text );
// System.out.println( text );
};
for( JSlider slider : allSliders )
slider.addChangeListener( sliderChanged );
} }
private void changeProgress() { private void changeProgress() {
@@ -55,6 +77,22 @@ public class FlatComponentsTest
progressBar4.setIndeterminate( indeterminate ); progressBar4.setIndeterminate( indeterminate );
} }
private void squareChanged() {
boolean square = squareCheckBox.isSelected();
progressBar1.setSquare( square );
progressBar2.setSquare( square );
progressBar3.setSquare( square );
progressBar4.setSquare( square );
}
private void largeHeightChanged() {
boolean largeHeight = largeHeightCheckBox.isSelected();
progressBar1.setLargeHeight( largeHeight );
progressBar2.setLargeHeight( largeHeight );
progressBar3.setLargeHeight( largeHeight );
progressBar4.setLargeHeight( largeHeight );
}
private void borderPaintedChanged() { private void borderPaintedChanged() {
boolean borderPainted = borderPaintedCheckBox.isSelected(); boolean borderPainted = borderPaintedCheckBox.isSelected();
@@ -99,13 +137,16 @@ public class FlatComponentsTest
} }
private void buttonTypeChanged() { private void buttonTypeChanged() {
String buttonType = (String) buttonTypeComboBox.getSelectedItem(); ButtonType buttonType = buttonTypeComboBox.getSelectedValue();
if( "-".equals( buttonType ) ) String buttonTypeStr = (buttonType != null && buttonType != ButtonType.none) ? buttonType.toString() : null;
buttonType = null;
for( Component c : getComponents() ) { for( Component c : getComponents() ) {
if( c instanceof AbstractButton ) if( c instanceof FlatButton )
((AbstractButton)c).putClientProperty( FlatClientProperties.BUTTON_TYPE, buttonType ); ((FlatButton)c).setButtonType( buttonType );
else if( c instanceof FlatToggleButton )
((FlatToggleButton)c).setButtonType( buttonType );
else if( c instanceof AbstractButton )
((AbstractButton)c).putClientProperty( FlatClientProperties.BUTTON_TYPE, buttonTypeStr );
} }
} }
@@ -129,6 +170,64 @@ public class FlatComponentsTest
textField1.requestFocusInWindow(); textField1.requestFocusInWindow();
} }
private void sliderPaintTrackChanged() {
boolean paintTrack = sliderPaintTrackCheckBox.isSelected();
for( JSlider slider : allSliders )
slider.setPaintTrack( paintTrack );
}
private void sliderPaintTicksChanged() {
Boolean paintTicks = sliderPaintTicksCheckBox.getChecked();
if( paintTicks != null ) {
for( JSlider slider : allSliders )
slider.setPaintTicks( paintTicks );
} else {
for( JSlider slider : roundSliders )
slider.setPaintTicks( false );
for( JSlider slider : directionalSliders )
slider.setPaintTicks( true );
}
}
private void sliderPaintLabelsChanged() {
Boolean paintLabels = sliderPaintLabelsCheckBox.getChecked();
if( paintLabels != null ) {
for( JSlider slider : allSliders )
slider.setPaintLabels( paintLabels );
} else {
for( JSlider slider : roundSliders )
slider.setPaintLabels( false );
for( JSlider slider : directionalSliders )
slider.setPaintLabels( true );
}
}
private void sliderInvertedChanged() {
boolean inverted = sliderInvertedCheckBox.isSelected();
for( JSlider slider : allSliders )
slider.setInverted( inverted );
}
private void sliderSnapToTicksChanged() {
boolean snapToTicks = sliderSnapToTicksCheckBox.isSelected();
for( JSlider slider : allSliders )
slider.setSnapToTicks( snapToTicks );
}
private void majorThickSpacingChanged() {
int majorTickSpacing = (Integer) majorTickSpacingSpinner.getValue();
for( JSlider slider : directionalSliders ) {
slider.setLabelTable( null );
slider.setMajorTickSpacing( majorTickSpacing );
}
}
private void minorThickSpacingChanged() {
int minorTickSpacing = (Integer) minorTickSpacingSpinner.getValue();
for( JSlider slider : directionalSliders )
slider.setMinorTickSpacing( minorTickSpacing );
}
private void initComponents() { private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel labelLabel = new JLabel(); JLabel labelLabel = new JLabel();
@@ -137,14 +236,14 @@ public class FlatComponentsTest
FlatComponentsTest.TestMultiLineLabel testMultiLineLabel1 = new FlatComponentsTest.TestMultiLineLabel(); FlatComponentsTest.TestMultiLineLabel testMultiLineLabel1 = new FlatComponentsTest.TestMultiLineLabel();
JLabel buttonLabel = new JLabel(); JLabel buttonLabel = new JLabel();
JButton button1 = new JButton(); JButton button1 = new JButton();
JButton button17 = new JButton(); FlatButton button17 = new FlatButton();
JButton button22 = new JButton(); FlatButton button22 = new FlatButton();
JButton button2 = new JButton(); JButton button2 = new JButton();
JButton button18 = new JButton(); FlatButton button18 = new FlatButton();
JButton button23 = new JButton(); FlatButton button23 = new FlatButton();
FlatComponentsTest.TestDefaultButton button5 = new FlatComponentsTest.TestDefaultButton(); FlatComponentsTest.TestDefaultButton button5 = new FlatComponentsTest.TestDefaultButton();
JButton button3 = new JButton(); FlatButton button3 = new FlatButton();
JButton button12 = new JButton(); FlatButton button12 = new FlatButton();
JButton button13 = new JButton(); JButton button13 = new JButton();
JButton button14 = new JButton(); JButton button14 = new JButton();
JButton button15 = new JButton(); JButton button15 = new JButton();
@@ -152,11 +251,11 @@ public class FlatComponentsTest
JButton button20 = new JButton(); JButton button20 = new JButton();
JLabel toggleButtonLabel = new JLabel(); JLabel toggleButtonLabel = new JLabel();
JToggleButton toggleButton1 = new JToggleButton(); JToggleButton toggleButton1 = new JToggleButton();
JToggleButton toggleButton9 = new JToggleButton(); FlatToggleButton toggleButton9 = new FlatToggleButton();
JToggleButton toggleButton19 = new JToggleButton(); FlatToggleButton toggleButton19 = new FlatToggleButton();
JToggleButton toggleButton2 = new JToggleButton(); JToggleButton toggleButton2 = new JToggleButton();
JToggleButton toggleButton10 = new JToggleButton(); FlatToggleButton toggleButton10 = new FlatToggleButton();
JToggleButton toggleButton20 = new JToggleButton(); FlatToggleButton toggleButton20 = new FlatToggleButton();
JToggleButton toggleButton3 = new JToggleButton(); JToggleButton toggleButton3 = new JToggleButton();
JToggleButton toggleButton4 = new JToggleButton(); JToggleButton toggleButton4 = new JToggleButton();
JToggleButton toggleButton11 = new JToggleButton(); JToggleButton toggleButton11 = new JToggleButton();
@@ -169,8 +268,8 @@ public class FlatComponentsTest
JCheckBox checkBox2 = new JCheckBox(); JCheckBox checkBox2 = new JCheckBox();
JCheckBox checkBox3 = new JCheckBox(); JCheckBox checkBox3 = new JCheckBox();
JCheckBox checkBox4 = new JCheckBox(); JCheckBox checkBox4 = new JCheckBox();
JToggleButton toggleButton5 = new JToggleButton(); FlatToggleButton toggleButton5 = new FlatToggleButton();
JToggleButton toggleButton8 = new JToggleButton(); FlatToggleButton toggleButton8 = new FlatToggleButton();
JLabel radioButtonLabel = new JLabel(); JLabel radioButtonLabel = new JLabel();
JRadioButton radioButton1 = new JRadioButton(); JRadioButton radioButton1 = new JRadioButton();
JRadioButton radioButton2 = new JRadioButton(); JRadioButton radioButton2 = new JRadioButton();
@@ -188,28 +287,28 @@ public class FlatComponentsTest
JSpinner spinner2 = new JSpinner(); JSpinner spinner2 = new JSpinner();
FlatComponentsTest.ButtonlessSpinner buttonlessSpinner1 = new FlatComponentsTest.ButtonlessSpinner(); FlatComponentsTest.ButtonlessSpinner buttonlessSpinner1 = new FlatComponentsTest.ButtonlessSpinner();
FlatComponentsTest.ButtonlessSpinner buttonlessSpinner2 = new FlatComponentsTest.ButtonlessSpinner(); FlatComponentsTest.ButtonlessSpinner buttonlessSpinner2 = new FlatComponentsTest.ButtonlessSpinner();
JComboBox<String> comboBox7 = new JComboBox<>(); FlatComboBox<String> comboBox7 = new FlatComboBox<>();
JSpinner spinner3 = new JSpinner(); JSpinner spinner3 = new JSpinner();
JLabel textFieldLabel = new JLabel(); JLabel textFieldLabel = new JLabel();
textField1 = new JTextField(); textField1 = new JTextField();
JTextField textField2 = new JTextField(); JTextField textField2 = new JTextField();
JTextField textField3 = new JTextField(); JTextField textField3 = new JTextField();
JTextField textField4 = new JTextField(); JTextField textField4 = new JTextField();
JTextField textField6 = new JTextField(); FlatTextField textField6 = new FlatTextField();
JTextField textField5 = new JTextField(); JTextField textField5 = new JTextField();
JLabel formattedTextFieldLabel = new JLabel(); JLabel formattedTextFieldLabel = new JLabel();
JFormattedTextField formattedTextField1 = new JFormattedTextField(); JFormattedTextField formattedTextField1 = new JFormattedTextField();
JFormattedTextField formattedTextField2 = new JFormattedTextField(); JFormattedTextField formattedTextField2 = new JFormattedTextField();
JFormattedTextField formattedTextField3 = new JFormattedTextField(); JFormattedTextField formattedTextField3 = new JFormattedTextField();
JFormattedTextField formattedTextField4 = new JFormattedTextField(); JFormattedTextField formattedTextField4 = new JFormattedTextField();
JFormattedTextField formattedTextField5 = new JFormattedTextField(); FlatFormattedTextField formattedTextField5 = new FlatFormattedTextField();
JFormattedTextField formattedTextField6 = new JFormattedTextField(); JFormattedTextField formattedTextField6 = new JFormattedTextField();
JLabel passwordFieldLabel = new JLabel(); JLabel passwordFieldLabel = new JLabel();
JPasswordField passwordField1 = new JPasswordField(); JPasswordField passwordField1 = new JPasswordField();
JPasswordField passwordField2 = new JPasswordField(); JPasswordField passwordField2 = new JPasswordField();
JPasswordField passwordField3 = new JPasswordField(); JPasswordField passwordField3 = new JPasswordField();
JPasswordField passwordField4 = new JPasswordField(); JPasswordField passwordField4 = new JPasswordField();
JPasswordField passwordField5 = new JPasswordField(); FlatPasswordField passwordField5 = new FlatPasswordField();
JPasswordField passwordField6 = new JPasswordField(); JPasswordField passwordField6 = new JPasswordField();
JLabel textAreaLabel = new JLabel(); JLabel textAreaLabel = new JLabel();
JScrollPane scrollPane1 = new JScrollPane(); JScrollPane scrollPane1 = new JScrollPane();
@@ -247,14 +346,14 @@ public class FlatComponentsTest
JButton button19 = new JButton(); JButton button19 = new JButton();
JScrollBar scrollBar2 = new JScrollBar(); JScrollBar scrollBar2 = new JScrollBar();
JScrollBar scrollBar3 = new JScrollBar(); JScrollBar scrollBar3 = new JScrollBar();
JScrollBar scrollBar7 = new JScrollBar(); FlatScrollBar scrollBar7 = new FlatScrollBar();
JScrollBar scrollBar8 = new JScrollBar(); FlatScrollBar scrollBar8 = new FlatScrollBar();
JSeparator separator2 = new JSeparator(); JSeparator separator2 = new JSeparator();
JSlider slider2 = new JSlider(); slider2 = new JSlider();
JSlider slider4 = new JSlider(); slider4 = new JSlider();
JScrollPane scrollPane14 = new JScrollPane(); JScrollPane scrollPane14 = new JScrollPane();
progressBar3 = new JProgressBar(); progressBar3 = new FlatProgressBar();
progressBar4 = new JProgressBar(); progressBar4 = new FlatProgressBar();
JToolBar toolBar2 = new JToolBar(); JToolBar toolBar2 = new JToolBar();
JButton button9 = new JButton(); JButton button9 = new JButton();
JButton button10 = new JButton(); JButton button10 = new JButton();
@@ -264,7 +363,7 @@ public class FlatComponentsTest
JPanel panel3 = new JPanel(); JPanel panel3 = new JPanel();
JButton button21 = new JButton(); JButton button21 = new JButton();
JPanel panel5 = new JPanel(); JPanel panel5 = new JPanel();
buttonTypeComboBox = new JComboBox<>(); buttonTypeComboBox = new FlatTestEnumComboBox<>();
borderPaintedCheckBox = new JCheckBox(); borderPaintedCheckBox = new JCheckBox();
roundRectCheckBox = new JCheckBox(); roundRectCheckBox = new JCheckBox();
contentAreaFilledCheckBox = new JCheckBox(); contentAreaFilledCheckBox = new JCheckBox();
@@ -278,21 +377,34 @@ public class FlatComponentsTest
JLabel scrollBarLabel = new JLabel(); JLabel scrollBarLabel = new JLabel();
JScrollBar scrollBar1 = new JScrollBar(); JScrollBar scrollBar1 = new JScrollBar();
JScrollBar scrollBar4 = new JScrollBar(); JScrollBar scrollBar4 = new JScrollBar();
JScrollBar scrollBar5 = new JScrollBar(); FlatScrollBar scrollBar5 = new FlatScrollBar();
JScrollBar scrollBar6 = new JScrollBar(); FlatScrollBar scrollBar6 = new FlatScrollBar();
JLabel separatorLabel = new JLabel(); JLabel separatorLabel = new JLabel();
JSeparator separator1 = new JSeparator(); JSeparator separator1 = new JSeparator();
JPanel panel2 = new JPanel(); JPanel panel2 = new JPanel();
JLabel sliderLabel = new JLabel(); JLabel sliderLabel = new JLabel();
JSlider slider1 = new JSlider(); slider1 = new JSlider();
JSlider slider6 = new JSlider(); slider6 = new JSlider();
JPanel panel8 = new JPanel();
JPanel panel6 = new JPanel();
sliderPaintTrackCheckBox = new JCheckBox();
sliderPaintTicksCheckBox = new FlatTriStateCheckBox();
sliderPaintLabelsCheckBox = new FlatTriStateCheckBox();
sliderInvertedCheckBox = new JCheckBox();
sliderSnapToTicksCheckBox = new JCheckBox();
majorTickSpacingSpinner = new JSpinner();
minorTickSpacingSpinner = new JSpinner();
sliderValueLabel = new JLabel();
JPanel panel7 = new JPanel();
indeterminateCheckBox = new JCheckBox();
squareCheckBox = new JCheckBox();
largeHeightCheckBox = new JCheckBox();
JLabel sliderLabel2 = new JLabel(); JLabel sliderLabel2 = new JLabel();
slider3 = new JSlider(); slider3 = new JSlider();
JSlider slider5 = new JSlider(); slider5 = new JSlider();
JLabel progressBarLabel = new JLabel(); JLabel progressBarLabel = new JLabel();
progressBar1 = new JProgressBar(); progressBar1 = new FlatProgressBar();
progressBar2 = new JProgressBar(); progressBar2 = new FlatProgressBar();
indeterminateCheckBox = new JCheckBox();
JLabel toolTipLabel = new JLabel(); JLabel toolTipLabel = new JLabel();
JToolTip toolTip1 = new JToolTip(); JToolTip toolTip1 = new JToolTip();
JToolTip toolTip2 = new JToolTip(); JToolTip toolTip2 = new JToolTip();
@@ -308,16 +420,16 @@ public class FlatComponentsTest
JToggleButton toggleButton17 = new JToggleButton(); JToggleButton toggleButton17 = new JToggleButton();
JLabel label3 = new JLabel(); JLabel label3 = new JLabel();
JToolBar toolBar3 = new JToolBar(); JToolBar toolBar3 = new JToolBar();
JButton button26 = new JButton(); FlatButton button26 = new FlatButton();
JButton button27 = new JButton(); FlatButton button27 = new FlatButton();
JToggleButton toggleButton23 = new JToggleButton(); FlatToggleButton toggleButton23 = new FlatToggleButton();
JToggleButton toggleButton24 = new JToggleButton(); FlatToggleButton toggleButton24 = new FlatToggleButton();
JLabel label4 = new JLabel(); JLabel label4 = new JLabel();
JToolBar toolBar4 = new JToolBar(); JToolBar toolBar4 = new JToolBar();
JButton button28 = new JButton(); FlatButton button28 = new FlatButton();
JButton button29 = new JButton(); FlatButton button29 = new FlatButton();
JToggleButton toggleButton25 = new JToggleButton(); FlatToggleButton toggleButton25 = new FlatToggleButton();
JToggleButton toggleButton26 = new JToggleButton(); FlatToggleButton toggleButton26 = new FlatToggleButton();
//======== this ======== //======== this ========
setLayout(new MigLayout( setLayout(new MigLayout(
@@ -387,14 +499,14 @@ public class FlatComponentsTest
//---- button17 ---- //---- button17 ----
button17.setText("Sq"); button17.setText("Sq");
button17.putClientProperty("JButton.buttonType", "square"); button17.setButtonType(FlatButton.ButtonType.square);
button17.putClientProperty("JComponent.minimumWidth", 0); button17.setMinimumWidth(0);
add(button17, "cell 1 1"); add(button17, "cell 1 1");
//---- button22 ---- //---- button22 ----
button22.setText("Rd"); button22.setText("Rd");
button22.putClientProperty("JButton.buttonType", "roundRect"); button22.setButtonType(FlatButton.ButtonType.roundRect);
button22.putClientProperty("JComponent.minimumWidth", 0); button22.setMinimumWidth(0);
add(button22, "cell 1 1"); add(button22, "cell 1 1");
//---- button2 ---- //---- button2 ----
@@ -406,16 +518,16 @@ public class FlatComponentsTest
//---- button18 ---- //---- button18 ----
button18.setText("Sq"); button18.setText("Sq");
button18.putClientProperty("JButton.buttonType", "square"); button18.setButtonType(FlatButton.ButtonType.square);
button18.setEnabled(false); button18.setEnabled(false);
button18.putClientProperty("JComponent.minimumWidth", 0); button18.setMinimumWidth(0);
add(button18, "cell 2 1"); add(button18, "cell 2 1");
//---- button23 ---- //---- button23 ----
button23.setText("Rd"); button23.setText("Rd");
button23.putClientProperty("JButton.buttonType", "roundRect"); button23.setButtonType(FlatButton.ButtonType.roundRect);
button23.setEnabled(false); button23.setEnabled(false);
button23.putClientProperty("JComponent.minimumWidth", 0); button23.setMinimumWidth(0);
add(button23, "cell 2 1"); add(button23, "cell 2 1");
//---- button5 ---- //---- button5 ----
@@ -426,12 +538,12 @@ public class FlatComponentsTest
//---- button3 ---- //---- button3 ----
button3.setText("Help"); button3.setText("Help");
button3.putClientProperty("JButton.buttonType", "help"); button3.setButtonType(FlatButton.ButtonType.help);
add(button3, "cell 4 1"); add(button3, "cell 4 1");
//---- button12 ---- //---- button12 ----
button12.setText("Help"); button12.setText("Help");
button12.putClientProperty("JButton.buttonType", "help"); button12.setButtonType(FlatButton.ButtonType.help);
button12.setEnabled(false); button12.setEnabled(false);
add(button12, "cell 4 1"); add(button12, "cell 4 1");
@@ -462,16 +574,17 @@ public class FlatComponentsTest
//---- toggleButton1 ---- //---- toggleButton1 ----
toggleButton1.setText("Enabled"); toggleButton1.setText("Enabled");
toggleButton1.setToolTipText("LOOOOOOOOOOOOOONG TEXT");
add(toggleButton1, "cell 1 2"); add(toggleButton1, "cell 1 2");
//---- toggleButton9 ---- //---- toggleButton9 ----
toggleButton9.setText("Sq"); toggleButton9.setText("Sq");
toggleButton9.putClientProperty("JButton.buttonType", "square"); toggleButton9.setButtonType(FlatButton.ButtonType.square);
add(toggleButton9, "cell 1 2"); add(toggleButton9, "cell 1 2");
//---- toggleButton19 ---- //---- toggleButton19 ----
toggleButton19.setText("Rd"); toggleButton19.setText("Rd");
toggleButton19.putClientProperty("JButton.buttonType", "roundRect"); toggleButton19.setButtonType(FlatButton.ButtonType.roundRect);
add(toggleButton19, "cell 1 2"); add(toggleButton19, "cell 1 2");
//---- toggleButton2 ---- //---- toggleButton2 ----
@@ -481,13 +594,13 @@ public class FlatComponentsTest
//---- toggleButton10 ---- //---- toggleButton10 ----
toggleButton10.setText("Sq"); toggleButton10.setText("Sq");
toggleButton10.putClientProperty("JButton.buttonType", "square"); toggleButton10.setButtonType(FlatButton.ButtonType.square);
toggleButton10.setEnabled(false); toggleButton10.setEnabled(false);
add(toggleButton10, "cell 2 2"); add(toggleButton10, "cell 2 2");
//---- toggleButton20 ---- //---- toggleButton20 ----
toggleButton20.setText("Rd"); toggleButton20.setText("Rd");
toggleButton20.putClientProperty("JButton.buttonType", "roundRect"); toggleButton20.setButtonType(FlatButton.ButtonType.roundRect);
toggleButton20.setEnabled(false); toggleButton20.setEnabled(false);
add(toggleButton20, "cell 2 2"); add(toggleButton20, "cell 2 2");
@@ -555,13 +668,13 @@ public class FlatComponentsTest
//---- toggleButton5 ---- //---- toggleButton5 ----
toggleButton5.setText("Tab"); toggleButton5.setText("Tab");
toggleButton5.putClientProperty("JButton.buttonType", "tab"); toggleButton5.setButtonType(FlatButton.ButtonType.tab);
toggleButton5.setSelected(true); toggleButton5.setSelected(true);
add(toggleButton5, "cell 5 3"); add(toggleButton5, "cell 5 3");
//---- toggleButton8 ---- //---- toggleButton8 ----
toggleButton8.setText("Tab"); toggleButton8.setText("Tab");
toggleButton8.putClientProperty("JButton.buttonType", "tab"); toggleButton8.setButtonType(FlatButton.ButtonType.tab);
toggleButton8.setEnabled(false); toggleButton8.setEnabled(false);
toggleButton8.setSelected(true); toggleButton8.setSelected(true);
add(toggleButton8, "cell 5 3"); add(toggleButton8, "cell 5 3");
@@ -686,7 +799,7 @@ public class FlatComponentsTest
//---- comboBox7 ---- //---- comboBox7 ----
comboBox7.setEditable(true); comboBox7.setEditable(true);
comboBox7.putClientProperty("JTextField.placeholderText", "Placeholder"); comboBox7.setPlaceholderText("Placeholder");
add(comboBox7, "cell 5 6,growx"); add(comboBox7, "cell 5 6,growx");
//---- spinner3 ---- //---- spinner3 ----
@@ -719,7 +832,7 @@ public class FlatComponentsTest
add(textField4, "cell 4 7,growx"); add(textField4, "cell 4 7,growx");
//---- textField6 ---- //---- textField6 ----
textField6.putClientProperty("JTextField.placeholderText", "Placeholder"); textField6.setPlaceholderText("Placeholder");
add(textField6, "cell 5 7,growx"); add(textField6, "cell 5 7,growx");
//---- textField5 ---- //---- textField5 ----
@@ -752,7 +865,7 @@ public class FlatComponentsTest
add(formattedTextField4, "cell 4 8,growx"); add(formattedTextField4, "cell 4 8,growx");
//---- formattedTextField5 ---- //---- formattedTextField5 ----
formattedTextField5.putClientProperty("JTextField.placeholderText", "Placeholder"); formattedTextField5.setPlaceholderText("Placeholder");
add(formattedTextField5, "cell 5 8,growx"); add(formattedTextField5, "cell 5 8,growx");
//---- formattedTextField6 ---- //---- formattedTextField6 ----
@@ -785,7 +898,7 @@ public class FlatComponentsTest
add(passwordField4, "cell 4 9,growx"); add(passwordField4, "cell 4 9,growx");
//---- passwordField5 ---- //---- passwordField5 ----
passwordField5.putClientProperty("JTextField.placeholderText", "Placeholder"); passwordField5.setPlaceholderText("Placeholder");
add(passwordField5, "cell 5 9,growx"); add(passwordField5, "cell 5 9,growx");
//---- passwordField6 ---- //---- passwordField6 ----
@@ -996,12 +1109,12 @@ public class FlatComponentsTest
add(scrollBar3, "cell 2 13 1 6,growy"); add(scrollBar3, "cell 2 13 1 6,growy");
//---- scrollBar7 ---- //---- scrollBar7 ----
scrollBar7.putClientProperty("JScrollBar.showButtons", true); scrollBar7.setShowButtons(true);
add(scrollBar7, "cell 2 13 1 6,growy"); add(scrollBar7, "cell 2 13 1 6,growy");
//---- scrollBar8 ---- //---- scrollBar8 ----
scrollBar8.setEnabled(false); scrollBar8.setEnabled(false);
scrollBar8.putClientProperty("JScrollBar.showButtons", true); scrollBar8.setShowButtons(true);
add(scrollBar8, "cell 2 13 1 6,growy"); add(scrollBar8, "cell 2 13 1 6,growy");
//---- separator2 ---- //---- separator2 ----
@@ -1091,13 +1204,6 @@ public class FlatComponentsTest
"[]")); "[]"));
//---- buttonTypeComboBox ---- //---- buttonTypeComboBox ----
buttonTypeComboBox.setModel(new DefaultComboBoxModel<>(new String[] {
"-",
"square",
"roundRect",
"tab",
"help"
}));
buttonTypeComboBox.addActionListener(e -> buttonTypeChanged()); buttonTypeComboBox.addActionListener(e -> buttonTypeChanged());
panel5.add(buttonTypeComboBox, "cell 0 0"); panel5.add(buttonTypeComboBox, "cell 0 0");
@@ -1173,13 +1279,13 @@ public class FlatComponentsTest
//---- scrollBar5 ---- //---- scrollBar5 ----
scrollBar5.setOrientation(Adjustable.HORIZONTAL); scrollBar5.setOrientation(Adjustable.HORIZONTAL);
scrollBar5.putClientProperty("JScrollBar.showButtons", true); scrollBar5.setShowButtons(true);
add(scrollBar5, "cell 1 16,growx"); add(scrollBar5, "cell 1 16,growx");
//---- scrollBar6 ---- //---- scrollBar6 ----
scrollBar6.setOrientation(Adjustable.HORIZONTAL); scrollBar6.setOrientation(Adjustable.HORIZONTAL);
scrollBar6.setEnabled(false); scrollBar6.setEnabled(false);
scrollBar6.putClientProperty("JScrollBar.showButtons", true); scrollBar6.setShowButtons(true);
add(scrollBar6, "cell 1 17,growx"); add(scrollBar6, "cell 1 17,growx");
//---- separatorLabel ---- //---- separatorLabel ----
@@ -1208,6 +1314,104 @@ public class FlatComponentsTest
slider6.setValue(30); slider6.setValue(30);
add(slider6, "cell 1 19 3 1"); add(slider6, "cell 1 19 3 1");
//======== panel8 ========
{
panel8.setLayout(new MigLayout(
"ltr,insets 0,hidemode 3",
// columns
"[]",
// rows
"[]" +
"[]" +
"[]" +
"[]"));
//======== panel6 ========
{
panel6.setBorder(new TitledBorder("JSlider Control"));
panel6.setLayout(new MigLayout(
"ltr,insets 0,hidemode 3",
// columns
"[]",
// rows
"[]0" +
"[]0" +
"[]0" +
"[]"));
//---- sliderPaintTrackCheckBox ----
sliderPaintTrackCheckBox.setText("track");
sliderPaintTrackCheckBox.setSelected(true);
sliderPaintTrackCheckBox.addActionListener(e -> sliderPaintTrackChanged());
panel6.add(sliderPaintTrackCheckBox, "cell 0 0");
//---- sliderPaintTicksCheckBox ----
sliderPaintTicksCheckBox.setText("ticks");
sliderPaintTicksCheckBox.addActionListener(e -> sliderPaintTicksChanged());
panel6.add(sliderPaintTicksCheckBox, "cell 0 0");
//---- sliderPaintLabelsCheckBox ----
sliderPaintLabelsCheckBox.setText("labels");
sliderPaintLabelsCheckBox.addActionListener(e -> sliderPaintLabelsChanged());
panel6.add(sliderPaintLabelsCheckBox, "cell 0 0");
//---- sliderInvertedCheckBox ----
sliderInvertedCheckBox.setText("inverted");
sliderInvertedCheckBox.addActionListener(e -> sliderInvertedChanged());
panel6.add(sliderInvertedCheckBox, "cell 0 1");
//---- sliderSnapToTicksCheckBox ----
sliderSnapToTicksCheckBox.setText("snap to ticks");
sliderSnapToTicksCheckBox.addActionListener(e -> sliderSnapToTicksChanged());
panel6.add(sliderSnapToTicksCheckBox, "cell 0 1");
//---- majorTickSpacingSpinner ----
majorTickSpacingSpinner.setModel(new SpinnerNumberModel(50, 0, 100, 5));
majorTickSpacingSpinner.addChangeListener(e -> majorThickSpacingChanged());
panel6.add(majorTickSpacingSpinner, "cell 0 2");
//---- minorTickSpacingSpinner ----
minorTickSpacingSpinner.setModel(new SpinnerNumberModel(10, 0, 100, 5));
minorTickSpacingSpinner.addChangeListener(e -> minorThickSpacingChanged());
panel6.add(minorTickSpacingSpinner, "cell 0 2");
//---- sliderValueLabel ----
sliderValueLabel.setText("slider value");
panel6.add(sliderValueLabel, "cell 0 3");
}
panel8.add(panel6, "cell 0 0 1 2,grow");
//======== panel7 ========
{
panel7.setBorder(new TitledBorder("JProgressBar Control"));
panel7.setLayout(new MigLayout(
"ltr,insets 0,hidemode 3",
// columns
"[]" +
"[fill]",
// rows
"[]0" +
"[]"));
//---- indeterminateCheckBox ----
indeterminateCheckBox.setText("indeterminate");
indeterminateCheckBox.addActionListener(e -> indeterminateProgress());
panel7.add(indeterminateCheckBox, "cell 0 0");
//---- squareCheckBox ----
squareCheckBox.setText("square");
squareCheckBox.addActionListener(e -> squareChanged());
panel7.add(squareCheckBox, "cell 1 0");
//---- largeHeightCheckBox ----
largeHeightCheckBox.setText("large height");
largeHeightCheckBox.addActionListener(e -> largeHeightChanged());
panel7.add(largeHeightCheckBox, "cell 0 1,aligny top,growy 0");
}
panel8.add(panel7, "cell 0 2 1 2,grow");
}
add(panel8, "cell 4 19 1 4");
//---- sliderLabel2 ---- //---- sliderLabel2 ----
sliderLabel2.setText("baseline"); sliderLabel2.setText("baseline");
add(sliderLabel2, "cell 0 20,alignx right,growx 0"); add(sliderLabel2, "cell 0 20,alignx right,growx 0");
@@ -1243,11 +1447,6 @@ public class FlatComponentsTest
progressBar2.setValue(60); progressBar2.setValue(60);
add(progressBar2, "cell 1 21 3 1,growx"); add(progressBar2, "cell 1 21 3 1,growx");
//---- indeterminateCheckBox ----
indeterminateCheckBox.setText("indeterminate");
indeterminateCheckBox.addActionListener(e -> indeterminateProgress());
add(indeterminateCheckBox, "cell 4 21");
//---- toolTipLabel ---- //---- toolTipLabel ----
toolTipLabel.setText("JToolTip:"); toolTipLabel.setText("JToolTip:");
add(toolTipLabel, "cell 0 22"); add(toolTipLabel, "cell 0 22");
@@ -1318,24 +1517,24 @@ public class FlatComponentsTest
//---- button26 ---- //---- button26 ----
button26.setIcon(UIManager.getIcon("Tree.closedIcon")); button26.setIcon(UIManager.getIcon("Tree.closedIcon"));
button26.putClientProperty("JButton.buttonType", "square"); button26.setButtonType(FlatButton.ButtonType.square);
toolBar3.add(button26); toolBar3.add(button26);
//---- button27 ---- //---- button27 ----
button27.setIcon(UIManager.getIcon("Tree.openIcon")); button27.setIcon(UIManager.getIcon("Tree.openIcon"));
button27.putClientProperty("JButton.buttonType", "square"); button27.setButtonType(FlatButton.ButtonType.square);
toolBar3.add(button27); toolBar3.add(button27);
//---- toggleButton23 ---- //---- toggleButton23 ----
toggleButton23.setIcon(UIManager.getIcon("FileView.computerIcon")); toggleButton23.setIcon(UIManager.getIcon("FileView.computerIcon"));
toggleButton23.setSelected(true); toggleButton23.setSelected(true);
toggleButton23.putClientProperty("JButton.buttonType", "square"); toggleButton23.setButtonType(FlatButton.ButtonType.square);
toolBar3.add(toggleButton23); toolBar3.add(toggleButton23);
//---- toggleButton24 ---- //---- toggleButton24 ----
toggleButton24.setIcon(UIManager.getIcon("FileView.floppyDriveIcon")); toggleButton24.setIcon(UIManager.getIcon("FileView.floppyDriveIcon"));
toggleButton24.setSelected(true); toggleButton24.setSelected(true);
toggleButton24.putClientProperty("JButton.buttonType", "square"); toggleButton24.setButtonType(FlatButton.ButtonType.square);
toolBar3.add(toggleButton24); toolBar3.add(toggleButton24);
} }
add(toolBar3, "cell 1 23 5 1"); add(toolBar3, "cell 1 23 5 1");
@@ -1349,24 +1548,24 @@ public class FlatComponentsTest
//---- button28 ---- //---- button28 ----
button28.setIcon(UIManager.getIcon("Tree.closedIcon")); button28.setIcon(UIManager.getIcon("Tree.closedIcon"));
button28.putClientProperty("JButton.buttonType", "roundRect"); button28.setButtonType(FlatButton.ButtonType.roundRect);
toolBar4.add(button28); toolBar4.add(button28);
//---- button29 ---- //---- button29 ----
button29.setIcon(UIManager.getIcon("Tree.openIcon")); button29.setIcon(UIManager.getIcon("Tree.openIcon"));
button29.putClientProperty("JButton.buttonType", "roundRect"); button29.setButtonType(FlatButton.ButtonType.roundRect);
toolBar4.add(button29); toolBar4.add(button29);
//---- toggleButton25 ---- //---- toggleButton25 ----
toggleButton25.setIcon(UIManager.getIcon("FileView.computerIcon")); toggleButton25.setIcon(UIManager.getIcon("FileView.computerIcon"));
toggleButton25.setSelected(true); toggleButton25.setSelected(true);
toggleButton25.putClientProperty("JButton.buttonType", "roundRect"); toggleButton25.setButtonType(FlatButton.ButtonType.roundRect);
toolBar4.add(toggleButton25); toolBar4.add(toggleButton25);
//---- toggleButton26 ---- //---- toggleButton26 ----
toggleButton26.setIcon(UIManager.getIcon("FileView.floppyDriveIcon")); toggleButton26.setIcon(UIManager.getIcon("FileView.floppyDriveIcon"));
toggleButton26.setSelected(true); toggleButton26.setSelected(true);
toggleButton26.putClientProperty("JButton.buttonType", "roundRect"); toggleButton26.setButtonType(FlatButton.ButtonType.roundRect);
toolBar4.add(toggleButton26); toolBar4.add(toggleButton26);
} }
add(toolBar4, "cell 1 23 5 1"); add(toolBar4, "cell 1 23 5 1");
@@ -1388,9 +1587,11 @@ public class FlatComponentsTest
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JTextField textField1; private JTextField textField1;
private JProgressBar progressBar3; private JSlider slider2;
private JProgressBar progressBar4; private JSlider slider4;
private JComboBox<String> buttonTypeComboBox; private FlatProgressBar progressBar3;
private FlatProgressBar progressBar4;
private FlatTestEnumComboBox<ButtonType> buttonTypeComboBox;
private JCheckBox borderPaintedCheckBox; private JCheckBox borderPaintedCheckBox;
private JCheckBox roundRectCheckBox; private JCheckBox roundRectCheckBox;
private JCheckBox contentAreaFilledCheckBox; private JCheckBox contentAreaFilledCheckBox;
@@ -1400,10 +1601,23 @@ public class FlatComponentsTest
private JRadioButton magentaOutlineRadioButton; private JRadioButton magentaOutlineRadioButton;
private JRadioButton magentaCyanOutlineRadioButton; private JRadioButton magentaCyanOutlineRadioButton;
private JCheckBox focusPaintedCheckBox; private JCheckBox focusPaintedCheckBox;
private JSlider slider3; private JSlider slider1;
private JProgressBar progressBar1; private JSlider slider6;
private JProgressBar progressBar2; private JCheckBox sliderPaintTrackCheckBox;
private FlatTriStateCheckBox sliderPaintTicksCheckBox;
private FlatTriStateCheckBox sliderPaintLabelsCheckBox;
private JCheckBox sliderInvertedCheckBox;
private JCheckBox sliderSnapToTicksCheckBox;
private JSpinner majorTickSpacingSpinner;
private JSpinner minorTickSpacingSpinner;
private JLabel sliderValueLabel;
private JCheckBox indeterminateCheckBox; private JCheckBox indeterminateCheckBox;
private JCheckBox squareCheckBox;
private JCheckBox largeHeightCheckBox;
private JSlider slider3;
private JSlider slider5;
private FlatProgressBar progressBar1;
private FlatProgressBar progressBar2;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
//---- class TestDefaultButton -------------------------------------------- //---- class TestDefaultButton --------------------------------------------

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8" JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
new FormModel { new FormModel {
contentType: "form/swing" contentType: "form/swing"
@@ -53,19 +53,19 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1" "value": "cell 1 1"
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button17" name: "button17"
"text": "Sq" "text": "Sq"
"$client.JButton.buttonType": "square" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType square
"$client.JComponent.minimumWidth": 0 "minimumWidth": 0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1" "value": "cell 1 1"
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button22" name: "button22"
"text": "Rd" "text": "Rd"
"$client.JButton.buttonType": "roundRect" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType roundRect
"$client.JComponent.minimumWidth": 0 "minimumWidth": 0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1" "value": "cell 1 1"
} ) } )
@@ -78,21 +78,21 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1" "value": "cell 2 1"
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button18" name: "button18"
"text": "Sq" "text": "Sq"
"$client.JButton.buttonType": "square" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType square
"enabled": false "enabled": false
"$client.JComponent.minimumWidth": 0 "minimumWidth": 0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1" "value": "cell 2 1"
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button23" name: "button23"
"text": "Rd" "text": "Rd"
"$client.JButton.buttonType": "roundRect" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType roundRect
"enabled": false "enabled": false
"$client.JComponent.minimumWidth": 0 "minimumWidth": 0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1" "value": "cell 2 1"
} ) } )
@@ -104,17 +104,17 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 1" "value": "cell 3 1"
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button3" name: "button3"
"text": "Help" "text": "Help"
"$client.JButton.buttonType": "help" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType help
}, 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" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button12" name: "button12"
"text": "Help" "text": "Help"
"$client.JButton.buttonType": "help" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType help
"enabled": false "enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 1" "value": "cell 4 1"
@@ -159,20 +159,21 @@ new FormModel {
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "toggleButton1" name: "toggleButton1"
"text": "Enabled" "text": "Enabled"
"toolTipText": "LOOOOOOOOOOOOOONG TEXT"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2" "value": "cell 1 2"
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton9" name: "toggleButton9"
"text": "Sq" "text": "Sq"
"$client.JButton.buttonType": "square" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType square
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2" "value": "cell 1 2"
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton19" name: "toggleButton19"
"text": "Rd" "text": "Rd"
"$client.JButton.buttonType": "roundRect" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType roundRect
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2" "value": "cell 1 2"
} ) } )
@@ -183,18 +184,18 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2" "value": "cell 2 2"
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton10" name: "toggleButton10"
"text": "Sq" "text": "Sq"
"$client.JButton.buttonType": "square" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType square
"enabled": false "enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2" "value": "cell 2 2"
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton20" name: "toggleButton20"
"text": "Rd" "text": "Rd"
"$client.JButton.buttonType": "roundRect" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType roundRect
"enabled": false "enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2" "value": "cell 2 2"
@@ -285,18 +286,18 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 3" "value": "cell 4 3"
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton5" name: "toggleButton5"
"text": "Tab" "text": "Tab"
"$client.JButton.buttonType": "tab" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType tab
"selected": true "selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 3" "value": "cell 5 3"
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton8" name: "toggleButton8"
"text": "Tab" "text": "Tab"
"$client.JButton.buttonType": "tab" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType tab
"enabled": false "enabled": false
"selected": true "selected": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -466,10 +467,10 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 6,growx" "value": "cell 4 6,growx"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatComboBox" ) {
name: "comboBox7" name: "comboBox7"
"editable": true "editable": true
"$client.JTextField.placeholderText": "Placeholder" "placeholderText": "Placeholder"
auxiliary() { auxiliary() {
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "String"
} }
@@ -522,9 +523,9 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 7,growx" "value": "cell 4 7,growx"
} ) } )
add( new FormComponent( "javax.swing.JTextField" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTextField" ) {
name: "textField6" name: "textField6"
"$client.JTextField.placeholderText": "Placeholder" "placeholderText": "Placeholder"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 7,growx" "value": "cell 5 7,growx"
} ) } )
@@ -569,9 +570,9 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 8,growx" "value": "cell 4 8,growx"
} ) } )
add( new FormComponent( "javax.swing.JFormattedTextField" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatFormattedTextField" ) {
name: "formattedTextField5" name: "formattedTextField5"
"$client.JTextField.placeholderText": "Placeholder" "placeholderText": "Placeholder"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 8,growx" "value": "cell 5 8,growx"
} ) } )
@@ -616,9 +617,9 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 9,growx" "value": "cell 4 9,growx"
} ) } )
add( new FormComponent( "javax.swing.JPasswordField" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatPasswordField" ) {
name: "passwordField5" name: "passwordField5"
"$client.JTextField.placeholderText": "Placeholder" "placeholderText": "Placeholder"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 9,growx" "value": "cell 5 9,growx"
} ) } )
@@ -850,16 +851,16 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 6,growy" "value": "cell 2 13 1 6,growy"
} ) } )
add( new FormComponent( "javax.swing.JScrollBar" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) {
name: "scrollBar7" name: "scrollBar7"
"$client.JScrollBar.showButtons": true "showButtons": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 6,growy" "value": "cell 2 13 1 6,growy"
} ) } )
add( new FormComponent( "javax.swing.JScrollBar" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) {
name: "scrollBar8" name: "scrollBar8"
"enabled": false "enabled": false
"$client.JScrollBar.showButtons": true "showButtons": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 6,growy" "value": "cell 2 13 1 6,growy"
} ) } )
@@ -873,6 +874,9 @@ new FormModel {
name: "slider2" name: "slider2"
"orientation": 1 "orientation": 1
"value": 30 "value": 30
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 6,growy" "value": "cell 2 13 1 6,growy"
} ) } )
@@ -884,6 +888,9 @@ new FormModel {
"paintLabels": true "paintLabels": true
"orientation": 1 "orientation": 1
"value": 30 "value": 30
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 13 1 6,growy" "value": "cell 2 13 1 6,growy"
} ) } )
@@ -892,7 +899,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 13,grow" "value": "cell 3 13,grow"
} ) } )
add( new FormComponent( "javax.swing.JProgressBar" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) {
name: "progressBar3" name: "progressBar3"
"orientation": 1 "orientation": 1
"value": 60 "value": 60
@@ -902,7 +909,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 13 1 6,growy" "value": "cell 4 13 1 6,growy"
} ) } )
add( new FormComponent( "javax.swing.JProgressBar" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) {
name: "progressBar4" name: "progressBar4"
"orientation": 1 "orientation": 1
"value": 60 "value": 60
@@ -963,18 +970,11 @@ new FormModel {
} ) { } ) {
name: "panel5" name: "panel5"
"border": new javax.swing.border.TitledBorder( "Control" ) "border": new javax.swing.border.TitledBorder( "Control" )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "buttonTypeComboBox" name: "buttonTypeComboBox"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "-"
addElement( "-" )
addElement( "square" )
addElement( "roundRect" )
addElement( "tab" )
addElement( "help" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "ButtonType"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "buttonTypeChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "buttonTypeChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -1098,18 +1098,18 @@ 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 FormComponent( "javax.swing.JScrollBar" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) {
name: "scrollBar5" name: "scrollBar5"
"orientation": 0 "orientation": 0
"$client.JScrollBar.showButtons": true "showButtons": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 16,growx" "value": "cell 1 16,growx"
} ) } )
add( new FormComponent( "javax.swing.JScrollBar" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatScrollBar" ) {
name: "scrollBar6" name: "scrollBar6"
"orientation": 0 "orientation": 0
"enabled": false "enabled": false
"$client.JScrollBar.showButtons": true "showButtons": true
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 17,growx" "value": "cell 1 17,growx"
} ) } )
@@ -1140,6 +1140,9 @@ new FormModel {
add( new FormComponent( "javax.swing.JSlider" ) { add( new FormComponent( "javax.swing.JSlider" ) {
name: "slider1" name: "slider1"
"value": 30 "value": 30
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 19 3 1,growx" "value": "cell 1 19 3 1,growx"
} ) } )
@@ -1147,9 +1150,151 @@ new FormModel {
name: "slider6" name: "slider6"
"enabled": false "enabled": false
"value": 30 "value": 30
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 19 3 1" "value": "cell 1 19 3 1"
} ) } )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[]"
"$rowConstraints": "[][][][]"
"$layoutConstraints": "ltr,insets 0,hidemode 3"
} ) {
name: "panel8"
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[]"
"$rowConstraints": "[]0[]0[]0[]"
"$layoutConstraints": "ltr,insets 0,hidemode 3"
} ) {
name: "panel6"
"border": new javax.swing.border.TitledBorder( "JSlider Control" )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "sliderPaintTrackCheckBox"
"text": "track"
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "sliderPaintTrackChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "sliderPaintTicksCheckBox"
"text": "ticks"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "sliderPaintTicksChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "sliderPaintLabelsCheckBox"
"text": "labels"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "sliderPaintLabelsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "sliderInvertedCheckBox"
"text": "inverted"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "sliderInvertedChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "sliderSnapToTicksCheckBox"
"text": "snap to ticks"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "sliderSnapToTicksChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "majorTickSpacingSpinner"
"model": new javax.swing.SpinnerNumberModel( 50, 0, 100, 5 )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "majorThickSpacingChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "minorTickSpacingSpinner"
"model": new javax.swing.SpinnerNumberModel( 10, 0, 100, 5 )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "minorThickSpacingChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "sliderValueLabel"
"text": "slider value"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0 1 2,grow"
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[][fill]"
"$rowConstraints": "[]0[]"
"$layoutConstraints": "ltr,insets 0,hidemode 3"
} ) {
name: "panel7"
"border": new javax.swing.border.TitledBorder( "JProgressBar Control" )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "indeterminateCheckBox"
"text": "indeterminate"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "indeterminateProgress", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "squareCheckBox"
"text": "square"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "squareChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "largeHeightCheckBox"
"text": "large height"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "largeHeightChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1,aligny top,growy 0"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2 1 2,grow"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 19 1 4"
} )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "sliderLabel2" name: "sliderLabel2"
"text": "baseline" "text": "baseline"
@@ -1178,6 +1323,9 @@ new FormModel {
"paintLabels": true "paintLabels": true
"enabled": false "enabled": false
"value": 30 "value": 30
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 20 3 1" "value": "cell 1 20 3 1"
} ) } )
@@ -1187,7 +1335,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 21" "value": "cell 0 21"
} ) } )
add( new FormComponent( "javax.swing.JProgressBar" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) {
name: "progressBar1" name: "progressBar1"
"value": 60 "value": 60
auxiliary() { auxiliary() {
@@ -1196,7 +1344,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 21 3 1,growx" "value": "cell 1 21 3 1,growx"
} ) } )
add( new FormComponent( "javax.swing.JProgressBar" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatProgressBar" ) {
name: "progressBar2" name: "progressBar2"
"stringPainted": true "stringPainted": true
"value": 60 "value": 60
@@ -1206,16 +1354,6 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 21 3 1,growx" "value": "cell 1 21 3 1,growx"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "indeterminateCheckBox"
"text": "indeterminate"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "indeterminateProgress", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 21"
} )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "toolTipLabel" name: "toolTipLabel"
"text": "JToolTip:" "text": "JToolTip:"
@@ -1297,27 +1435,27 @@ new FormModel {
} ) } )
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
name: "toolBar3" name: "toolBar3"
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button26" name: "button26"
"icon": #SwingIcon1 "icon": #SwingIcon1
"$client.JButton.buttonType": "square" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType square
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button27" name: "button27"
"icon": #SwingIcon2 "icon": #SwingIcon2
"$client.JButton.buttonType": "square" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType square
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton23" name: "toggleButton23"
"icon": #SwingIcon4 "icon": #SwingIcon4
"selected": true "selected": true
"$client.JButton.buttonType": "square" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType square
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton24" name: "toggleButton24"
"icon": #SwingIcon5 "icon": #SwingIcon5
"selected": true "selected": true
"$client.JButton.buttonType": "square" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType square
} ) } )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 23 5 1" "value": "cell 1 23 5 1"
@@ -1330,27 +1468,27 @@ new FormModel {
} ) } )
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
name: "toolBar4" name: "toolBar4"
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button28" name: "button28"
"icon": #SwingIcon1 "icon": #SwingIcon1
"$client.JButton.buttonType": "roundRect" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType roundRect
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatButton" ) {
name: "button29" name: "button29"
"icon": #SwingIcon2 "icon": #SwingIcon2
"$client.JButton.buttonType": "roundRect" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType roundRect
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton25" name: "toggleButton25"
"icon": #SwingIcon4 "icon": #SwingIcon4
"selected": true "selected": true
"$client.JButton.buttonType": "roundRect" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType roundRect
} ) } )
add( new FormComponent( "javax.swing.JToggleButton" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatToggleButton" ) {
name: "toggleButton26" name: "toggleButton26"
"icon": #SwingIcon5 "icon": #SwingIcon5
"selected": true "selected": true
"$client.JButton.buttonType": "roundRect" "buttonType": enum com.formdev.flatlaf.extras.components.FlatButton$ButtonType roundRect
} ) } )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 23 5 1" "value": "cell 1 23 5 1"

View File

@@ -19,11 +19,12 @@ package com.formdev.flatlaf.testing;
import static com.formdev.flatlaf.FlatClientProperties.*; import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.function.BiConsumer;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.*; import javax.swing.border.*;
import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.extras.TriStateCheckBox; import com.formdev.flatlaf.extras.components.FlatTabbedPane;
import com.formdev.flatlaf.extras.components.FlatTabbedPane.*;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
import com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon; import com.formdev.flatlaf.icons.FlatInternalFrameCloseIcon;
import com.formdev.flatlaf.util.ScaledImageIcon; import com.formdev.flatlaf.util.ScaledImageIcon;
import com.jgoodies.forms.layout.*; import com.jgoodies.forms.layout.*;
@@ -46,11 +47,21 @@ public class FlatContainerTest
public FlatContainerTest() { public FlatContainerTest() {
initComponents(); initComponents();
tabPlacementField.init( TabPlacement.class, true );
iconPlacementField.init( TabIconPlacement.class, true );
tabsPopupPolicyField.init( TabsPopupPolicy.class, true );
scrollButtonsPolicyField.init( ScrollButtonsPolicy.class, true );
scrollButtonsPlacementField.init( ScrollButtonsPlacement.class, true );
tabAreaAlignmentField.init( TabAreaAlignment.class, true );
tabAlignmentField.init( TabAlignment.class, true );
tabWidthModeField.init( TabWidthMode.class, true );
tabCountChanged(); tabCountChanged();
tabsClosableCheckBox.setSelected( true ); tabsClosableCheckBox.setSelected( true );
tabsClosableChanged(); tabsClosableChanged();
putTabbedPanesClientProperty( TABBED_PANE_TAB_CLOSE_TOOLTIPTEXT, "Close" ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabCloseToolTipText( "Close" );
tabScrollCheckBox.setSelected( true ); tabScrollCheckBox.setSelected( true );
tabScrollChanged(); tabScrollChanged();
@@ -79,7 +90,7 @@ public class FlatContainerTest
} }
private void hideTabAreaWithOneTabChanged() { private void hideTabAreaWithOneTabChanged() {
boolean hideTabAreaWithOneTab = hideTabAreaWithOneTabCheckBox.isSelected(); Boolean hideTabAreaWithOneTab = hideTabAreaWithOneTabCheckBox.isSelected() ? true : null;
putTabbedPanesClientProperty( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, hideTabAreaWithOneTab ); putTabbedPanesClientProperty( TABBED_PANE_HIDE_TAB_AREA_WITH_ONE_TAB, hideTabAreaWithOneTab );
} }
@@ -158,6 +169,7 @@ public class FlatContainerTest
setTabIcons( tabbedPane ); setTabIcons( tabbedPane );
tabIconSizeSpinner.setEnabled( tabIconsCheckBox.isSelected() ); tabIconSizeSpinner.setEnabled( tabIconsCheckBox.isSelected() );
iconPlacementField.setEnabled( tabIconsCheckBox.isSelected() );
} }
private void setTabIcons( JTabbedPane tabbedPane ) { private void setTabIcons( JTabbedPane tabbedPane ) {
@@ -182,14 +194,10 @@ public class FlatContainerTest
} }
private void iconPlacementChanged() { private void iconPlacementChanged() {
Object iconPlacement = null; TabIconPlacement value = iconPlacementField.getSelectedValue();
switch( (String) iconPlacementField.getSelectedItem() ) { int iconPlacement = (value != null) ? value.value : -1;
case "leading": iconPlacement = SwingConstants.LEADING; break; for( FlatTabbedPane tabbedPane : allTabbedPanes )
case "trailing": iconPlacement = SwingConstants.TRAILING; break; tabbedPane.setTabIconPlacement( iconPlacement );
case "top": iconPlacement = SwingConstants.TOP; break;
case "bottom": iconPlacement = SwingConstants.BOTTOM; break;
}
putTabbedPanesClientProperty( TABBED_PANE_TAB_ICON_PLACEMENT, iconPlacement );
} }
private void customBorderChanged() { private void customBorderChanged() {
@@ -252,13 +260,8 @@ public class FlatContainerTest
} }
private void tabPlacementChanged() { private void tabPlacementChanged() {
int tabPlacement = -1; TabPlacement value = tabPlacementField.getSelectedValue();
switch( (String) tabPlacementField.getSelectedItem() ) { int tabPlacement = (value != null) ? value.value : -1;
case "top": tabPlacement = SwingConstants.TOP; break;
case "bottom": tabPlacement = SwingConstants.BOTTOM; break;
case "left": tabPlacement = SwingConstants.LEFT; break;
case "right": tabPlacement = SwingConstants.RIGHT; break;
}
tabbedPane1.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.TOP ); tabbedPane1.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.TOP );
tabbedPane2.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.BOTTOM ); tabbedPane2.setTabPlacement( (tabPlacement >= 0) ? tabPlacement : SwingConstants.BOTTOM );
@@ -267,49 +270,39 @@ public class FlatContainerTest
} }
private void tabsPopupPolicyChanged() { private void tabsPopupPolicyChanged() {
String value = (String) tabsPopupPolicyField.getSelectedItem(); TabsPopupPolicy value = tabsPopupPolicyField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setTabsPopupPolicy( value );
putTabbedPanesClientProperty( TABBED_PANE_TABS_POPUP_POLICY, value );
} }
private void scrollButtonsPolicyChanged() { private void scrollButtonsPolicyChanged() {
String value = (String) scrollButtonsPolicyField.getSelectedItem(); ScrollButtonsPolicy value = scrollButtonsPolicyField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setScrollButtonsPolicy( value );
putTabbedPanesClientProperty( TABBED_PANE_SCROLL_BUTTONS_POLICY, value );
} }
private void scrollButtonsPlacementChanged() { private void scrollButtonsPlacementChanged() {
String value = (String) scrollButtonsPlacementField.getSelectedItem(); ScrollButtonsPlacement value = scrollButtonsPlacementField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setScrollButtonsPlacement( value );
putTabbedPanesClientProperty( TABBED_PANE_SCROLL_BUTTONS_PLACEMENT, value );
} }
private void tabAreaAlignmentChanged() { private void tabAreaAlignmentChanged() {
String value = (String) tabAreaAlignmentField.getSelectedItem(); TabAreaAlignment value = tabAreaAlignmentField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setTabAreaAlignment( value );
putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_ALIGNMENT, value );
} }
private void tabAlignmentChanged() { private void tabAlignmentChanged() {
String value = (String) tabAlignmentField.getSelectedItem(); TabAlignment value = tabAlignmentField.getSelectedValue();
Integer tabAlignment = null; for( FlatTabbedPane tabbedPane : allTabbedPanes )
switch( value ) { tabbedPane.setTabAlignment( value );
case "center": tabAlignment = SwingConstants.CENTER; break;
case "leading": tabAlignment = SwingConstants.LEADING; break;
case "trailing": tabAlignment = SwingConstants.TRAILING; break;
}
putTabbedPanesClientProperty( TABBED_PANE_TAB_ALIGNMENT, tabAlignment );
} }
private void tabWidthModeChanged() { private void tabWidthModeChanged() {
String value = (String) tabWidthModeField.getSelectedItem(); TabWidthMode value = tabWidthModeField.getSelectedValue();
if( "default".equals( value ) ) for( FlatTabbedPane tabbedPane : allTabbedPanes )
value = null; tabbedPane.setTabWidthMode( value );
putTabbedPanesClientProperty( TABBED_PANE_TAB_WIDTH_MODE, value );
} }
private void tabBackForegroundChanged() { private void tabBackForegroundChanged() {
@@ -349,65 +342,74 @@ public class FlatContainerTest
private void tabsClosableChanged() { private void tabsClosableChanged() {
boolean closable = tabsClosableCheckBox.isSelected(); boolean closable = tabsClosableCheckBox.isSelected();
putTabbedPanesClientProperty( TABBED_PANE_TAB_CLOSABLE, closable ? true : null ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabsClosable( closable );
if( closable ) { if( closable ) {
putTabbedPanesClientProperty( TABBED_PANE_TAB_CLOSE_CALLBACK, for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
(BiConsumer<JTabbedPane, Integer>) (tabbedPane, tabIndex) -> { tabbedPane.setTabCloseCallback( (tabbedPane2, tabIndex) -> {
AWTEvent e = EventQueue.getCurrentEvent(); AWTEvent e = EventQueue.getCurrentEvent();
int modifiers = (e instanceof MouseEvent) ? ((MouseEvent)e).getModifiers() : 0; int modifiers = (e instanceof MouseEvent) ? ((MouseEvent)e).getModifiers() : 0;
JOptionPane.showMessageDialog( this, "Closed tab '" + tabbedPane.getTitleAt( tabIndex ) + "'." JOptionPane.showMessageDialog( this, "Closed tab '" + tabbedPane2.getTitleAt( tabIndex ) + "'."
+ "\n\n(modifiers: " + MouseEvent.getMouseModifiersText( modifiers ) + ")", + "\n\n(modifiers: " + MouseEvent.getMouseModifiersText( modifiers ) + ")",
"Tab Closed", JOptionPane.PLAIN_MESSAGE ); "Tab Closed", JOptionPane.PLAIN_MESSAGE );
} ); } );
}
} }
} }
private void secondTabClosableChanged() { private void secondTabClosableChanged() {
Boolean value = secondTabClosableCheckBox.getValue(); Boolean closable = secondTabClosableCheckBox.getChecked();
for( JTabbedPane tabbedPane : allTabbedPanes ) { for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
if( tabbedPane.getTabCount() > 1 ) { if( tabbedPane.getTabCount() > 1 ) {
Component c = tabbedPane.getComponentAt( 1 ); if( closable != null )
((JComponent)c).putClientProperty( TABBED_PANE_TAB_CLOSABLE, value ); tabbedPane.setTabClosable( 1, closable );
else {
JComponent c = (JComponent) tabbedPane.getComponentAt( 1 );
c.putClientProperty( TABBED_PANE_TAB_CLOSABLE, null );
}
} }
} }
} }
private void tabAreaInsetsChanged() { private void tabAreaInsetsChanged() {
Insets insets = tabAreaInsetsCheckBox.isSelected() ? new Insets( 5, 5, 10, 10 ) : null; Insets insets = tabAreaInsetsCheckBox.isSelected() ? new Insets( 5, 5, 10, 10 ) : null;
putTabbedPanesClientProperty( TABBED_PANE_TAB_AREA_INSETS, insets ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabAreaInsets( insets );
} }
private void smallerTabHeightChanged() { private void smallerTabHeightChanged() {
Integer tabHeight = smallerTabHeightCheckBox.isSelected() ? 26 : null; int tabHeight = smallerTabHeightCheckBox.isSelected() ? 26 : -1;
putTabbedPanesClientProperty( TABBED_PANE_TAB_HEIGHT, tabHeight ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabHeight( tabHeight );
} }
private void smallerInsetsChanged() { private void smallerInsetsChanged() {
Insets insets = smallerInsetsCheckBox.isSelected() ? new Insets( 2, 2, 2, 2 ) : null; Insets insets = smallerInsetsCheckBox.isSelected() ? new Insets( 2, 2, 2, 2 ) : null;
putTabbedPanesClientProperty( TABBED_PANE_TAB_INSETS, insets ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setTabInsets( insets );
} }
private void secondTabWiderChanged() { private void secondTabWiderChanged() {
Insets insets = secondTabWiderCheckBox.isSelected() ? new Insets( 4, 20, 4, 20 ) : null; Insets insets = secondTabWiderCheckBox.isSelected() ? new Insets( 4, 20, 4, 20 ) : null;
for( JTabbedPane tabbedPane : allTabbedPanes ) { for( FlatTabbedPane tabbedPane : allTabbedPanes ) {
if( tabbedPane.getTabCount() > 1 ) { if( tabbedPane.getTabCount() > 1 )
Component c = tabbedPane.getComponentAt( 1 ); tabbedPane.setTabInsets( 1, insets );
((JComponent)c).putClientProperty( TABBED_PANE_TAB_INSETS, insets );
}
} }
} }
private void minimumTabWidthChanged() { private void minimumTabWidthChanged() {
Integer minimumTabWidth = minimumTabWidthCheckBox.isSelected() ? 100 : null; int minimumTabWidth = minimumTabWidthCheckBox.isSelected() ? 100 : -1;
putTabbedPanesClientProperty( TABBED_PANE_MINIMUM_TAB_WIDTH, minimumTabWidth ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setMinimumTabWidth( minimumTabWidth );
} }
private void maximumTabWidthChanged() { private void maximumTabWidthChanged() {
Integer maximumTabWidth = maximumTabWidthCheckBox.isSelected() ? 60 : null; int maximumTabWidth = maximumTabWidthCheckBox.isSelected() ? 60 : -1;
putTabbedPanesClientProperty( TABBED_PANE_MAXIMUM_TAB_WIDTH, maximumTabWidth ); for( FlatTabbedPane tabbedPane : allTabbedPanes )
tabbedPane.setMaximumTabWidth( maximumTabWidth );
} }
private void initComponents() { private void initComponents() {
@@ -424,10 +426,10 @@ public class FlatContainerTest
JPanel panel13 = new JPanel(); JPanel panel13 = new JPanel();
JLabel label4 = new JLabel(); JLabel label4 = new JLabel();
JLabel tabbedPaneLabel = new JLabel(); JLabel tabbedPaneLabel = new JLabel();
tabbedPane1 = new JTabbedPane(); tabbedPane1 = new FlatTabbedPane();
tabbedPane3 = new JTabbedPane(); tabbedPane3 = new FlatTabbedPane();
tabbedPane2 = new JTabbedPane(); tabbedPane2 = new FlatTabbedPane();
tabbedPane4 = new JTabbedPane(); tabbedPane4 = new FlatTabbedPane();
FlatTestFrame.NoRightToLeftPanel tabbedPaneControlPanel = new FlatTestFrame.NoRightToLeftPanel(); FlatTestFrame.NoRightToLeftPanel tabbedPaneControlPanel = new FlatTestFrame.NoRightToLeftPanel();
tabScrollCheckBox = new JCheckBox(); tabScrollCheckBox = new JCheckBox();
JLabel tabCountLabel = new JLabel(); JLabel tabCountLabel = new JLabel();
@@ -436,24 +438,24 @@ public class FlatContainerTest
htmlTabsCheckBox = new JCheckBox(); htmlTabsCheckBox = new JCheckBox();
multiLineTabsCheckBox = new JCheckBox(); multiLineTabsCheckBox = new JCheckBox();
JLabel tabsPopupPolicyLabel = new JLabel(); JLabel tabsPopupPolicyLabel = new JLabel();
tabsPopupPolicyField = new JComboBox<>(); tabsPopupPolicyField = new FlatTestEnumComboBox<>();
tabBackForegroundCheckBox = new JCheckBox(); tabBackForegroundCheckBox = new JCheckBox();
JLabel scrollButtonsPolicyLabel = new JLabel(); JLabel scrollButtonsPolicyLabel = new JLabel();
scrollButtonsPolicyField = new JComboBox<>(); scrollButtonsPolicyField = new FlatTestEnumComboBox<>();
tabIconsCheckBox = new JCheckBox(); tabIconsCheckBox = new JCheckBox();
tabIconSizeSpinner = new JSpinner(); tabIconSizeSpinner = new JSpinner();
iconPlacementField = new JComboBox<>(); iconPlacementField = new FlatTestEnumComboBox<>();
JLabel scrollButtonsPlacementLabel = new JLabel(); JLabel scrollButtonsPlacementLabel = new JLabel();
scrollButtonsPlacementField = new JComboBox<>(); scrollButtonsPlacementField = new FlatTestEnumComboBox<>();
tabsClosableCheckBox = new JCheckBox(); tabsClosableCheckBox = new JCheckBox();
JLabel tabPlacementLabel = new JLabel(); JLabel tabPlacementLabel = new JLabel();
tabPlacementField = new JComboBox<>(); tabPlacementField = new FlatTestEnumComboBox<>();
secondTabClosableCheckBox = new TriStateCheckBox(); secondTabClosableCheckBox = new FlatTriStateCheckBox();
JLabel tabAreaAlignmentLabel = new JLabel(); JLabel tabAreaAlignmentLabel = new JLabel();
tabAreaAlignmentField = new JComboBox<>(); tabAreaAlignmentField = new FlatTestEnumComboBox<>();
tabAlignmentField = new JComboBox<>(); tabAlignmentField = new FlatTestEnumComboBox<>();
JLabel tabWidthModeLabel = new JLabel(); JLabel tabWidthModeLabel = new JLabel();
tabWidthModeField = new JComboBox<>(); tabWidthModeField = new FlatTestEnumComboBox<>();
leadingComponentCheckBox = new JCheckBox(); leadingComponentCheckBox = new JCheckBox();
customBorderCheckBox = new JCheckBox(); customBorderCheckBox = new JCheckBox();
tabAreaInsetsCheckBox = new JCheckBox(); tabAreaInsetsCheckBox = new JCheckBox();
@@ -623,11 +625,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabsPopupPolicyLabel, "cell 0 1"); tabbedPaneControlPanel.add(tabsPopupPolicyLabel, "cell 0 1");
//---- tabsPopupPolicyField ---- //---- tabsPopupPolicyField ----
tabsPopupPolicyField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"asNeeded",
"never"
}));
tabsPopupPolicyField.addActionListener(e -> tabsPopupPolicyChanged()); tabsPopupPolicyField.addActionListener(e -> tabsPopupPolicyChanged());
tabbedPaneControlPanel.add(tabsPopupPolicyField, "cell 1 1"); tabbedPaneControlPanel.add(tabsPopupPolicyField, "cell 1 1");
@@ -641,12 +638,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(scrollButtonsPolicyLabel, "cell 0 2"); tabbedPaneControlPanel.add(scrollButtonsPolicyLabel, "cell 0 2");
//---- scrollButtonsPolicyField ---- //---- scrollButtonsPolicyField ----
scrollButtonsPolicyField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"asNeededSingle",
"asNeeded",
"never"
}));
scrollButtonsPolicyField.addActionListener(e -> scrollButtonsPolicyChanged()); scrollButtonsPolicyField.addActionListener(e -> scrollButtonsPolicyChanged());
tabbedPaneControlPanel.add(scrollButtonsPolicyField, "cell 1 2"); tabbedPaneControlPanel.add(scrollButtonsPolicyField, "cell 1 2");
@@ -662,12 +653,7 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabIconSizeSpinner, "cell 2 2"); tabbedPaneControlPanel.add(tabIconSizeSpinner, "cell 2 2");
//---- iconPlacementField ---- //---- iconPlacementField ----
iconPlacementField.setModel(new DefaultComboBoxModel<>(new String[] { iconPlacementField.setEnabled(false);
"leading",
"trailing",
"top",
"bottom"
}));
iconPlacementField.addActionListener(e -> iconPlacementChanged()); iconPlacementField.addActionListener(e -> iconPlacementChanged());
tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2"); tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2");
@@ -676,11 +662,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(scrollButtonsPlacementLabel, "cell 0 3"); tabbedPaneControlPanel.add(scrollButtonsPlacementLabel, "cell 0 3");
//---- scrollButtonsPlacementField ---- //---- scrollButtonsPlacementField ----
scrollButtonsPlacementField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"both",
"trailing"
}));
scrollButtonsPlacementField.addActionListener(e -> scrollButtonsPlacementChanged()); scrollButtonsPlacementField.addActionListener(e -> scrollButtonsPlacementChanged());
tabbedPaneControlPanel.add(scrollButtonsPlacementField, "cell 1 3"); tabbedPaneControlPanel.add(scrollButtonsPlacementField, "cell 1 3");
@@ -694,13 +675,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabPlacementLabel, "cell 0 4"); tabbedPaneControlPanel.add(tabPlacementLabel, "cell 0 4");
//---- tabPlacementField ---- //---- tabPlacementField ----
tabPlacementField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"top",
"bottom",
"left",
"right"
}));
tabPlacementField.addActionListener(e -> tabPlacementChanged()); tabPlacementField.addActionListener(e -> tabPlacementChanged());
tabbedPaneControlPanel.add(tabPlacementField, "cell 1 4"); tabbedPaneControlPanel.add(tabPlacementField, "cell 1 4");
@@ -714,23 +688,10 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabAreaAlignmentLabel, "cell 0 5"); tabbedPaneControlPanel.add(tabAreaAlignmentLabel, "cell 0 5");
//---- tabAreaAlignmentField ---- //---- tabAreaAlignmentField ----
tabAreaAlignmentField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"leading",
"trailing",
"center",
"fill"
}));
tabAreaAlignmentField.addActionListener(e -> tabAreaAlignmentChanged()); tabAreaAlignmentField.addActionListener(e -> tabAreaAlignmentChanged());
tabbedPaneControlPanel.add(tabAreaAlignmentField, "cell 1 5"); tabbedPaneControlPanel.add(tabAreaAlignmentField, "cell 1 5");
//---- tabAlignmentField ---- //---- tabAlignmentField ----
tabAlignmentField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"leading",
"trailing",
"center"
}));
tabAlignmentField.addActionListener(e -> tabAlignmentChanged()); tabAlignmentField.addActionListener(e -> tabAlignmentChanged());
tabbedPaneControlPanel.add(tabAlignmentField, "cell 1 5"); tabbedPaneControlPanel.add(tabAlignmentField, "cell 1 5");
@@ -739,12 +700,6 @@ public class FlatContainerTest
tabbedPaneControlPanel.add(tabWidthModeLabel, "cell 2 5"); tabbedPaneControlPanel.add(tabWidthModeLabel, "cell 2 5");
//---- tabWidthModeField ---- //---- tabWidthModeField ----
tabWidthModeField.setModel(new DefaultComboBoxModel<>(new String[] {
"default",
"preferred",
"equal",
"compact"
}));
tabWidthModeField.addActionListener(e -> tabWidthModeChanged()); tabWidthModeField.addActionListener(e -> tabWidthModeChanged());
tabbedPaneControlPanel.add(tabWidthModeField, "cell 2 5"); tabbedPaneControlPanel.add(tabWidthModeField, "cell 2 5");
@@ -818,32 +773,32 @@ public class FlatContainerTest
add(panel9, "cell 0 0"); add(panel9, "cell 0 0");
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
allTabbedPanes = new JTabbedPane[] { tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 }; allTabbedPanes = new FlatTabbedPane[] { tabbedPane1, tabbedPane2, tabbedPane3, tabbedPane4 };
} }
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JTabbedPane tabbedPane1; private FlatTabbedPane tabbedPane1;
private JTabbedPane tabbedPane3; private FlatTabbedPane tabbedPane3;
private JTabbedPane tabbedPane2; private FlatTabbedPane tabbedPane2;
private JTabbedPane tabbedPane4; private FlatTabbedPane tabbedPane4;
private JCheckBox tabScrollCheckBox; private JCheckBox tabScrollCheckBox;
private JSpinner tabCountSpinner; private JSpinner tabCountSpinner;
private JCheckBox customTabsCheckBox; private JCheckBox customTabsCheckBox;
private JCheckBox htmlTabsCheckBox; private JCheckBox htmlTabsCheckBox;
private JCheckBox multiLineTabsCheckBox; private JCheckBox multiLineTabsCheckBox;
private JComboBox<String> tabsPopupPolicyField; private FlatTestEnumComboBox<TabsPopupPolicy> tabsPopupPolicyField;
private JCheckBox tabBackForegroundCheckBox; private JCheckBox tabBackForegroundCheckBox;
private JComboBox<String> scrollButtonsPolicyField; private FlatTestEnumComboBox<ScrollButtonsPolicy> scrollButtonsPolicyField;
private JCheckBox tabIconsCheckBox; private JCheckBox tabIconsCheckBox;
private JSpinner tabIconSizeSpinner; private JSpinner tabIconSizeSpinner;
private JComboBox<String> iconPlacementField; private FlatTestEnumComboBox<TabIconPlacement> iconPlacementField;
private JComboBox<String> scrollButtonsPlacementField; private FlatTestEnumComboBox<ScrollButtonsPlacement> scrollButtonsPlacementField;
private JCheckBox tabsClosableCheckBox; private JCheckBox tabsClosableCheckBox;
private JComboBox<String> tabPlacementField; private FlatTestEnumComboBox<TabPlacement> tabPlacementField;
private TriStateCheckBox secondTabClosableCheckBox; private FlatTriStateCheckBox secondTabClosableCheckBox;
private JComboBox<String> tabAreaAlignmentField; private FlatTestEnumComboBox<TabAreaAlignment> tabAreaAlignmentField;
private JComboBox<String> tabAlignmentField; private FlatTestEnumComboBox<TabAlignment> tabAlignmentField;
private JComboBox<String> tabWidthModeField; private FlatTestEnumComboBox<TabWidthMode> tabWidthModeField;
private JCheckBox leadingComponentCheckBox; private JCheckBox leadingComponentCheckBox;
private JCheckBox customBorderCheckBox; private JCheckBox customBorderCheckBox;
private JCheckBox tabAreaInsetsCheckBox; private JCheckBox tabAreaInsetsCheckBox;
@@ -859,7 +814,37 @@ public class FlatContainerTest
private JCheckBox hideTabAreaWithOneTabCheckBox; private JCheckBox hideTabAreaWithOneTabCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
private JTabbedPane[] allTabbedPanes; private FlatTabbedPane[] allTabbedPanes;
//---- enum TabPlacement --------------------------------------------------
enum TabPlacement {
top( SwingConstants.TOP ),
bottom( SwingConstants.BOTTOM ),
left( SwingConstants.LEFT ),
right( SwingConstants.RIGHT );
public final int value;
TabPlacement( int value ) {
this.value = value;
}
};
//---- enum TabIconPlacement ----------------------------------------------
enum TabIconPlacement {
leading( SwingConstants.LEADING ),
trailing( SwingConstants.TRAILING ),
top( SwingConstants.TOP ),
bottom( SwingConstants.BOTTOM );
public final int value;
TabIconPlacement( int value ) {
this.value = value;
}
};
//---- class Tab1Panel ---------------------------------------------------- //---- class Tab1Panel ----------------------------------------------------

View File

@@ -91,7 +91,7 @@ new FormModel {
"gridX": 1 "gridX": 1
"gridY": 5 "gridY": 5
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "com.formdev.flatlaf.extras.components.FlatTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane1" name: "tabbedPane1"
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
@@ -100,7 +100,7 @@ new FormModel {
"gridX": 1 "gridX": 1
"gridY": 7 "gridY": 7
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "com.formdev.flatlaf.extras.components.FlatTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane3" name: "tabbedPane3"
"tabPlacement": 2 "tabPlacement": 2
auxiliary() { auxiliary() {
@@ -110,7 +110,7 @@ new FormModel {
"gridX": 3 "gridX": 3
"gridY": 7 "gridY": 7
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "com.formdev.flatlaf.extras.components.FlatTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane2" name: "tabbedPane2"
"tabPlacement": 3 "tabPlacement": 3
auxiliary() { auxiliary() {
@@ -119,7 +119,7 @@ new FormModel {
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 9 "gridY": 9
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "com.formdev.flatlaf.extras.components.FlatTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "tabbedPane4" name: "tabbedPane4"
"tabPlacement": 4 "tabPlacement": 4
auxiliary() { auxiliary() {
@@ -202,17 +202,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1" "value": "cell 0 1"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabsPopupPolicyField" name: "tabsPopupPolicyField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "asNeeded" )
addElement( "never" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabsPopupPolicy"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabsPopupPolicyChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabsPopupPolicyChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -234,18 +228,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2" "value": "cell 0 2"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "scrollButtonsPolicyField" name: "scrollButtonsPolicyField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "asNeededSingle" )
addElement( "asNeeded" )
addElement( "never" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "ScrollButtonsPolicy"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPolicyChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPolicyChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -280,18 +267,12 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2" "value": "cell 2 2"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "iconPlacementField" name: "iconPlacementField"
"model": new javax.swing.DefaultComboBoxModel { "enabled": false
selectedItem: "leading"
addElement( "leading" )
addElement( "trailing" )
addElement( "top" )
addElement( "bottom" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabIconPlacement"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "iconPlacementChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "iconPlacementChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -303,17 +284,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3" "value": "cell 0 3"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "scrollButtonsPlacementField" name: "scrollButtonsPlacementField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "both" )
addElement( "trailing" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "ScrollButtonsPlacement"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPlacementChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scrollButtonsPlacementChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -335,25 +310,17 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4" "value": "cell 0 4"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabPlacementField" name: "tabPlacementField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "top" )
addElement( "bottom" )
addElement( "left" )
addElement( "right" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabPlacement"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabPlacementChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabPlacementChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4" "value": "cell 1 4"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "secondTabClosableCheckBox" name: "secondTabClosableCheckBox"
"text": "Second Tab closable" "text": "Second Tab closable"
auxiliary() { auxiliary() {
@@ -369,36 +336,21 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5" "value": "cell 0 5"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabAreaAlignmentField" name: "tabAreaAlignmentField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "leading" )
addElement( "trailing" )
addElement( "center" )
addElement( "fill" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabAreaAlignment"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAreaAlignmentChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAreaAlignmentChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5" "value": "cell 1 5"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabAlignmentField" name: "tabAlignmentField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "leading" )
addElement( "trailing" )
addElement( "center" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabAlignment"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAlignmentChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAlignmentChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
@@ -410,18 +362,11 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 5" "value": "cell 2 5"
} ) } )
add( new FormComponent( "javax.swing.JComboBox" ) { add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) {
name: "tabWidthModeField" name: "tabWidthModeField"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "default"
addElement( "default" )
addElement( "preferred" )
addElement( "equal" )
addElement( "compact" )
}
auxiliary() { auxiliary() {
"JavaCodeGenerator.variableLocal": false "JavaCodeGenerator.variableLocal": false
"JavaCodeGenerator.typeParameters": "String" "JavaCodeGenerator.typeParameters": "TabWidthMode"
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabWidthModeChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabWidthModeChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {

View File

@@ -21,6 +21,7 @@ import javax.swing.*;
import com.formdev.flatlaf.util.StringUtils; import com.formdev.flatlaf.util.StringUtils;
import com.formdev.flatlaf.util.UIScale; import com.formdev.flatlaf.util.UIScale;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
import org.jdesktop.swingx.*;
/** /**
* @author Karl Tauber * @author Karl Tauber
@@ -89,6 +90,12 @@ public class FlatHtmlTest
label14 = new JLabel(); label14 = new JLabel();
label15 = new JLabel(); label15 = new JLabel();
label16 = new JLabel(); label16 = new JLabel();
label17 = new JLabel();
comboBox1 = new JComboBox<>();
comboBox2 = new JComboBox<>();
label18 = new JLabel();
xHyperlink1 = new JXHyperlink();
xHyperlink2 = new JXHyperlink();
label1 = new JLabel(); label1 = new JLabel();
scrollPane15 = new JScrollPane(); scrollPane15 = new JScrollPane();
editorPane1 = new JEditorPane(); editorPane1 = new JEditorPane();
@@ -150,6 +157,8 @@ public class FlatHtmlTest
"[]" + "[]" +
"[]" + "[]" +
"[]" + "[]" +
"[]" +
"[]" +
"[]")); "[]"));
//---- label5 ---- //---- label5 ----
@@ -283,6 +292,38 @@ public class FlatHtmlTest
label16.setText("(move mouse here)"); label16.setText("(move mouse here)");
label16.setToolTipText("Some text"); label16.setToolTipText("Some text");
panel1.add(label16, "cell 2 9"); panel1.add(label16, "cell 2 9");
//---- label17 ----
label17.setText("JComboBox:");
panel1.add(label17, "cell 0 10");
//---- comboBox1 ----
comboBox1.setModel(new DefaultComboBoxModel<>(new String[] {
"<html>Some <b>Bold</b> Text",
"abc",
"def"
}));
panel1.add(comboBox1, "cell 1 10");
//---- comboBox2 ----
comboBox2.setModel(new DefaultComboBoxModel<>(new String[] {
"Some Text",
"abc",
"def"
}));
panel1.add(comboBox2, "cell 2 10");
//---- label18 ----
label18.setText("JXHyperlink:");
panel1.add(label18, "cell 0 11");
//---- xHyperlink1 ----
xHyperlink1.setText("<html>Some <b>Bold</b> Text");
panel1.add(xHyperlink1, "cell 1 11");
//---- xHyperlink2 ----
xHyperlink2.setText("Some text");
panel1.add(xHyperlink2, "cell 2 11");
} }
add(panel1, "cell 4 0 1 3,aligny top,growy 0"); add(panel1, "cell 4 0 1 3,aligny top,growy 0");
@@ -400,6 +441,12 @@ public class FlatHtmlTest
private JLabel label14; private JLabel label14;
private JLabel label15; private JLabel label15;
private JLabel label16; private JLabel label16;
private JLabel label17;
private JComboBox<String> comboBox1;
private JComboBox<String> comboBox2;
private JLabel label18;
private JXHyperlink xHyperlink1;
private JXHyperlink xHyperlink2;
private JLabel label1; private JLabel label1;
private JScrollPane scrollPane15; private JScrollPane scrollPane15;
private JEditorPane editorPane1; private JEditorPane editorPane1;

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8" JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
new FormModel { new FormModel {
contentType: "form/swing" contentType: "form/swing"
@@ -36,7 +36,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 0,hidemode 3" "$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[fill][fill][fill]" "$columnConstraints": "[fill][fill][fill]"
"$rowConstraints": "[][][][][][][][][][]" "$rowConstraints": "[][][][][][][][][][][][]"
} ) { } ) {
name: "panel1" name: "panel1"
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
@@ -227,6 +227,52 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 9" "value": "cell 2 9"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label17"
"text": "JComboBox:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 10"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox1"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "<html>Some <b>Bold</b> Text"
addElement( "<html>Some <b>Bold</b> Text" )
addElement( "abc" )
addElement( "def" )
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 10"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox2"
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "Some Text"
addElement( "Some Text" )
addElement( "abc" )
addElement( "def" )
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 10"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label18"
"text": "JXHyperlink:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 11"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink1"
"text": "<html>Some <b>Bold</b> Text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 11"
} )
add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) {
name: "xHyperlink2"
"text": "Some text"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 11"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 0 1 3,aligny top,growy 0" "value": "cell 4 0 1 3,aligny top,growy 0"
} ) } )
@@ -296,7 +342,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( 695, 755 ) "size": new java.awt.Dimension( 820, 755 )
} ) } )
} }
} }

View File

@@ -19,7 +19,7 @@ package com.formdev.flatlaf.testing;
import java.awt.*; import java.awt.*;
import java.beans.PropertyVetoException; import java.beans.PropertyVetoException;
import javax.swing.*; import javax.swing.*;
import com.formdev.flatlaf.extras.TriStateCheckBox; import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
import com.formdev.flatlaf.icons.FlatFileViewFloppyDriveIcon; import com.formdev.flatlaf.icons.FlatFileViewFloppyDriveIcon;
import com.formdev.flatlaf.util.UIScale; import com.formdev.flatlaf.util.UIScale;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
@@ -63,9 +63,9 @@ public class FlatInternalFrameTest
maximizableCheckBox.isSelected(), maximizableCheckBox.isSelected(),
iconifiableCheckBox.isSelected() ); iconifiableCheckBox.isSelected() );
if( iconCheckBox.getState() == TriStateCheckBox.State.SELECTED ) if( iconCheckBox.getState() == FlatTriStateCheckBox.State.SELECTED )
internalFrame.setFrameIcon( new FlatFileViewFloppyDriveIcon() ); internalFrame.setFrameIcon( new FlatFileViewFloppyDriveIcon() );
else if( iconCheckBox.getState() == TriStateCheckBox.State.UNSELECTED ) else if( iconCheckBox.getState() == FlatTriStateCheckBox.State.UNSELECTED )
internalFrame.setFrameIcon( null ); internalFrame.setFrameIcon( null );
if( menuBarCheckBox.isSelected() ) { if( menuBarCheckBox.isSelected() ) {
@@ -115,7 +115,7 @@ public class FlatInternalFrameTest
closableCheckBox = new JCheckBox(); closableCheckBox = new JCheckBox();
iconifiableCheckBox = new JCheckBox(); iconifiableCheckBox = new JCheckBox();
maximizableCheckBox = new JCheckBox(); maximizableCheckBox = new JCheckBox();
iconCheckBox = new TriStateCheckBox(); iconCheckBox = new FlatTriStateCheckBox();
menuBarCheckBox = new JCheckBox(); menuBarCheckBox = new JCheckBox();
titleLabel = new JLabel(); titleLabel = new JLabel();
titleField = new JTextField(); titleField = new JTextField();
@@ -207,7 +207,7 @@ public class FlatInternalFrameTest
private JCheckBox closableCheckBox; private JCheckBox closableCheckBox;
private JCheckBox iconifiableCheckBox; private JCheckBox iconifiableCheckBox;
private JCheckBox maximizableCheckBox; private JCheckBox maximizableCheckBox;
private TriStateCheckBox iconCheckBox; private FlatTriStateCheckBox iconCheckBox;
private JCheckBox menuBarCheckBox; private JCheckBox menuBarCheckBox;
private JLabel titleLabel; private JLabel titleLabel;
private JTextField titleField; private JTextField titleField;

View File

@@ -50,7 +50,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1,alignx left,growx 0" "value": "cell 1 1,alignx left,growx 0"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "iconCheckBox" name: "iconCheckBox"
"text": "Frame icon" "text": "Frame icon"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {

View File

@@ -180,7 +180,7 @@ public class FlatPaintingStringTest
@Override @Override
protected void paintComponent( Graphics g ) { protected void paintComponent( Graphics g ) {
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
FlatUIUtils.setRenderingHints( g2 ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g2 );
// simulate component y position at a fraction // simulate component y position at a fraction
if( scaleFactor > 1 && SystemInfo.isJava_9_orLater ) if( scaleFactor > 1 && SystemInfo.isJava_9_orLater )
@@ -241,6 +241,8 @@ public class FlatPaintingStringTest
double textY = t.getTranslateY() + (y * t.getScaleY()); double textY = t.getTranslateY() + (y * t.getScaleY());
setToolTipText( textY + " + " + yCorrection + " = " + (textY + yCorrection) ); setToolTipText( textY + " + " + yCorrection + " = " + (textY + yCorrection) );
} }
FlatUIUtils.resetRenderingHints( g2, oldRenderingHints );
} }
private int scale( int value ) { private int scale( int value ) {

View File

@@ -471,7 +471,7 @@ public class FlatPaintingTest
@Override @Override
protected void paintComponent( Graphics g ) { protected void paintComponent( Graphics g ) {
Graphics2D g2 = (Graphics2D) g; Graphics2D g2 = (Graphics2D) g;
FlatUIUtils.setRenderingHints( g2 ); Object[] oldRenderingHints = FlatUIUtils.setRenderingHints( g2 );
g2.scale( scale, scale ); g2.scale( scale, scale );
g2.translate( 1, 1 ); g2.translate( 1, 1 );
@@ -503,6 +503,8 @@ public class FlatPaintingTest
g2d.setColor( Color.magenta ); g2d.setColor( Color.magenta );
g2d.drawRect( x2 - gap, y2 - gap, width2 + (gap * 2) - 1, height2 + (gap * 2) - 1 ); g2d.drawRect( x2 - gap, y2 - gap, width2 + (gap * 2) - 1, height2 + (gap * 2) - 1 );
} ); } );
FlatUIUtils.resetRenderingHints( g2, oldRenderingHints );
} }
} }
} }

View File

@@ -0,0 +1,113 @@
/*
* Copyright 2020 FormDev Software GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.formdev.flatlaf.testing;
import java.awt.Component;
import java.util.Objects;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.plaf.basic.BasicComboBoxRenderer;
/**
* @author Karl Tauber
*/
public class FlatTestEnumComboBox<E>
extends JComboBox<E>
{
@SuppressWarnings( "unchecked" )
public void init( Class<E> enumType, boolean supportDefault ) {
setRenderer( new EnumComboBoxRenderer() );
setModel( new EnumComboBoxModel<>( enumType, supportDefault ) );
}
@SuppressWarnings( "unchecked" )
public E getSelectedValue() {
return (E) getSelectedItem();
}
@Override
public int getSelectedIndex() {
if( getSelectedItem() == null && getItemCount() > 0 && getItemAt( 0 ) == null )
return 0;
return super.getSelectedIndex();
}
//---- class EnumComboBoxRenderer -----------------------------------------
public static class EnumComboBoxRenderer
extends BasicComboBoxRenderer
{
@SuppressWarnings( "rawtypes" )
@Override
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus ) {
setEnabled( value != null || isSelected );
if( value == null )
value = "(default)";
return super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
}
}
//---- class EnumComboBoxModel --------------------------------------------
public static class EnumComboBoxModel<E>
extends AbstractListModel<E>
implements ComboBoxModel<E>
{
private final boolean supportDefault;
private final E[] values;
private Object selectedItem;
public EnumComboBoxModel( Class<E> enumType, boolean supportDefault ) {
this.supportDefault = supportDefault;
values = enumType.getEnumConstants();
if( !supportDefault )
selectedItem = values[0];
}
@Override
public int getSize() {
return values.length + (supportDefault ? 1 : 0);
}
@Override
public E getElementAt( int index ) {
if( supportDefault ) {
if( index == 0 )
return null;
index--;
}
return values[index];
}
@Override
public Object getSelectedItem() {
return selectedItem;
}
@Override
public void setSelectedItem( Object anItem ) {
if( !Objects.equals( selectedItem, anItem ) ) {
selectedItem = anItem;
fireContentsChanged( this, -1, -1 );
}
}
}
}

View File

@@ -43,7 +43,8 @@ import com.formdev.flatlaf.demo.LookAndFeelsComboBox;
import com.formdev.flatlaf.demo.DemoPrefs; import com.formdev.flatlaf.demo.DemoPrefs;
import com.formdev.flatlaf.demo.intellijthemes.*; import com.formdev.flatlaf.demo.intellijthemes.*;
import com.formdev.flatlaf.extras.*; import com.formdev.flatlaf.extras.*;
import com.formdev.flatlaf.extras.TriStateCheckBox.State; import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox.State;
import com.formdev.flatlaf.ui.FlatUIUtils; 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 com.formdev.flatlaf.util.UIScale;
@@ -67,6 +68,9 @@ public class FlatTestFrame
public boolean applyComponentOrientationToFrame; public boolean applyComponentOrientationToFrame;
public static FlatTestFrame create( String[] args, String title ) { public static FlatTestFrame create( String[] args, String title ) {
// disable text antialiasing
// System.setProperty( "awt.useSystemAAFontSettings", "off" );
DemoPrefs.init( PREFS_ROOT_PATH ); DemoPrefs.init( PREFS_ROOT_PATH );
// set scale factor // set scale factor
@@ -660,7 +664,7 @@ public class FlatTestFrame
inspectCheckBox = new JCheckBox(); inspectCheckBox = new JCheckBox();
explicitColorsCheckBox = new JCheckBox(); explicitColorsCheckBox = new JCheckBox();
backgroundCheckBox = new JCheckBox(); backgroundCheckBox = new JCheckBox();
opaqueTriStateCheckBox = new TriStateCheckBox(); opaqueTriStateCheckBox = new FlatTriStateCheckBox();
sizeVariantComboBox = new JComboBox<>(); sizeVariantComboBox = new JComboBox<>();
closeButton = new JButton(); closeButton = new JButton();
themesPanel = new IJThemesPanel(); themesPanel = new IJThemesPanel();
@@ -805,7 +809,7 @@ public class FlatTestFrame
private JCheckBox inspectCheckBox; private JCheckBox inspectCheckBox;
private JCheckBox explicitColorsCheckBox; private JCheckBox explicitColorsCheckBox;
private JCheckBox backgroundCheckBox; private JCheckBox backgroundCheckBox;
private TriStateCheckBox opaqueTriStateCheckBox; private FlatTriStateCheckBox opaqueTriStateCheckBox;
private JComboBox<String> sizeVariantComboBox; private JComboBox<String> sizeVariantComboBox;
private JButton closeButton; private JButton closeButton;
private IJThemesPanel themesPanel; private IJThemesPanel themesPanel;

View File

@@ -107,7 +107,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 0" "value": "cell 7 0"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "opaqueTriStateCheckBox" name: "opaqueTriStateCheckBox"
"text": "opaque" "text": "opaque"
"mnemonic": 79 "mnemonic": 79

View File

@@ -18,6 +18,7 @@ package com.formdev.flatlaf.testing.extras;
import javax.swing.*; import javax.swing.*;
import com.formdev.flatlaf.extras.*; import com.formdev.flatlaf.extras.*;
import com.formdev.flatlaf.extras.components.*;
import com.formdev.flatlaf.testing.*; import com.formdev.flatlaf.testing.*;
import net.miginfocom.swing.*; import net.miginfocom.swing.*;
@@ -37,8 +38,8 @@ public class FlatExtrasTest
public FlatExtrasTest() { public FlatExtrasTest() {
initComponents(); initComponents();
triStateLabel1.setText( triStateCheckBox1.getState().toString() ); triStateCheckBox1Changed();
triStateLabel2.setText( triStateCheckBox2.getState().toString() ); triStateCheckBox2Changed();
addSVGIcon( "actions/copy.svg" ); addSVGIcon( "actions/copy.svg" );
addSVGIcon( "actions/colors.svg" ); addSVGIcon( "actions/colors.svg" );
@@ -89,6 +90,10 @@ public class FlatExtrasTest
triStateLabel2.setText( triStateCheckBox2.getState().toString() ); triStateLabel2.setText( triStateCheckBox2.getState().toString() );
} }
private void triStateCheckBox3Changed() {
triStateLabel3.setText( triStateCheckBox3.getState().toString() );
}
private void disabledChanged() { private void disabledChanged() {
boolean enabled = !disabledCheckBox.isSelected(); boolean enabled = !disabledCheckBox.isSelected();
@@ -117,9 +122,11 @@ public class FlatExtrasTest
private void initComponents() { private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
label1 = new JLabel(); label1 = new JLabel();
triStateCheckBox1 = new TriStateCheckBox(); triStateCheckBox1 = new FlatTriStateCheckBox();
triStateLabel1 = new JLabel(); triStateLabel1 = new JLabel();
triStateCheckBox2 = new TriStateCheckBox(); triStateCheckBox3 = new FlatTriStateCheckBox();
triStateLabel3 = new JLabel();
triStateCheckBox2 = new FlatTriStateCheckBox();
triStateLabel2 = new JLabel(); triStateLabel2 = new JLabel();
label2 = new JLabel(); label2 = new JLabel();
svgIconsPanel = new JPanel(); svgIconsPanel = new JPanel();
@@ -165,20 +172,31 @@ public class FlatExtrasTest
triStateLabel1.setEnabled(false); triStateLabel1.setEnabled(false);
add(triStateLabel1, "cell 2 0,gapx 30"); add(triStateLabel1, "cell 2 0,gapx 30");
//---- triStateCheckBox3 ----
triStateCheckBox3.setText("alt state cycle order");
triStateCheckBox3.setAltStateCycleOrder(true);
triStateCheckBox3.addActionListener(e -> triStateCheckBox3Changed());
add(triStateCheckBox3, "cell 1 1");
//---- triStateLabel3 ----
triStateLabel3.setText("text");
triStateLabel3.setEnabled(false);
add(triStateLabel3, "cell 2 1,gapx 30");
//---- triStateCheckBox2 ---- //---- triStateCheckBox2 ----
triStateCheckBox2.setText("third state disabled"); triStateCheckBox2.setText("third state disabled");
triStateCheckBox2.setThirdStateEnabled(false); triStateCheckBox2.setAllowIndeterminate(false);
triStateCheckBox2.addActionListener(e -> triStateCheckBox2Changed()); triStateCheckBox2.addActionListener(e -> triStateCheckBox2Changed());
add(triStateCheckBox2, "cell 1 1"); add(triStateCheckBox2, "cell 1 2");
//---- triStateLabel2 ---- //---- triStateLabel2 ----
triStateLabel2.setText("text"); triStateLabel2.setText("text");
triStateLabel2.setEnabled(false); triStateLabel2.setEnabled(false);
add(triStateLabel2, "cell 2 1,gapx 30"); add(triStateLabel2, "cell 2 2,gapx 30");
//---- label2 ---- //---- label2 ----
label2.setText("SVG Icons:"); label2.setText("SVG Icons:");
add(label2, "cell 0 2"); add(label2, "cell 0 3");
//======== svgIconsPanel ======== //======== svgIconsPanel ========
{ {
@@ -189,58 +207,60 @@ public class FlatExtrasTest
// rows // rows
"[grow,center]")); "[grow,center]"));
} }
add(svgIconsPanel, "cell 1 2 2 1"); add(svgIconsPanel, "cell 1 3 2 1");
//---- label3 ---- //---- label3 ----
label3.setText("The icons may change colors when switching to another theme."); label3.setText("The icons may change colors when switching to another theme.");
add(label3, "cell 1 3 2 1"); add(label3, "cell 1 4 2 1");
//---- label4 ---- //---- label4 ----
label4.setText("Disabled SVG Icons:"); label4.setText("Disabled SVG Icons:");
add(label4, "cell 0 4"); add(label4, "cell 0 5");
//---- disabledLabel ---- //---- disabledLabel ----
disabledLabel.setText("label"); disabledLabel.setText("label");
add(disabledLabel, "cell 1 4 2 1"); add(disabledLabel, "cell 1 5 2 1");
//---- disabledButton ---- //---- disabledButton ----
disabledButton.setText("button"); disabledButton.setText("button");
add(disabledButton, "cell 1 4 2 1"); add(disabledButton, "cell 1 5 2 1");
add(disabledTabbedPane, "cell 1 4 2 1"); add(disabledTabbedPane, "cell 1 5 2 1");
//---- label5 ---- //---- label5 ----
label5.setText("only setIcon()"); label5.setText("only setIcon()");
label5.setEnabled(false); label5.setEnabled(false);
add(label5, "cell 1 4 2 1,gapx 20"); add(label5, "cell 1 5 2 1,gapx 20");
//---- disabledCheckBox ---- //---- disabledCheckBox ----
disabledCheckBox.setText("disabled"); disabledCheckBox.setText("disabled");
disabledCheckBox.setSelected(true); disabledCheckBox.setSelected(true);
disabledCheckBox.setMnemonic('D'); disabledCheckBox.setMnemonic('D');
disabledCheckBox.addActionListener(e -> disabledChanged()); disabledCheckBox.addActionListener(e -> disabledChanged());
add(disabledCheckBox, "cell 0 5,alignx left,growx 0"); add(disabledCheckBox, "cell 0 6,alignx left,growx 0");
//---- disabledLabel2 ---- //---- disabledLabel2 ----
disabledLabel2.setText("label"); disabledLabel2.setText("label");
add(disabledLabel2, "cell 1 5 2 1"); add(disabledLabel2, "cell 1 6 2 1");
//---- disabledButton2 ---- //---- disabledButton2 ----
disabledButton2.setText("button"); disabledButton2.setText("button");
add(disabledButton2, "cell 1 5 2 1"); add(disabledButton2, "cell 1 6 2 1");
add(disabledTabbedPane2, "cell 1 5 2 1"); add(disabledTabbedPane2, "cell 1 6 2 1");
//---- label6 ---- //---- label6 ----
label6.setText("setIcon() and setDisabledIcon()"); label6.setText("setIcon() and setDisabledIcon()");
label6.setEnabled(false); label6.setEnabled(false);
add(label6, "cell 1 5 2 1,gapx 20"); add(label6, "cell 1 6 2 1,gapx 20");
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
} }
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JLabel label1; private JLabel label1;
private TriStateCheckBox triStateCheckBox1; private FlatTriStateCheckBox triStateCheckBox1;
private JLabel triStateLabel1; private JLabel triStateLabel1;
private TriStateCheckBox triStateCheckBox2; private FlatTriStateCheckBox triStateCheckBox3;
private JLabel triStateLabel3;
private FlatTriStateCheckBox triStateCheckBox2;
private JLabel triStateLabel2; private JLabel triStateLabel2;
private JLabel label2; private JLabel label2;
private JPanel svgIconsPanel; private JPanel svgIconsPanel;

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8" JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
new FormModel { new FormModel {
contentType: "form/swing" contentType: "form/swing"
@@ -15,7 +15,7 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 0" "value": "cell 0 0"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox1" name: "triStateCheckBox1"
"text": "three states" "text": "three states"
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) )
@@ -29,26 +29,41 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0,gapx 30" "value": "cell 2 0,gapx 30"
} ) } )
add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox2" name: "triStateCheckBox3"
"text": "third state disabled" "text": "alt state cycle order"
"thirdStateEnabled": false "altStateCycleOrder": true
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox2Changed", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox3Changed", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1" "value": "cell 1 1"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "triStateLabel3"
"text": "text"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1,gapx 30"
} )
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
name: "triStateCheckBox2"
"text": "third state disabled"
"allowIndeterminate": false
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox2Changed", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "triStateLabel2" name: "triStateLabel2"
"text": "text" "text": "text"
"enabled": false "enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1,gapx 30" "value": "cell 2 2,gapx 30"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2" name: "label2"
"text": "SVG Icons:" "text": "SVG Icons:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2" "value": "cell 0 3"
} ) } )
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 0,hidemode 3" "$layoutConstraints": "insets 0,hidemode 3"
@@ -57,43 +72,43 @@ new FormModel {
} ) { } ) {
name: "svgIconsPanel" name: "svgIconsPanel"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2 2 1" "value": "cell 1 3 2 1"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3" name: "label3"
"text": "The icons may change colors when switching to another theme." "text": "The icons may change colors when switching to another theme."
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3 2 1" "value": "cell 1 4 2 1"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4" name: "label4"
"text": "Disabled SVG Icons:" "text": "Disabled SVG Icons:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4" "value": "cell 0 5"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "disabledLabel" name: "disabledLabel"
"text": "label" "text": "label"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1" "value": "cell 1 5 2 1"
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "javax.swing.JButton" ) {
name: "disabledButton" name: "disabledButton"
"text": "button" "text": "button"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1" "value": "cell 1 5 2 1"
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "disabledTabbedPane" name: "disabledTabbedPane"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1" "value": "cell 1 5 2 1"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5" name: "label5"
"text": "only setIcon()" "text": "only setIcon()"
"enabled": false "enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1,gapx 20" "value": "cell 1 5 2 1,gapx 20"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "disabledCheckBox" name: "disabledCheckBox"
@@ -102,35 +117,35 @@ new FormModel {
"mnemonic": 68 "mnemonic": 68
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "disabledChanged", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "disabledChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5,alignx left,growx 0" "value": "cell 0 6,alignx left,growx 0"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "disabledLabel2" name: "disabledLabel2"
"text": "label" "text": "label"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 2 1" "value": "cell 1 6 2 1"
} ) } )
add( new FormComponent( "javax.swing.JButton" ) { add( new FormComponent( "javax.swing.JButton" ) {
name: "disabledButton2" name: "disabledButton2"
"text": "button" "text": "button"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 2 1" "value": "cell 1 6 2 1"
} ) } )
add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) {
name: "disabledTabbedPane2" name: "disabledTabbedPane2"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 2 1" "value": "cell 1 6 2 1"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6" name: "label6"
"text": "setIcon() and setDisabledIcon()" "text": "setIcon() and setDisabledIcon()"
"enabled": false "enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5 2 1,gapx 20" "value": "cell 1 6 2 1,gapx 20"
} ) } )
}, 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( 595, 300 ) "size": new java.awt.Dimension( 595, 470 )
} ) } )
} }
} }

View File

@@ -51,6 +51,8 @@ public class FlatJideOssTest
FlatJideOssTest() { FlatJideOssTest() {
initComponents(); initComponents();
tristateCheckBox1Changed();
} }
private void tabScrollChanged() { private void tabScrollChanged() {
@@ -104,6 +106,16 @@ public class FlatJideOssTest
popupMenu.showPopup(); popupMenu.showPopup();
} }
private void tristateCheckBox1Changed() {
String text = null;
switch( tristateCheckBox1.getState() ) {
case TristateCheckBox.STATE_UNSELECTED: text = "UNSELECTED"; break;
case TristateCheckBox.STATE_SELECTED: text = "SELECTED"; break;
case TristateCheckBox.STATE_MIXED: text = "MIXED"; break;
}
triStateLabel1.setText( text );
}
private void initComponents() { private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JPanel panel9 = new JPanel(); JPanel panel9 = new JPanel();
@@ -135,6 +147,9 @@ public class FlatJideOssTest
JPanel panel10 = new JPanel(); JPanel panel10 = new JPanel();
JLabel jidePopupLabel = new JLabel(); JLabel jidePopupLabel = new JLabel();
JButton showJidePopupButton = new JButton(); JButton showJidePopupButton = new JButton();
JLabel label9 = new JLabel();
tristateCheckBox1 = new TristateCheckBox();
triStateLabel1 = new JLabel();
CellConstraints cc = new CellConstraints(); CellConstraints cc = new CellConstraints();
//======== this ======== //======== this ========
@@ -303,8 +318,10 @@ public class FlatJideOssTest
"insets 3 0 3 3,hidemode 3", "insets 3 0 3 3,hidemode 3",
// columns // columns
"[fill]" + "[fill]" +
"[fill]" +
"[fill]", "[fill]",
// rows // rows
"[]" +
"[]")); "[]"));
//---- jidePopupLabel ---- //---- jidePopupLabel ----
@@ -315,6 +332,20 @@ public class FlatJideOssTest
showJidePopupButton.setText("show JidePopup"); showJidePopupButton.setText("show JidePopup");
showJidePopupButton.addActionListener(e -> showJidePopupButtonActionPerformed(e)); showJidePopupButton.addActionListener(e -> showJidePopupButtonActionPerformed(e));
panel10.add(showJidePopupButton, "cell 1 0"); panel10.add(showJidePopupButton, "cell 1 0");
//---- label9 ----
label9.setText("TristateCheckBox:");
panel10.add(label9, "cell 0 1");
//---- tristateCheckBox1 ----
tristateCheckBox1.setText("three states");
tristateCheckBox1.addActionListener(e -> tristateCheckBox1Changed());
panel10.add(tristateCheckBox1, "cell 1 1");
//---- triStateLabel1 ----
triStateLabel1.setText("text");
triStateLabel1.setEnabled(false);
panel10.add(triStateLabel1, "cell 2 1");
} }
panel9.add(panel10, cc.xy(1, 9)); panel9.add(panel10, cc.xy(1, 9));
} }
@@ -330,5 +361,7 @@ public class FlatJideOssTest
private JCheckBox moreTabsCheckBox; private JCheckBox moreTabsCheckBox;
private JCheckBox tabScrollCheckBox; private JCheckBox tabScrollCheckBox;
private JCheckBox hasFullBorderCheckBox; private JCheckBox hasFullBorderCheckBox;
private TristateCheckBox tristateCheckBox1;
private JLabel triStateLabel1;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
} }

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8" JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
new FormModel { new FormModel {
contentType: "form/swing" contentType: "form/swing"
@@ -194,8 +194,8 @@ 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 3 0 3 3,hidemode 3" "$layoutConstraints": "insets 3 0 3 3,hidemode 3"
"$columnConstraints": "[fill][fill]" "$columnConstraints": "[fill][fill][fill]"
"$rowConstraints": "[]" "$rowConstraints": "[][]"
} ) { } ) {
name: "panel10" name: "panel10"
add( new FormComponent( "javax.swing.JLabel" ) { add( new FormComponent( "javax.swing.JLabel" ) {
@@ -211,6 +211,32 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0" "value": "cell 1 0"
} ) } )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label9"
"text": "TristateCheckBox:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1"
} )
add( new FormComponent( "com.jidesoft.swing.TristateCheckBox" ) {
name: "tristateCheckBox1"
"text": "three states"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tristateCheckBox1Changed", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "triStateLabel1"
"text": "text"
"enabled": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1"
} )
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
"gridY": 9 "gridY": 9
} ) } )

View File

@@ -16,12 +16,14 @@
package com.formdev.flatlaf.testing.jideoss; package com.formdev.flatlaf.testing.jideoss;
import javax.swing.*;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JSlider; import javax.swing.JSlider;
import javax.swing.SwingConstants; import javax.swing.SwingConstants;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.event.ChangeListener;
import com.formdev.flatlaf.testing.FlatTestFrame; import com.formdev.flatlaf.testing.FlatTestFrame;
import com.formdev.flatlaf.testing.FlatTestPanel; import com.formdev.flatlaf.testing.FlatTestPanel;
import com.jidesoft.plaf.LookAndFeelFactory; import com.jidesoft.plaf.LookAndFeelFactory;
@@ -46,8 +48,43 @@ public class FlatRangeSliderTest
} ); } );
} }
private final JSlider[] allSliders;
private final JSlider[] directionalSliders;
FlatRangeSliderTest() { FlatRangeSliderTest() {
initComponents(); initComponents();
allSliders = new JSlider[] {
horizontalRangeSlider,
verticalRangeSlider,
horizontalSlider,
verticalSlider,
horizontalRangeSlider2,
verticalRangeSlider2,
horizontalSlider2,
verticalSlider2,
};
directionalSliders = new JSlider[] {
horizontalRangeSlider,
verticalRangeSlider,
horizontalSlider,
verticalSlider,
};
ChangeListener sliderChanged = e -> {
JSlider slider = (JSlider) e.getSource();
String text;
if( slider instanceof RangeSlider ) {
RangeSlider rangeSlider = (RangeSlider) slider;
text = rangeSlider.getLowValue() + " - " + rangeSlider.getHighValue()
+ " " + slider.getValueIsAdjusting();
} else
text = slider.getValue() + " " + slider.getValueIsAdjusting();
sliderValueLabel.setText( text );
// System.out.println( text );
};
for( JSlider slider : allSliders )
slider.addChangeListener( sliderChanged );
} }
private void paintLabels() { private void paintLabels() {
@@ -66,6 +103,26 @@ public class FlatRangeSliderTest
verticalSlider.setPaintTicks( selected ); verticalSlider.setPaintTicks( selected );
} }
private void sliderSnapToTicksChanged() {
boolean snapToTicks = sliderSnapToTicksCheckBox.isSelected();
for( JSlider slider : allSliders )
slider.setSnapToTicks( snapToTicks );
}
private void majorThickSpacingChanged() {
int majorTickSpacing = (Integer) majorTickSpacingSpinner.getValue();
for( JSlider slider : directionalSliders ) {
slider.setLabelTable( null );
slider.setMajorTickSpacing( majorTickSpacing );
}
}
private void minorThickSpacingChanged() {
int minorTickSpacing = (Integer) minorTickSpacingSpinner.getValue();
for( JSlider slider : directionalSliders )
slider.setMinorTickSpacing( minorTickSpacing );
}
private void initComponents() { private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
JLabel tabbedPaneLabel = new JLabel(); JLabel tabbedPaneLabel = new JLabel();
@@ -81,13 +138,18 @@ public class FlatRangeSliderTest
verticalSlider2 = new JSlider(); verticalSlider2 = new JSlider();
paintTick = new JCheckBox(); paintTick = new JCheckBox();
paintLabel = new JCheckBox(); paintLabel = new JCheckBox();
sliderSnapToTicksCheckBox = new JCheckBox();
majorTickSpacingSpinner = new JSpinner();
minorTickSpacingSpinner = new JSpinner();
sliderValueLabel = new JLabel();
//======== this ======== //======== this ========
setLayout(new MigLayout( setLayout(new MigLayout(
"insets dialog,hidemode 3", "insets dialog,hidemode 3",
// columns // columns
"[left]" + "[left]" +
"[240,left]", "[240,left]" +
"[fill]",
// rows // rows
"[fill]" + "[fill]" +
"[center]" + "[center]" +
@@ -170,14 +232,33 @@ public class FlatRangeSliderTest
paintTick.setMnemonic('T'); paintTick.setMnemonic('T');
paintTick.setSelected(true); paintTick.setSelected(true);
paintTick.addActionListener(e -> paintTicks()); paintTick.addActionListener(e -> paintTicks());
add(paintTick, "cell 0 6 2 1"); add(paintTick, "cell 0 6 3 1");
//---- paintLabel ---- //---- paintLabel ----
paintLabel.setText("PaintLabels"); paintLabel.setText("PaintLabels");
paintLabel.setMnemonic('L'); paintLabel.setMnemonic('L');
paintLabel.setSelected(true); paintLabel.setSelected(true);
paintLabel.addActionListener(e -> paintLabels()); paintLabel.addActionListener(e -> paintLabels());
add(paintLabel, "cell 0 6 2 1"); add(paintLabel, "cell 0 6 3 1");
//---- sliderSnapToTicksCheckBox ----
sliderSnapToTicksCheckBox.setText("snap to ticks");
sliderSnapToTicksCheckBox.addActionListener(e -> sliderSnapToTicksChanged());
add(sliderSnapToTicksCheckBox, "cell 0 6 3 1");
//---- majorTickSpacingSpinner ----
majorTickSpacingSpinner.setModel(new SpinnerNumberModel(10, 0, 100, 5));
majorTickSpacingSpinner.addChangeListener(e -> majorThickSpacingChanged());
add(majorTickSpacingSpinner, "cell 0 6 3 1");
//---- minorTickSpacingSpinner ----
minorTickSpacingSpinner.setModel(new SpinnerNumberModel(5, 0, 100, 5));
minorTickSpacingSpinner.addChangeListener(e -> minorThickSpacingChanged());
add(minorTickSpacingSpinner, "cell 0 6 3 1");
//---- sliderValueLabel ----
sliderValueLabel.setText("slider value");
add(sliderValueLabel, "cell 0 6 3 1");
// JFormDesigner - End of component initialization //GEN-END:initComponents // JFormDesigner - End of component initialization //GEN-END:initComponents
} }
@@ -192,5 +273,9 @@ public class FlatRangeSliderTest
private JSlider verticalSlider2; private JSlider verticalSlider2;
private JCheckBox paintTick; private JCheckBox paintTick;
private JCheckBox paintLabel; private JCheckBox paintLabel;
private JCheckBox sliderSnapToTicksCheckBox;
private JSpinner majorTickSpacingSpinner;
private JSpinner minorTickSpacingSpinner;
private JLabel sliderValueLabel;
// JFormDesigner - End of variables declaration //GEN-END:variables // JFormDesigner - End of variables declaration //GEN-END:variables
} }

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.2.0.298" Java: "15" encoding: "UTF-8" JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
new FormModel { new FormModel {
contentType: "form/swing" contentType: "form/swing"
@@ -8,7 +8,7 @@ new FormModel {
} }
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets dialog,hidemode 3" "$layoutConstraints": "insets dialog,hidemode 3"
"$columnConstraints": "[left][240,left]" "$columnConstraints": "[left][240,left][fill]"
"$rowConstraints": "[fill][center][][][][grow,fill][]" "$rowConstraints": "[fill][center][][][][grow,fill][]"
} ) { } ) {
name: "this" name: "this"
@@ -136,7 +136,7 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintTicks", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintTicks", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6 2 1" "value": "cell 0 6 3 1"
} ) } )
add( new FormComponent( "javax.swing.JCheckBox" ) { add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "paintLabel" name: "paintLabel"
@@ -148,7 +148,46 @@ new FormModel {
} }
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintLabels", false ) ) addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintLabels", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6 2 1" "value": "cell 0 6 3 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "sliderSnapToTicksCheckBox"
"text": "snap to ticks"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "sliderSnapToTicksChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6 3 1"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "majorTickSpacingSpinner"
"model": new javax.swing.SpinnerNumberModel( 10, 0, 100, 5 )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "majorThickSpacingChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6 3 1"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "minorTickSpacingSpinner"
"model": new javax.swing.SpinnerNumberModel( 5, 0, 100, 5 )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "minorThickSpacingChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6 3 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "sliderValueLabel"
"text": "slider value"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6 3 1"
} ) } )
}, new FormLayoutConstraints( null ) { }, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 ) "location": new java.awt.Point( 0, 0 )

View File

@@ -928,6 +928,9 @@ Tree.textForeground
Tree.timeFactor Tree.timeFactor
Tree.wideSelection Tree.wideSelection
TreeUI TreeUI
TristateCheckBox.clearMixed.clientProperty
TristateCheckBox.setMixed.clientProperty
UIColorHighlighter.stripingBackground
Viewport.background Viewport.background
Viewport.font Viewport.font
Viewport.foreground Viewport.foreground