Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec8213b891 | ||
|
|
ae61383742 | ||
|
|
cc90a2ad75 | ||
|
|
28634cda56 | ||
|
|
3b71fcd690 | ||
|
|
5923ac65df | ||
|
|
faffc9393d | ||
|
|
6da220f36c | ||
|
|
21d78671d6 | ||
|
|
af5a0ec0b7 | ||
|
|
ff214455a3 | ||
|
|
3e941e3e42 | ||
|
|
2f876d553f | ||
|
|
b208017117 | ||
|
|
a1dab94a61 | ||
|
|
e55b2afd60 | ||
|
|
535c3ddf6c | ||
|
|
3008d99fcd | ||
|
|
fd37339e2f | ||
|
|
e29eca203c | ||
|
|
f1fd6dcdd2 | ||
|
|
2975ed2eae | ||
|
|
5a27d03faa | ||
|
|
8bcf9dbcaf | ||
|
|
56ebd26361 | ||
|
|
b0426b81a7 |
53
CHANGELOG.md
@@ -1,6 +1,59 @@
|
||||
FlatLaf Change Log
|
||||
==================
|
||||
|
||||
## 0.41
|
||||
|
||||
#### New features and improvements
|
||||
|
||||
- Added API to register packages or folders where FlatLaf searches for
|
||||
application specific properties files with custom UI defaults (see
|
||||
`FlatLaf.registerCustomDefaultsSource(...)` methods).
|
||||
- Demo: Show hint popups to guide users to some features of the FlatLaf Demo
|
||||
application.
|
||||
- Extras: `FlatSVGIcon` now allows specifying `ClassLoader` that is used to load
|
||||
SVG file. (issue #163)
|
||||
- Smoother transition from old to new theme, independent of UI complexity, when
|
||||
using animated theme change (see [FlatLaf Extras](flatlaf-extras)).
|
||||
|
||||
#### Fixed bugs
|
||||
|
||||
- Button: "selected" state was not shown. (issue #161)
|
||||
- TextArea: Update background color property if enabled or editable state
|
||||
changes in the same way as Swing does it for all other text components. (issue
|
||||
#147)
|
||||
- Demo: Fixed restoring last used theme on startup. (regression in 0.39)
|
||||
- Custom window decorations: Fixed iconify, maximize and close icon colors if
|
||||
window is inactive.
|
||||
- Custom window decorations: Fixed title pane background color in IntelliJ
|
||||
themes if window is inactive.
|
||||
- Fixed sub-pixel text rendering in animated theme change (see
|
||||
[FlatLaf Extras](flatlaf-extras)).
|
||||
|
||||
#### Other Changes
|
||||
|
||||
- Extras: Updated dependency
|
||||
[svgSalamander](https://github.com/JFormDesigner/svgSalamander) to version
|
||||
1.1.2.3.
|
||||
|
||||
|
||||
## 0.40
|
||||
|
||||
#### New features
|
||||
|
||||
- Table: Detect whether component is used in cell editor and automatically
|
||||
disable round border style and reduce cell editor outer border width (used for
|
||||
focus indicator) to zero. (issue #148)
|
||||
- ComboBox, Spinner and TextField: Support disabling round border style per
|
||||
component, if globally enabled (set client property `JComponent.roundRect` to
|
||||
`false`). (issue #148)
|
||||
|
||||
#### Fixed bugs
|
||||
|
||||
- Custom window decorations: Embedded menu bar did not always respond to mouse
|
||||
events after adding menus and when running in JetBrains Runtime. (issue #151)
|
||||
- IntelliJ Themes: Fixed NPE in Solarized themes on scroll bar hover.
|
||||
|
||||
|
||||
## 0.39
|
||||
|
||||
#### New features
|
||||
|
||||
@@ -11,9 +11,9 @@ scales on **HiDPI** displays and runs on Java 8 or newer.
|
||||
The look is heavily inspired by **Darcula** and **IntelliJ** themes from
|
||||
IntelliJ IDEA 2019.2+ and uses almost the same colors and icons.
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
IntelliJ Platform Themes
|
||||
@@ -22,9 +22,7 @@ IntelliJ Platform Themes
|
||||
FlatLaf can use 3rd party themes created for IntelliJ Platform (see
|
||||
[IntelliJ Themes Pack](flatlaf-intellij-themes)):
|
||||
|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
Demo
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
val releaseVersion = "0.39"
|
||||
val developmentVersion = "0.40-SNAPSHOT"
|
||||
val releaseVersion = "0.41"
|
||||
val developmentVersion = "0.42-SNAPSHOT"
|
||||
|
||||
version = if( java.lang.Boolean.getBoolean( "release" ) ) releaseVersion else developmentVersion
|
||||
|
||||
|
||||
@@ -314,6 +314,15 @@ public interface FlatClientProperties
|
||||
return (value instanceof Boolean) ? (boolean) value : defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a client property of a component is a {@link Boolean} and returns its value.
|
||||
* If the client property is not set, or not a {@link Boolean}, defaultValue is returned.
|
||||
*/
|
||||
static Boolean clientPropertyBooleanStrict( JComponent c, String key, Boolean defaultValue ) {
|
||||
Object value = c.getClientProperty( key );
|
||||
return (value instanceof Boolean) ? (Boolean) value : defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a client property of a component is an integer and returns its value.
|
||||
* If the client property is not set, or not an integer, defaultValue is returned.
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.awt.image.ImageFilter;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -76,6 +77,8 @@ public abstract class FlatLaf
|
||||
static final Logger LOG = Logger.getLogger( FlatLaf.class.getName() );
|
||||
private static final String DESKTOPFONTHINTS = "awt.font.desktophints";
|
||||
|
||||
private static List<Object> customDefaultsSources;
|
||||
|
||||
private String desktopPropertyName;
|
||||
private String desktopPropertyName2;
|
||||
private PropertyChangeListener desktopPropertyListener;
|
||||
@@ -552,6 +555,87 @@ public abstract class FlatLaf
|
||||
defaults.put( key, value );
|
||||
}
|
||||
|
||||
static List<Object> getCustomDefaultsSources() {
|
||||
return customDefaultsSources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a package where FlatLaf searches for properties files with custom UI defaults.
|
||||
* <p>
|
||||
* This can be used to specify application specific UI defaults that override UI values
|
||||
* of existing themes or to define own UI values used in custom controls.
|
||||
* <p>
|
||||
* There may be multiple properties files in that package for multiple themes.
|
||||
* The properties file name must match the used theme class names.
|
||||
* E.g. {@code FlatLightLaf.properties} for class {@link FlatLightLaf}
|
||||
* or {@code FlatDarkLaf.properties} for class {@link FlatDarkLaf}.
|
||||
* {@code FlatLaf.properties} is loaded first for all themes.
|
||||
* <p>
|
||||
* These properties files are loaded after theme and addon properties files
|
||||
* and can therefore override all UI defaults.
|
||||
* <p>
|
||||
* Invoke this method before setting the look and feel.
|
||||
*
|
||||
* @param packageName a package name (e.g. "com.myapp.resources")
|
||||
*/
|
||||
public static void registerCustomDefaultsSource( String packageName ) {
|
||||
registerCustomDefaultsSource( packageName, null );
|
||||
}
|
||||
|
||||
public static void unregisterCustomDefaultsSource( String packageName ) {
|
||||
unregisterCustomDefaultsSource( packageName, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a package where FlatLaf searches for properties files with custom UI defaults.
|
||||
* <p>
|
||||
* See {@link #registerCustomDefaultsSource(String)} for details.
|
||||
*
|
||||
* @param packageName a package name (e.g. "com.myapp.resources")
|
||||
* @param classLoader a class loader used to find resources, or {@code null}
|
||||
*/
|
||||
public static void registerCustomDefaultsSource( String packageName, ClassLoader classLoader ) {
|
||||
if( customDefaultsSources == null )
|
||||
customDefaultsSources = new ArrayList<>();
|
||||
customDefaultsSources.add( packageName );
|
||||
customDefaultsSources.add( classLoader );
|
||||
}
|
||||
|
||||
public static void unregisterCustomDefaultsSource( String packageName, ClassLoader classLoader ) {
|
||||
if( customDefaultsSources == null )
|
||||
return;
|
||||
|
||||
int size = customDefaultsSources.size();
|
||||
for( int i = 0; i < size - 1; i++ ) {
|
||||
Object source = customDefaultsSources.get( i );
|
||||
if( packageName.equals( source ) && customDefaultsSources.get( i + 1 ) == classLoader ) {
|
||||
customDefaultsSources.remove( i + 1 );
|
||||
customDefaultsSources.remove( i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a folder where FlatLaf searches for properties files with custom UI defaults.
|
||||
* <p>
|
||||
* See {@link #registerCustomDefaultsSource(String)} for details.
|
||||
*
|
||||
* @param folder a folder
|
||||
*/
|
||||
public static void registerCustomDefaultsSource( File folder ) {
|
||||
if( customDefaultsSources == null )
|
||||
customDefaultsSources = new ArrayList<>();
|
||||
customDefaultsSources.add( folder );
|
||||
}
|
||||
|
||||
public static void unregisterCustomDefaultsSource( File folder ) {
|
||||
if( customDefaultsSources == null )
|
||||
return;
|
||||
|
||||
customDefaultsSources.remove( folder );
|
||||
}
|
||||
|
||||
private static void reSetLookAndFeel() {
|
||||
EventQueue.invokeLater( () -> {
|
||||
LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
|
||||
|
||||
@@ -263,6 +263,9 @@ public class IntelliJTheme
|
||||
for( Map.Entry<String, Object> e : ((Map<String, Object>)value).entrySet() )
|
||||
apply( key + '.' + e.getKey(), e.getValue(), defaults, defaultsKeysCache, uiKeys );
|
||||
} else {
|
||||
if( "".equals( value ) )
|
||||
return; // ignore empty value
|
||||
|
||||
uiKeys.add( key );
|
||||
|
||||
// fix ComboBox size and Spinner border in all Material UI Lite themes
|
||||
@@ -528,6 +531,7 @@ public class IntelliJTheme
|
||||
uiKeyMapping.put( "Slider.trackWidth", "" ); // ignore (used in Material Theme UI Lite)
|
||||
|
||||
// TitlePane
|
||||
uiKeyCopying.put( "TitlePane.inactiveBackground", "TitlePane.background" );
|
||||
uiKeyMapping.put( "TitlePane.infoForeground", "TitlePane.foreground" );
|
||||
uiKeyMapping.put( "TitlePane.inactiveInfoForeground", "TitlePane.inactiveForeground" );
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.formdev.flatlaf;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Insets;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -107,6 +109,42 @@ class UIDefaultsLoader
|
||||
}
|
||||
}
|
||||
|
||||
// load custom properties files (usually provides by applications)
|
||||
List<Object> customDefaultsSources = FlatLaf.getCustomDefaultsSources();
|
||||
int size = (customDefaultsSources != null) ? customDefaultsSources.size() : 0;
|
||||
for( int i = 0; i < size; i++ ) {
|
||||
Object source = customDefaultsSources.get( i );
|
||||
if( source instanceof String && i + 1 < size ) {
|
||||
// load from package in classloader
|
||||
String packageName = (String) source;
|
||||
ClassLoader classLoader = (ClassLoader) customDefaultsSources.get( ++i );
|
||||
|
||||
packageName = packageName.replace( '.', '/' );
|
||||
if( classLoader == null )
|
||||
classLoader = FlatLaf.class.getClassLoader();
|
||||
|
||||
for( Class<?> lafClass : lafClasses ) {
|
||||
String propertiesName = packageName + '/' + lafClass.getSimpleName() + ".properties";
|
||||
try( InputStream in = classLoader.getResourceAsStream( propertiesName ) ) {
|
||||
if( in != null )
|
||||
properties.load( in );
|
||||
}
|
||||
}
|
||||
} else if( source instanceof File ) {
|
||||
// load from folder
|
||||
File folder = (File) source;
|
||||
for( Class<?> lafClass : lafClasses ) {
|
||||
File propertiesFile = new File( folder, lafClass.getSimpleName() + ".properties" );
|
||||
if( !propertiesFile.isFile() )
|
||||
continue;
|
||||
|
||||
try( InputStream in = new FileInputStream( propertiesFile ) ) {
|
||||
properties.load( in );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// collect addon class loaders
|
||||
List<ClassLoader> addonClassLoaders = new ArrayList<>();
|
||||
for( FlatDefaultsAddon addon : addons ) {
|
||||
|
||||
@@ -87,15 +87,14 @@ public class FlatBorder
|
||||
try {
|
||||
FlatUIUtils.setRenderingHints( g2 );
|
||||
|
||||
boolean isCellEditor = isCellEditor( c );
|
||||
float focusWidth = isCellEditor ? 0 : scale( (float) getFocusWidth( c ) );
|
||||
float focusWidth = scale( (float) getFocusWidth( c ) );
|
||||
float borderWidth = scale( (float) getBorderWidth( c ) );
|
||||
float arc = isCellEditor ? 0 : scale( (float) getArc( c ) );
|
||||
float arc = scale( (float) getArc( c ) );
|
||||
Color outlineColor = getOutlineColor( c );
|
||||
|
||||
// paint outer border
|
||||
if( outlineColor != null || isFocused( c ) ) {
|
||||
float innerWidth = !isCellEditor && !(c instanceof JScrollPane)
|
||||
float innerWidth = !isCellEditor( c ) && !(c instanceof JScrollPane)
|
||||
? (outlineColor != null ? innerOutlineWidth : innerFocusWidth)
|
||||
: 0;
|
||||
|
||||
@@ -204,8 +203,7 @@ public class FlatBorder
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets( Component c, Insets insets ) {
|
||||
boolean isCellEditor = isCellEditor( c );
|
||||
float focusWidth = isCellEditor ? 0 : scale( (float) getFocusWidth( c ) );
|
||||
float focusWidth = scale( (float) getFocusWidth( c ) );
|
||||
float ow = focusWidth + scale( (float) getLineWidth( c ) );
|
||||
|
||||
insets = super.getBorderInsets( c, insets );
|
||||
@@ -214,7 +212,7 @@ public class FlatBorder
|
||||
insets.bottom = Math.round( scale( (float) insets.bottom ) + ow );
|
||||
insets.right = Math.round( scale( (float) insets.right ) + ow );
|
||||
|
||||
if( isCellEditor ) {
|
||||
if( isCellEditor( c ) ) {
|
||||
// remove top and bottom insets if used as cell editor
|
||||
insets.top = insets.bottom = 0;
|
||||
|
||||
@@ -232,6 +230,9 @@ public class FlatBorder
|
||||
* Returns the (unscaled) thickness of the outer focus border.
|
||||
*/
|
||||
protected int getFocusWidth( Component c ) {
|
||||
if( isCellEditor( c ) )
|
||||
return 0;
|
||||
|
||||
return focusWidth;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,9 @@ public class FlatButtonBorder
|
||||
|
||||
@Override
|
||||
protected int getArc( Component c ) {
|
||||
if( isCellEditor( c ) )
|
||||
return 0;
|
||||
|
||||
switch( FlatButtonUI.getButtonType( c ) ) {
|
||||
case FlatButtonUI.TYPE_SQUARE: return 0;
|
||||
case FlatButtonUI.TYPE_ROUND_RECT: return Short.MAX_VALUE;
|
||||
|
||||
@@ -67,8 +67,11 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
* @uiDefault Button.focusedBackground Color optional
|
||||
* @uiDefault Button.hoverBackground Color optional
|
||||
* @uiDefault Button.pressedBackground Color optional
|
||||
* @uiDefault Button.selectedBackground Color
|
||||
* @uiDefault Button.selectedForeground Color
|
||||
* @uiDefault Button.disabledBackground Color optional
|
||||
* @uiDefault Button.disabledText Color
|
||||
* @uiDefault Button.disabledSelectedBackground Color
|
||||
* @uiDefault Button.default.background Color
|
||||
* @uiDefault Button.default.startBackground Color optional; if set, a gradient paint is used and Button.default.background is ignored
|
||||
* @uiDefault Button.default.endBackground Color optional; if set, a gradient paint is used
|
||||
@@ -84,6 +87,7 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
* @uiDefault Button.toolbar.spacingInsets Insets
|
||||
* @uiDefault Button.toolbar.hoverBackground Color
|
||||
* @uiDefault Button.toolbar.pressedBackground Color
|
||||
* @uiDefault Button.toolbar.selectedBackground Color
|
||||
*
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
@@ -101,8 +105,11 @@ public class FlatButtonUI
|
||||
protected Color focusedBackground;
|
||||
protected Color hoverBackground;
|
||||
protected Color pressedBackground;
|
||||
protected Color selectedBackground;
|
||||
protected Color selectedForeground;
|
||||
protected Color disabledBackground;
|
||||
protected Color disabledText;
|
||||
protected Color disabledSelectedBackground;
|
||||
|
||||
protected Color defaultBackground;
|
||||
protected Color defaultEndBackground;
|
||||
@@ -119,6 +126,7 @@ public class FlatButtonUI
|
||||
protected Insets toolbarSpacingInsets;
|
||||
protected Color toolbarHoverBackground;
|
||||
protected Color toolbarPressedBackground;
|
||||
protected Color toolbarSelectedBackground;
|
||||
|
||||
private Icon helpButtonIcon;
|
||||
|
||||
@@ -150,8 +158,11 @@ public class FlatButtonUI
|
||||
focusedBackground = UIManager.getColor( prefix + "focusedBackground" );
|
||||
hoverBackground = UIManager.getColor( prefix + "hoverBackground" );
|
||||
pressedBackground = UIManager.getColor( prefix + "pressedBackground" );
|
||||
selectedBackground = UIManager.getColor( prefix + "selectedBackground" );
|
||||
selectedForeground = UIManager.getColor( prefix + "selectedForeground" );
|
||||
disabledBackground = UIManager.getColor( prefix + "disabledBackground" );
|
||||
disabledText = UIManager.getColor( prefix + "disabledText" );
|
||||
disabledSelectedBackground = UIManager.getColor( prefix + "disabledSelectedBackground" );
|
||||
|
||||
if( UIManager.getBoolean( "Button.paintShadow" ) ) {
|
||||
shadowWidth = FlatUIUtils.getUIInt( "Button.shadowWidth", 2 );
|
||||
@@ -174,6 +185,7 @@ public class FlatButtonUI
|
||||
toolbarSpacingInsets = UIManager.getInsets( "Button.toolbar.spacingInsets" );
|
||||
toolbarHoverBackground = UIManager.getColor( prefix + "toolbar.hoverBackground" );
|
||||
toolbarPressedBackground = UIManager.getColor( prefix + "toolbar.pressedBackground" );
|
||||
toolbarSelectedBackground = UIManager.getColor( prefix + "toolbar.selectedBackground" );
|
||||
|
||||
helpButtonIcon = UIManager.getIcon( "HelpButton.icon" );
|
||||
|
||||
@@ -369,6 +381,17 @@ public class FlatButtonUI
|
||||
}
|
||||
|
||||
protected Color getBackground( JComponent c ) {
|
||||
if( ((AbstractButton)c).isSelected() ) {
|
||||
// in toolbar use same colors for disabled and enabled because
|
||||
// we assume that toolbar icon is shown disabled
|
||||
boolean toolBarButton = isToolBarButton( c );
|
||||
return buttonStateColor( c,
|
||||
toolBarButton ? toolbarSelectedBackground : selectedBackground,
|
||||
toolBarButton ? toolbarSelectedBackground : disabledSelectedBackground,
|
||||
null, null,
|
||||
toolBarButton ? toolbarPressedBackground : pressedBackground );
|
||||
}
|
||||
|
||||
if( !c.isEnabled() )
|
||||
return disabledBackground;
|
||||
|
||||
@@ -430,6 +453,9 @@ public class FlatButtonUI
|
||||
if( !c.isEnabled() )
|
||||
return disabledText;
|
||||
|
||||
if( ((AbstractButton)c).isSelected() && !isToolBarButton( c ) )
|
||||
return selectedForeground;
|
||||
|
||||
// use component foreground if explicitly set
|
||||
Color fg = c.getForeground();
|
||||
if( isCustomForeground( fg ) )
|
||||
|
||||
@@ -126,6 +126,9 @@ public class FlatListUI
|
||||
* or the application has to be changed to extend a FlatLaf renderer.
|
||||
*/
|
||||
private void toggleSelectionColors() {
|
||||
if( list == null )
|
||||
return;
|
||||
|
||||
if( FlatUIUtils.isPermanentFocusOwner( list ) ) {
|
||||
if( list.getSelectionBackground() == selectionInactiveBackground )
|
||||
list.setSelectionBackground( selectionBackground );
|
||||
|
||||
@@ -123,6 +123,14 @@ public class FlatMenuUI
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getMinimumSize( JComponent c ) {
|
||||
// avoid that top-level menus (in menu bar) are made smaller if horizontal space is rare
|
||||
// same code is in BasicMenuUI since Java 10
|
||||
// see https://bugs.openjdk.java.net/browse/JDK-8178430
|
||||
return ((JMenu)menuItem).isTopLevelMenu() ? c.getPreferredSize() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dimension getPreferredMenuItemSize( JComponent c, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap ) {
|
||||
return renderer.getPreferredMenuItemSize();
|
||||
|
||||
@@ -304,6 +304,9 @@ public class FlatRootPaneUI
|
||||
Container contentPane = rootPane.getContentPane();
|
||||
if( contentPane != null )
|
||||
contentPane.setBounds( 0, nextY, width, Math.max( height - nextY, 0 ) );
|
||||
|
||||
if( titlePane != null )
|
||||
titlePane.menuBarLayouted();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,10 @@ public class FlatRoundBorder
|
||||
|
||||
@Override
|
||||
protected int getArc( Component c ) {
|
||||
return FlatUIUtils.isRoundRect( c ) ? Short.MAX_VALUE : arc;
|
||||
if( isCellEditor( c ) )
|
||||
return 0;
|
||||
|
||||
Boolean roundRect = FlatUIUtils.isRoundRect( c );
|
||||
return roundRect != null ? (roundRect ? Short.MAX_VALUE : 0) : arc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class FlatTableHeaderUI
|
||||
g2.setColor( separatorColor );
|
||||
|
||||
int sepCount = columnCount;
|
||||
if( header.getTable().getAutoResizeMode() != JTable.AUTO_RESIZE_OFF && !isVerticalScrollBarVisible() )
|
||||
if( header.getTable() != null && header.getTable().getAutoResizeMode() != JTable.AUTO_RESIZE_OFF && !isVerticalScrollBarVisible() )
|
||||
sepCount--;
|
||||
|
||||
if( header.getComponentOrientation().isLeftToRight() ) {
|
||||
|
||||
@@ -188,6 +188,9 @@ public class FlatTableUI
|
||||
* or the application has to be changed to extend a FlatLaf renderer.
|
||||
*/
|
||||
private void toggleSelectionColors() {
|
||||
if( table == null )
|
||||
return;
|
||||
|
||||
if( FlatUIUtils.isPermanentFocusOwner( table ) ) {
|
||||
if( table.getSelectionBackground() == selectionInactiveBackground )
|
||||
table.setSelectionBackground( selectionBackground );
|
||||
|
||||
@@ -60,6 +60,7 @@ public class FlatTextAreaUI
|
||||
{
|
||||
protected int minimumWidth;
|
||||
protected boolean isIntelliJTheme;
|
||||
protected Color background;
|
||||
protected Color disabledBackground;
|
||||
protected Color inactiveBackground;
|
||||
|
||||
@@ -67,12 +68,20 @@ public class FlatTextAreaUI
|
||||
return new FlatTextAreaUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installUI( JComponent c ) {
|
||||
super.installUI( c );
|
||||
|
||||
updateBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
|
||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||
background = UIManager.getColor( "TextArea.background" );
|
||||
disabledBackground = UIManager.getColor( "TextArea.disabledBackground" );
|
||||
inactiveBackground = UIManager.getColor( "TextArea.inactiveBackground" );
|
||||
}
|
||||
@@ -81,6 +90,7 @@ public class FlatTextAreaUI
|
||||
protected void uninstallDefaults() {
|
||||
super.uninstallDefaults();
|
||||
|
||||
background = null;
|
||||
disabledBackground = null;
|
||||
inactiveBackground = null;
|
||||
}
|
||||
@@ -89,26 +99,36 @@ public class FlatTextAreaUI
|
||||
protected void propertyChange( PropertyChangeEvent e ) {
|
||||
super.propertyChange( e );
|
||||
FlatEditorPaneUI.propertyChange( getComponent(), e );
|
||||
|
||||
switch( e.getPropertyName() ) {
|
||||
case "editable":
|
||||
case "enabled":
|
||||
updateBackground();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintSafely( Graphics g ) {
|
||||
super.paintSafely( HiDPIUtils.createGraphicsTextYCorrection( (Graphics2D) g ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground( Graphics g ) {
|
||||
private void updateBackground() {
|
||||
JTextComponent c = getComponent();
|
||||
|
||||
Color background = c.getBackground();
|
||||
g.setColor( !(background instanceof UIResource)
|
||||
? background
|
||||
: (isIntelliJTheme && (!c.isEnabled() || !c.isEditable())
|
||||
? FlatUIUtils.getParentBackground( c )
|
||||
: (!c.isEnabled()
|
||||
? disabledBackground
|
||||
: (!c.isEditable() ? inactiveBackground : background))) );
|
||||
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
|
||||
if( !(background instanceof UIResource) )
|
||||
return;
|
||||
|
||||
// do not update background if it currently has a unknown color (assigned from outside)
|
||||
if( background != this.background &&
|
||||
background != disabledBackground &&
|
||||
background != inactiveBackground )
|
||||
return;
|
||||
|
||||
Color newBackground = !c.isEnabled()
|
||||
? disabledBackground
|
||||
: (!c.isEditable()
|
||||
? inactiveBackground
|
||||
: this.background);
|
||||
|
||||
if( newBackground != background )
|
||||
c.setBackground( newBackground );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,4 +148,22 @@ public class FlatTextAreaUI
|
||||
|
||||
return FlatEditorPaneUI.applyMinimumWidth( c, size, minimumWidth );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintSafely( Graphics g ) {
|
||||
super.paintSafely( HiDPIUtils.createGraphicsTextYCorrection( (Graphics2D) g ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground( Graphics g ) {
|
||||
JTextComponent c = getComponent();
|
||||
|
||||
// for compatibility with IntelliJ themes
|
||||
if( isIntelliJTheme && (!c.isEnabled() || !c.isEditable()) && (c.getBackground() instanceof UIResource) ) {
|
||||
FlatUIUtils.paintParentBackground( g, c );
|
||||
return;
|
||||
}
|
||||
|
||||
super.paintBackground( g );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ public class FlatTextBorder
|
||||
|
||||
@Override
|
||||
protected int getArc( Component c ) {
|
||||
return FlatUIUtils.isRoundRect( c ) ? Short.MAX_VALUE : arc;
|
||||
if( isCellEditor( c ) )
|
||||
return 0;
|
||||
|
||||
Boolean roundRect = FlatUIUtils.isRoundRect( c );
|
||||
return roundRect != null ? (roundRect ? Short.MAX_VALUE : 0) : arc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.ui;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
@@ -165,7 +166,25 @@ public class FlatTitlePane
|
||||
|
||||
createButtons();
|
||||
|
||||
setLayout( new BorderLayout() );
|
||||
setLayout( new BorderLayout() {
|
||||
@Override
|
||||
public void layoutContainer( Container target ) {
|
||||
super.layoutContainer( target );
|
||||
|
||||
// make left panel (with embedded menu bar) smaller if horizontal space is rare
|
||||
// to avoid that embedded menu bar overlaps button bar
|
||||
Insets insets = target.getInsets();
|
||||
int width = target.getWidth() - insets.left - insets.right;
|
||||
if( leftPanel.getWidth() + buttonPanel.getWidth() > width ) {
|
||||
int oldWidth = leftPanel.getWidth();
|
||||
int newWidth = Math.max( width - buttonPanel.getWidth(), 0 );
|
||||
leftPanel.setSize( newWidth, leftPanel.getHeight() );
|
||||
if( !getComponentOrientation().isLeftToRight() )
|
||||
leftPanel.setLocation( leftPanel.getX() + (oldWidth - newWidth), leftPanel.getY() );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
add( leftPanel, BorderLayout.LINE_START );
|
||||
add( titleLabel, BorderLayout.CENTER );
|
||||
add( buttonPanel, BorderLayout.LINE_END );
|
||||
@@ -221,12 +240,15 @@ public class FlatTitlePane
|
||||
protected void activeChanged( boolean active ) {
|
||||
boolean hasEmbeddedMenuBar = rootPane.getJMenuBar() != null && isMenuBarEmbedded();
|
||||
Color background = FlatUIUtils.nonUIResource( active ? activeBackground : inactiveBackground );
|
||||
Color foreground = FlatUIUtils.nonUIResource( active
|
||||
? (hasEmbeddedMenuBar ? embeddedForeground : activeForeground)
|
||||
: inactiveForeground );
|
||||
Color foreground = FlatUIUtils.nonUIResource( active ? activeForeground : inactiveForeground );
|
||||
Color titleForeground = (hasEmbeddedMenuBar && active) ? FlatUIUtils.nonUIResource( embeddedForeground ) : foreground;
|
||||
|
||||
setBackground( background );
|
||||
titleLabel.setForeground( foreground );
|
||||
titleLabel.setForeground( titleForeground );
|
||||
iconifyButton.setForeground( foreground );
|
||||
maximizeButton.setForeground( foreground );
|
||||
restoreButton.setForeground( foreground );
|
||||
closeButton.setForeground( foreground );
|
||||
|
||||
titleLabel.setHorizontalAlignment( hasEmbeddedMenuBar ? SwingConstants.CENTER : SwingConstants.LEADING );
|
||||
|
||||
@@ -391,6 +413,12 @@ public class FlatTitlePane
|
||||
return FlatUIUtils.subtractInsets( bounds, UIScale.scale( getMenuBarMargins() ) );
|
||||
}
|
||||
|
||||
protected Insets getMenuBarMargins() {
|
||||
return getComponentOrientation().isLeftToRight()
|
||||
? menuBarMargins
|
||||
: new Insets( menuBarMargins.top, menuBarMargins.right, menuBarMargins.bottom, menuBarMargins.left );
|
||||
}
|
||||
|
||||
protected void menuBarChanged() {
|
||||
menuBarPlaceholder.invalidate();
|
||||
|
||||
@@ -400,12 +428,27 @@ public class FlatTitlePane
|
||||
} );
|
||||
}
|
||||
|
||||
protected Insets getMenuBarMargins() {
|
||||
return getComponentOrientation().isLeftToRight()
|
||||
? menuBarMargins
|
||||
: new Insets( menuBarMargins.top, menuBarMargins.right, menuBarMargins.bottom, menuBarMargins.left );
|
||||
protected void menuBarLayouted() {
|
||||
updateJBRHitTestSpotsAndTitleBarHeightLater();
|
||||
}
|
||||
|
||||
/*debug
|
||||
@Override
|
||||
public void paint( Graphics g ) {
|
||||
super.paint( g );
|
||||
|
||||
if( debugTitleBarHeight > 0 ) {
|
||||
g.setColor( Color.green );
|
||||
g.drawLine( 0, debugTitleBarHeight, getWidth(), debugTitleBarHeight );
|
||||
}
|
||||
if( debugHitTestSpots != null ) {
|
||||
g.setColor( Color.blue );
|
||||
for( Rectangle r : debugHitTestSpots )
|
||||
g.drawRect( r.x, r.y, r.width, r.height );
|
||||
}
|
||||
}
|
||||
debug*/
|
||||
|
||||
@Override
|
||||
protected void paintComponent( Graphics g ) {
|
||||
g.setColor( getBackground() );
|
||||
@@ -583,6 +626,12 @@ public class FlatTitlePane
|
||||
titleBarHeight--;
|
||||
|
||||
JBRCustomDecorations.setHitTestSpotsAndTitleBarHeight( window, hitTestSpots, titleBarHeight );
|
||||
|
||||
/*debug
|
||||
debugHitTestSpots = hitTestSpots;
|
||||
debugTitleBarHeight = titleBarHeight;
|
||||
repaint();
|
||||
debug*/
|
||||
}
|
||||
|
||||
protected void addJBRHitTestSpot( JComponent c, boolean subtractMenuBarMargins, List<Rectangle> hitTestSpots ) {
|
||||
@@ -599,6 +648,11 @@ public class FlatTitlePane
|
||||
hitTestSpots.add( r );
|
||||
}
|
||||
|
||||
/*debug
|
||||
private List<Rectangle> debugHitTestSpots;
|
||||
private int debugTitleBarHeight;
|
||||
debug*/
|
||||
|
||||
//---- class TitlePaneBorder ----------------------------------------------
|
||||
|
||||
protected class FlatTitlePaneBorder
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.ButtonModel;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.UIManager;
|
||||
@@ -50,18 +49,17 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
* @uiDefault ToggleButton.startBackground Color optional; if set, a gradient paint is used and ToggleButton.background is ignored
|
||||
* @uiDefault ToggleButton.endBackground Color optional; if set, a gradient paint is used
|
||||
* @uiDefault ToggleButton.pressedBackground Color
|
||||
* @uiDefault ToggleButton.disabledBackground Color optional
|
||||
* @uiDefault ToggleButton.disabledText Color
|
||||
* @uiDefault ToggleButton.toolbar.hoverBackground Color
|
||||
* @uiDefault ToggleButton.toolbar.pressedBackground Color
|
||||
*
|
||||
* <!-- FlatToggleButtonUI -->
|
||||
*
|
||||
* @uiDefault ToggleButton.selectedBackground Color
|
||||
* @uiDefault ToggleButton.selectedForeground Color
|
||||
* @uiDefault ToggleButton.disabledBackground Color optional
|
||||
* @uiDefault ToggleButton.disabledText Color
|
||||
* @uiDefault ToggleButton.disabledSelectedBackground Color
|
||||
* @uiDefault ToggleButton.toolbar.hoverBackground Color
|
||||
* @uiDefault ToggleButton.toolbar.pressedBackground Color
|
||||
* @uiDefault ToggleButton.toolbar.selectedBackground Color
|
||||
*
|
||||
* <!-- FlatToggleButtonUI -->
|
||||
*
|
||||
* @uiDefault ToggleButton.tab.underlineHeight int
|
||||
* @uiDefault ToggleButton.tab.underlineColor Color
|
||||
* @uiDefault ToggleButton.tab.disabledUnderlineColor Color
|
||||
@@ -75,12 +73,6 @@ import com.formdev.flatlaf.util.UIScale;
|
||||
public class FlatToggleButtonUI
|
||||
extends FlatButtonUI
|
||||
{
|
||||
protected Color selectedBackground;
|
||||
protected Color selectedForeground;
|
||||
protected Color disabledSelectedBackground;
|
||||
|
||||
protected Color toolbarSelectedBackground;
|
||||
|
||||
protected int tabUnderlineHeight;
|
||||
protected Color tabUnderlineColor;
|
||||
protected Color tabDisabledUnderlineColor;
|
||||
@@ -108,12 +100,6 @@ public class FlatToggleButtonUI
|
||||
super.installDefaults( b );
|
||||
|
||||
if( !defaults_initialized ) {
|
||||
selectedBackground = UIManager.getColor( "ToggleButton.selectedBackground" );
|
||||
selectedForeground = UIManager.getColor( "ToggleButton.selectedForeground" );
|
||||
disabledSelectedBackground = UIManager.getColor( "ToggleButton.disabledSelectedBackground" );
|
||||
|
||||
toolbarSelectedBackground = UIManager.getColor( "ToggleButton.toolbar.selectedBackground" );
|
||||
|
||||
tabUnderlineHeight = UIManager.getInt( "ToggleButton.tab.underlineHeight" );
|
||||
tabUnderlineColor = UIManager.getColor( "ToggleButton.tab.underlineColor" );
|
||||
tabDisabledUnderlineColor = UIManager.getColor( "ToggleButton.tab.disabledUnderlineColor" );
|
||||
@@ -185,30 +171,4 @@ public class FlatToggleButtonUI
|
||||
} else
|
||||
super.paintBackground( g, c );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getBackground( JComponent c ) {
|
||||
ButtonModel model = ((AbstractButton)c).getModel();
|
||||
|
||||
if( model.isSelected() ) {
|
||||
// in toolbar use same colors for disabled and enabled because
|
||||
// we assume that toolbar icon is shown disabled
|
||||
boolean toolBarButton = isToolBarButton( c );
|
||||
return buttonStateColor( c,
|
||||
toolBarButton ? toolbarSelectedBackground : selectedBackground,
|
||||
toolBarButton ? toolbarSelectedBackground : disabledSelectedBackground,
|
||||
null, null,
|
||||
toolBarButton ? toolbarPressedBackground : pressedBackground );
|
||||
}
|
||||
|
||||
return super.getBackground( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Color getForeground( JComponent c ) {
|
||||
if( c.isEnabled() && ((AbstractButton)c).isSelected() && !isToolBarButton( c ) )
|
||||
return selectedForeground;
|
||||
|
||||
return super.getForeground( c );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.awt.geom.Rectangle2D;
|
||||
import java.awt.geom.RoundRectangle2D;
|
||||
import java.util.function.Consumer;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
@@ -137,11 +138,21 @@ public class FlatUIUtils
|
||||
}
|
||||
|
||||
public static boolean isCellEditor( Component c ) {
|
||||
// check whether used as cell editor in file chooser
|
||||
// Tree.cellEditor is set in sun.swing.FilePane.editFileName()
|
||||
// check whether used in cell editor (check 3 levels up)
|
||||
Component c2 = c;
|
||||
for( int i = 0; i <= 2 && c2 != null; i++ ) {
|
||||
Container parent = c2.getParent();
|
||||
if( parent instanceof JTable && ((JTable)parent).getEditorComponent() == c2 )
|
||||
return true;
|
||||
|
||||
c2 = parent;
|
||||
}
|
||||
|
||||
// check whether used as cell editor
|
||||
// Table.editor is set in JTable.GenericEditor constructor
|
||||
// Tree.cellEditor is set in sun.swing.FilePane.editFileName()
|
||||
String name = c.getName();
|
||||
if( "Tree.cellEditor".equals( name ) || "Table.editor".equals( name ) )
|
||||
if( "Table.editor".equals( name ) || "Tree.cellEditor".equals( name ) )
|
||||
return true;
|
||||
|
||||
// for using combo box as cell editor in table
|
||||
@@ -159,9 +170,11 @@ public class FlatUIUtils
|
||||
keyboardFocusManager.getActiveWindow() == SwingUtilities.windowForComponent( c );
|
||||
}
|
||||
|
||||
public static boolean isRoundRect( Component c ) {
|
||||
return c instanceof JComponent && FlatClientProperties.clientPropertyBoolean(
|
||||
(JComponent) c, FlatClientProperties.COMPONENT_ROUND_RECT, false );
|
||||
public static Boolean isRoundRect( Component c ) {
|
||||
return (c instanceof JComponent)
|
||||
? FlatClientProperties.clientPropertyBooleanStrict(
|
||||
(JComponent) c, FlatClientProperties.COMPONENT_ROUND_RECT, null )
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,6 +74,9 @@ controlDkShadow=lighten($controlShadow,10%)
|
||||
Button.background=#4c5052
|
||||
Button.hoverBackground=lighten($Button.background,3%,derived)
|
||||
Button.pressedBackground=lighten($Button.background,6%,derived)
|
||||
Button.selectedBackground=lighten($Button.background,10%,derived)
|
||||
Button.selectedForeground=@foreground
|
||||
Button.disabledSelectedBackground=lighten($Button.background,3%,derived)
|
||||
|
||||
Button.borderColor=#5e6060
|
||||
Button.disabledBorderColor=#5e6060
|
||||
@@ -92,6 +95,7 @@ Button.default.boldText=true
|
||||
|
||||
Button.toolbar.hoverBackground=lighten($Button.background,1%,derived)
|
||||
Button.toolbar.pressedBackground=lighten($Button.background,4%,derived)
|
||||
Button.toolbar.selectedBackground=lighten($Button.background,7%,derived)
|
||||
|
||||
|
||||
#---- CheckBox ----
|
||||
|
||||
@@ -75,6 +75,9 @@ Button.background=#ffffff
|
||||
Button.focusedBackground=#e3f1fa
|
||||
Button.hoverBackground=darken($Button.background,3%,derived)
|
||||
Button.pressedBackground=darken($Button.background,10%,derived)
|
||||
Button.selectedBackground=darken($Button.background,20%,derived)
|
||||
Button.selectedForeground=@foreground
|
||||
Button.disabledSelectedBackground=darken($Button.background,13%,derived)
|
||||
|
||||
Button.borderColor=$Component.borderColor
|
||||
Button.disabledBorderColor=$Component.disabledBorderColor
|
||||
@@ -94,6 +97,7 @@ Button.default.borderWidth=2
|
||||
|
||||
Button.toolbar.hoverBackground=darken($Button.background,12%,derived)
|
||||
Button.toolbar.pressedBackground=darken($Button.background,15%,derived)
|
||||
Button.toolbar.selectedBackground=$Button.selectedBackground
|
||||
|
||||
|
||||
#---- CheckBox ----
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.formdev.flatlaf.demo;
|
||||
|
||||
import java.awt.Component;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.DefaultEditorKit;
|
||||
import net.miginfocom.swing.*;
|
||||
@@ -114,14 +115,14 @@ class BasicComponentsPanel
|
||||
JScrollPane scrollPane12 = new JScrollPane();
|
||||
JTextPane textPane4 = new JTextPane();
|
||||
JTextPane textPane5 = new JTextPane();
|
||||
JLabel label3 = new JLabel();
|
||||
JTextField textField5 = new JTextField();
|
||||
JComboBox<String> comboBox7 = new JComboBox<>();
|
||||
JSpinner spinner3 = new JSpinner();
|
||||
JLabel label4 = new JLabel();
|
||||
JTextField textField7 = new JTextField();
|
||||
JComboBox<String> comboBox8 = new JComboBox<>();
|
||||
JSpinner spinner4 = new JSpinner();
|
||||
JLabel errorHintsLabel = new JLabel();
|
||||
JTextField errorHintsTextField = new JTextField();
|
||||
JComboBox<String> errorHintsComboBox = new JComboBox<>();
|
||||
JSpinner errorHintsSpinner = new JSpinner();
|
||||
JLabel warningHintsLabel = new JLabel();
|
||||
JTextField warningHintsTextField = new JTextField();
|
||||
JComboBox<String> warningHintsComboBox = new JComboBox<>();
|
||||
JSpinner warningHintsSpinner = new JSpinner();
|
||||
JPopupMenu popupMenu1 = new JPopupMenu();
|
||||
JMenuItem cutMenuItem = new JMenuItem();
|
||||
JMenuItem copyMenuItem = new JMenuItem();
|
||||
@@ -129,12 +130,12 @@ class BasicComponentsPanel
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
"hidemode 3",
|
||||
"insets dialog,hidemode 3",
|
||||
// columns
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[sizegroup 1]" +
|
||||
"[sizegroup 1]" +
|
||||
"[sizegroup 1]" +
|
||||
"[sizegroup 1]" +
|
||||
"[]" +
|
||||
"[]",
|
||||
// rows
|
||||
@@ -606,44 +607,44 @@ class BasicComponentsPanel
|
||||
textPane5.setText("No scroll pane");
|
||||
add(textPane5, "cell 5 11,growx");
|
||||
|
||||
//---- label3 ----
|
||||
label3.setText("Error hints:");
|
||||
add(label3, "cell 0 12");
|
||||
//---- errorHintsLabel ----
|
||||
errorHintsLabel.setText("Error hints:");
|
||||
add(errorHintsLabel, "cell 0 12");
|
||||
|
||||
//---- textField5 ----
|
||||
textField5.putClientProperty("JComponent.outline", "error");
|
||||
add(textField5, "cell 1 12,growx");
|
||||
//---- errorHintsTextField ----
|
||||
errorHintsTextField.putClientProperty("JComponent.outline", "error");
|
||||
add(errorHintsTextField, "cell 1 12,growx");
|
||||
|
||||
//---- comboBox7 ----
|
||||
comboBox7.putClientProperty("JComponent.outline", "error");
|
||||
comboBox7.setModel(new DefaultComboBoxModel<>(new String[] {
|
||||
//---- errorHintsComboBox ----
|
||||
errorHintsComboBox.putClientProperty("JComponent.outline", "error");
|
||||
errorHintsComboBox.setModel(new DefaultComboBoxModel<>(new String[] {
|
||||
"Editable"
|
||||
}));
|
||||
comboBox7.setEditable(true);
|
||||
add(comboBox7, "cell 2 12,growx");
|
||||
errorHintsComboBox.setEditable(true);
|
||||
add(errorHintsComboBox, "cell 2 12,growx");
|
||||
|
||||
//---- spinner3 ----
|
||||
spinner3.putClientProperty("JComponent.outline", "error");
|
||||
add(spinner3, "cell 3 12,growx");
|
||||
//---- errorHintsSpinner ----
|
||||
errorHintsSpinner.putClientProperty("JComponent.outline", "error");
|
||||
add(errorHintsSpinner, "cell 3 12,growx");
|
||||
|
||||
//---- label4 ----
|
||||
label4.setText("Warning hints:");
|
||||
add(label4, "cell 0 13");
|
||||
//---- warningHintsLabel ----
|
||||
warningHintsLabel.setText("Warning hints:");
|
||||
add(warningHintsLabel, "cell 0 13");
|
||||
|
||||
//---- textField7 ----
|
||||
textField7.putClientProperty("JComponent.outline", "warning");
|
||||
add(textField7, "cell 1 13,growx");
|
||||
//---- warningHintsTextField ----
|
||||
warningHintsTextField.putClientProperty("JComponent.outline", "warning");
|
||||
add(warningHintsTextField, "cell 1 13,growx");
|
||||
|
||||
//---- comboBox8 ----
|
||||
comboBox8.putClientProperty("JComponent.outline", "warning");
|
||||
comboBox8.setModel(new DefaultComboBoxModel<>(new String[] {
|
||||
//---- warningHintsComboBox ----
|
||||
warningHintsComboBox.putClientProperty("JComponent.outline", "warning");
|
||||
warningHintsComboBox.setModel(new DefaultComboBoxModel<>(new String[] {
|
||||
"Not editable"
|
||||
}));
|
||||
add(comboBox8, "cell 2 13,growx");
|
||||
add(warningHintsComboBox, "cell 2 13,growx");
|
||||
|
||||
//---- spinner4 ----
|
||||
spinner4.putClientProperty("JComponent.outline", "warning");
|
||||
add(spinner4, "cell 3 13,growx");
|
||||
//---- warningHintsSpinner ----
|
||||
warningHintsSpinner.putClientProperty("JComponent.outline", "warning");
|
||||
add(warningHintsSpinner, "cell 3 13,growx");
|
||||
|
||||
//======== popupMenu1 ========
|
||||
{
|
||||
@@ -668,6 +669,33 @@ class BasicComponentsPanel
|
||||
cutMenuItem.addActionListener( new DefaultEditorKit.CutAction() );
|
||||
copyMenuItem.addActionListener( new DefaultEditorKit.CopyAction() );
|
||||
pasteMenuItem.addActionListener( new DefaultEditorKit.PasteAction() );
|
||||
|
||||
if( FlatLafDemo.screenshotsMode ) {
|
||||
Component[] components = {
|
||||
button13, button14, button15, button16, comboBox5, comboBox6,
|
||||
textField6, passwordField5,
|
||||
|
||||
formattedTextFieldLabel, formattedTextField1, formattedTextField2, formattedTextField3, formattedTextField4, formattedTextField5,
|
||||
textAreaLabel, scrollPane1, scrollPane2, scrollPane3, scrollPane4, textArea5,
|
||||
editorPaneLabel, scrollPane5, scrollPane6, scrollPane7, scrollPane8, editorPane5,
|
||||
textPaneLabel, scrollPane9, scrollPane10, scrollPane11, scrollPane12, textPane5,
|
||||
|
||||
errorHintsLabel, errorHintsTextField, errorHintsComboBox, errorHintsSpinner,
|
||||
warningHintsLabel, warningHintsTextField, warningHintsComboBox, warningHintsSpinner,
|
||||
};
|
||||
|
||||
for( Component c : components )
|
||||
c.setVisible( false );
|
||||
|
||||
// move password fields one row up
|
||||
Component[] formattedTextFields = { formattedTextFieldLabel, formattedTextField1, formattedTextField2, formattedTextField3, formattedTextField4 };
|
||||
Component[] passwordFields = { passwordFieldLabel, passwordField1, passwordField2, passwordField3, passwordField4 };
|
||||
MigLayout layout = (MigLayout) getLayout();
|
||||
for( int i = 0; i < passwordFields.length; i++ ) {
|
||||
Object cons = layout.getComponentConstraints( formattedTextFields[i] );
|
||||
layout.setComponentConstraints( passwordFields[i], cons );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
|
||||
@@ -7,8 +7,8 @@ new FormModel {
|
||||
"JavaCodeGenerator.defaultVariableLocal": true
|
||||
}
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "hidemode 3"
|
||||
"$columnConstraints": "[][][][][][]"
|
||||
"$layoutConstraints": "insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[sizegroup 1][sizegroup 1][sizegroup 1][sizegroup 1][][]"
|
||||
"$rowConstraints": "[][][][][][][][][][][][]para[][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
@@ -592,19 +592,19 @@ new FormModel {
|
||||
"value": "cell 5 11,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label3"
|
||||
name: "errorHintsLabel"
|
||||
"text": "Error hints:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 12"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "textField5"
|
||||
name: "errorHintsTextField"
|
||||
"$client.JComponent.outline": "error"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 12,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||
name: "comboBox7"
|
||||
name: "errorHintsComboBox"
|
||||
"$client.JComponent.outline": "error"
|
||||
"model": new javax.swing.DefaultComboBoxModel {
|
||||
selectedItem: "Editable"
|
||||
@@ -615,25 +615,25 @@ new FormModel {
|
||||
"value": "cell 2 12,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JSpinner" ) {
|
||||
name: "spinner3"
|
||||
name: "errorHintsSpinner"
|
||||
"$client.JComponent.outline": "error"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 12,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label4"
|
||||
name: "warningHintsLabel"
|
||||
"text": "Warning hints:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 13"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JTextField" ) {
|
||||
name: "textField7"
|
||||
name: "warningHintsTextField"
|
||||
"$client.JComponent.outline": "warning"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 13,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JComboBox" ) {
|
||||
name: "comboBox8"
|
||||
name: "warningHintsComboBox"
|
||||
"$client.JComponent.outline": "warning"
|
||||
"model": new javax.swing.DefaultComboBoxModel {
|
||||
selectedItem: "Not editable"
|
||||
@@ -643,7 +643,7 @@ new FormModel {
|
||||
"value": "cell 2 13,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JSpinner" ) {
|
||||
name: "spinner4"
|
||||
name: "warningHintsSpinner"
|
||||
"$client.JComponent.outline": "warning"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 13,growx"
|
||||
|
||||
@@ -30,6 +30,9 @@ import com.formdev.flatlaf.*;
|
||||
import com.formdev.flatlaf.extras.FlatAnimatedLafChange;
|
||||
import com.formdev.flatlaf.util.SystemInfo;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
import net.miginfocom.layout.ConstraintParser;
|
||||
import net.miginfocom.layout.LC;
|
||||
import net.miginfocom.layout.UnitValue;
|
||||
import net.miginfocom.swing.*;
|
||||
|
||||
/**
|
||||
@@ -44,6 +47,18 @@ class ControlBar
|
||||
ControlBar() {
|
||||
initComponents();
|
||||
|
||||
// remove top insets
|
||||
MigLayout layout = (MigLayout) getLayout();
|
||||
LC lc = ConstraintParser.parseLayoutConstraint( (String) layout.getLayoutConstraints() );
|
||||
UnitValue[] insets = lc.getInsets();
|
||||
lc.setInsets( new UnitValue[] {
|
||||
new UnitValue( 0, UnitValue.PIXEL, null ),
|
||||
insets[1],
|
||||
insets[2],
|
||||
insets[3]
|
||||
} );
|
||||
layout.setLayoutConstraints( lc );
|
||||
|
||||
// initialize look and feels combo box
|
||||
DefaultComboBoxModel<LookAndFeelInfo> lafModel = new DefaultComboBoxModel<>();
|
||||
lafModel.addElement( new LookAndFeelInfo( "Flat Light (F1)", FlatLightLaf.class.getName() ) );
|
||||
|
||||
@@ -20,11 +20,13 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.prefs.Preferences;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.DefaultEditorKit;
|
||||
import javax.swing.text.StyleContext;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.demo.HintManager.Hint;
|
||||
import com.formdev.flatlaf.demo.extras.*;
|
||||
import com.formdev.flatlaf.demo.intellijthemes.*;
|
||||
import com.formdev.flatlaf.extras.FlatAnimatedLafChange;
|
||||
@@ -57,6 +59,35 @@ class DemoFrame
|
||||
|
||||
if( tabIndex >= 0 && tabIndex < tabbedPane.getTabCount() && tabIndex != tabbedPane.getSelectedIndex() )
|
||||
tabbedPane.setSelectedIndex( tabIndex );
|
||||
|
||||
SwingUtilities.invokeLater( () -> {
|
||||
showHints();
|
||||
} );
|
||||
}
|
||||
|
||||
private void showHints() {
|
||||
Hint fontMenuHint = new Hint(
|
||||
"Use 'Font' menu to increase/decrease font size or try different fonts.",
|
||||
fontMenu, SwingConstants.BOTTOM, "hint.fontMenu", null );
|
||||
|
||||
Hint optionsMenuHint = new Hint(
|
||||
"Use 'Options' menu to try out various FlatLaf options.",
|
||||
optionsMenu, SwingConstants.BOTTOM, "hint.optionsMenu", fontMenuHint );
|
||||
|
||||
Hint themesHint = new Hint(
|
||||
"Use 'Themes' list to try out various themes.",
|
||||
themesPanel, SwingConstants.LEFT, "hint.themesPanel", optionsMenuHint );
|
||||
|
||||
HintManager.showHint( themesHint );
|
||||
}
|
||||
|
||||
private void clearHints() {
|
||||
HintManager.hideAllHints();
|
||||
|
||||
Preferences state = DemoPrefs.getState();
|
||||
state.remove( "hint.fontMenu" );
|
||||
state.remove( "hint.optionsMenu" );
|
||||
state.remove( "hint.themesPanel" );
|
||||
}
|
||||
|
||||
private void exitActionPerformed() {
|
||||
@@ -110,6 +141,11 @@ class DemoFrame
|
||||
System.setProperty( "flatlaf.animatedLafChange", String.valueOf( animatedLafChangeMenuItem.isSelected() ) );
|
||||
}
|
||||
|
||||
private void showHintsChanged() {
|
||||
clearHints();
|
||||
showHints();
|
||||
}
|
||||
|
||||
private void fontFamilyChanged( ActionEvent e ) {
|
||||
String fontFamily = e.getActionCommand();
|
||||
|
||||
@@ -251,12 +287,13 @@ class DemoFrame
|
||||
JMenuItem restoreFontMenuItem = new JMenuItem();
|
||||
JMenuItem incrFontMenuItem = new JMenuItem();
|
||||
JMenuItem decrFontMenuItem = new JMenuItem();
|
||||
JMenu optionsMenu = new JMenu();
|
||||
optionsMenu = new JMenu();
|
||||
windowDecorationsCheckBoxMenuItem = new JCheckBoxMenuItem();
|
||||
menuBarEmbeddedCheckBoxMenuItem = new JCheckBoxMenuItem();
|
||||
underlineMenuSelectionMenuItem = new JCheckBoxMenuItem();
|
||||
alwaysShowMnemonicsMenuItem = new JCheckBoxMenuItem();
|
||||
animatedLafChangeMenuItem = new JCheckBoxMenuItem();
|
||||
JMenuItem showHintsMenuItem = new JMenuItem();
|
||||
JMenu helpMenu = new JMenu();
|
||||
JMenuItem aboutMenuItem = new JMenuItem();
|
||||
JToolBar toolBar1 = new JToolBar();
|
||||
@@ -276,7 +313,7 @@ class DemoFrame
|
||||
OptionPanePanel optionPanePanel = new OptionPanePanel();
|
||||
ExtrasPanel extrasPanel1 = new ExtrasPanel();
|
||||
controlBar = new ControlBar();
|
||||
IJThemesPanel themesPanel = new IJThemesPanel();
|
||||
themesPanel = new IJThemesPanel();
|
||||
|
||||
//======== this ========
|
||||
setTitle("FlatLaf Demo");
|
||||
@@ -516,6 +553,11 @@ class DemoFrame
|
||||
animatedLafChangeMenuItem.setSelected(true);
|
||||
animatedLafChangeMenuItem.addActionListener(e -> animatedLafChangeChanged());
|
||||
optionsMenu.add(animatedLafChangeMenuItem);
|
||||
|
||||
//---- showHintsMenuItem ----
|
||||
showHintsMenuItem.setText("Show hints");
|
||||
showHintsMenuItem.addActionListener(e -> showHintsChanged());
|
||||
optionsMenu.add(showHintsMenuItem);
|
||||
}
|
||||
menuBar1.add(optionsMenu);
|
||||
|
||||
@@ -631,6 +673,7 @@ class DemoFrame
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
private JMenu fontMenu;
|
||||
private JMenu optionsMenu;
|
||||
private JCheckBoxMenuItem windowDecorationsCheckBoxMenuItem;
|
||||
private JCheckBoxMenuItem menuBarEmbeddedCheckBoxMenuItem;
|
||||
private JCheckBoxMenuItem underlineMenuSelectionMenuItem;
|
||||
@@ -638,5 +681,6 @@ class DemoFrame
|
||||
private JCheckBoxMenuItem animatedLafChangeMenuItem;
|
||||
private JTabbedPane tabbedPane;
|
||||
private ControlBar controlBar;
|
||||
private IJThemesPanel themesPanel;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "14.0.2" encoding: "UTF-8"
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
@@ -114,6 +114,9 @@ new FormModel {
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.demo.intellijthemes.IJThemesPanel" ) {
|
||||
name: "themesPanel"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class java.lang.String ) {
|
||||
"value": "East"
|
||||
} )
|
||||
@@ -322,6 +325,9 @@ new FormModel {
|
||||
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
|
||||
name: "optionsMenu"
|
||||
"text": "Options"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
|
||||
name: "windowDecorationsCheckBoxMenuItem"
|
||||
"text": "Window decorations"
|
||||
@@ -365,6 +371,11 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "animatedLafChangeChanged", false ) )
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JMenuItem" ) {
|
||||
name: "showHintsMenuItem"
|
||||
"text": "Show hints"
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showHintsChanged", false ) )
|
||||
} )
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
|
||||
name: "helpMenu"
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
package com.formdev.flatlaf.demo;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.SwingUtilities;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.extras.FlatInspector;
|
||||
import com.formdev.flatlaf.util.SystemInfo;
|
||||
|
||||
@@ -30,6 +32,8 @@ public class FlatLafDemo
|
||||
static final String PREFS_ROOT_PATH = "/flatlaf-demo";
|
||||
static final String KEY_TAB = "tab";
|
||||
|
||||
static boolean screenshotsMode = Boolean.parseBoolean( System.getProperty( "flatlaf.demo.screenshotsMode" ) );
|
||||
|
||||
public static void main( String[] args ) {
|
||||
// on macOS enable screen menu bar
|
||||
if( SystemInfo.isMacOS && System.getProperty( "apple.laf.useScreenMenuBar" ) == null )
|
||||
@@ -42,6 +46,9 @@ public class FlatLafDemo
|
||||
JFrame.setDefaultLookAndFeelDecorated( true );
|
||||
JDialog.setDefaultLookAndFeelDecorated( true );
|
||||
|
||||
// application specific UI defaults
|
||||
FlatLaf.registerCustomDefaultsSource( "com.formdev.flatlaf.demo" );
|
||||
|
||||
// set look and feel
|
||||
DemoPrefs.initLaf( args );
|
||||
|
||||
@@ -51,6 +58,9 @@ public class FlatLafDemo
|
||||
// create frame
|
||||
DemoFrame frame = new DemoFrame();
|
||||
|
||||
if( FlatLafDemo.screenshotsMode )
|
||||
frame.setPreferredSize( new Dimension( 1280, 620 ) );
|
||||
|
||||
// show frame
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo( null );
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
/*
|
||||
* 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.demo;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.*;
|
||||
import com.formdev.flatlaf.ui.FlatDropShadowBorder;
|
||||
import com.formdev.flatlaf.ui.FlatPopupMenuBorder;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
import net.miginfocom.swing.*;
|
||||
|
||||
/**
|
||||
* @author Karl Tauber
|
||||
*/
|
||||
class HintManager
|
||||
{
|
||||
private static final List<HintPanel> hintPanels = new ArrayList<>();
|
||||
|
||||
static void showHint( Hint hint ) {
|
||||
// check whether user already closed the hint
|
||||
if( DemoPrefs.getState().getBoolean( hint.prefsKey, false ) ) {
|
||||
if( hint.nextHint != null )
|
||||
showHint( hint.nextHint );
|
||||
return;
|
||||
}
|
||||
|
||||
HintPanel hintPanel = new HintPanel( hint );
|
||||
hintPanel.showHint();
|
||||
|
||||
hintPanels.add( hintPanel );
|
||||
}
|
||||
|
||||
static void hideAllHints() {
|
||||
HintPanel[] hintPanels2 = hintPanels.toArray( new HintPanel[hintPanels.size()] );
|
||||
for( HintPanel hintPanel : hintPanels2 )
|
||||
hintPanel.hideHint();
|
||||
}
|
||||
|
||||
//---- class HintPanel ----------------------------------------------------
|
||||
|
||||
static class Hint
|
||||
{
|
||||
private final String message;
|
||||
private final Component owner;
|
||||
private final int position;
|
||||
private final String prefsKey;
|
||||
private final Hint nextHint;
|
||||
|
||||
Hint( String message, Component owner, int position, String prefsKey, Hint nextHint ) {
|
||||
this.message = message;
|
||||
this.owner = owner;
|
||||
this.position = position;
|
||||
this.prefsKey = prefsKey;
|
||||
this.nextHint = nextHint;
|
||||
}
|
||||
}
|
||||
|
||||
//---- class HintPanel ----------------------------------------------------
|
||||
|
||||
private static class HintPanel
|
||||
extends JPanel
|
||||
{
|
||||
private final Hint hint;
|
||||
|
||||
private JPanel popup;
|
||||
|
||||
private HintPanel( Hint hint ) {
|
||||
this.hint = hint;
|
||||
|
||||
initComponents();
|
||||
|
||||
hintLabel.setText( "<html>" + hint.message + "</html>" );
|
||||
|
||||
// grab all mouse events to avoid that components overlapped
|
||||
// by the hint panel receive them
|
||||
addMouseListener( new MouseAdapter() {} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
|
||||
setBackground( UIManager.getColor( "HintPanel.backgroundColor" ) );
|
||||
setBorder( new FlatPopupMenuBorder() );
|
||||
}
|
||||
|
||||
void showHint() {
|
||||
JRootPane rootPane = SwingUtilities.getRootPane( hint.owner );
|
||||
if( rootPane == null )
|
||||
return;
|
||||
|
||||
JLayeredPane layeredPane = rootPane.getLayeredPane();
|
||||
|
||||
// create a popup panel that has a drop shadow
|
||||
popup = new JPanel( new BorderLayout() ) {
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
|
||||
setBorder( new FlatDropShadowBorder(
|
||||
UIManager.getColor( "Popup.dropShadowColor" ),
|
||||
UIManager.getInsets( "Popup.dropShadowInsets" ),
|
||||
FlatUIUtils.getUIFloat( "Popup.dropShadowOpacity", 0.5f ) ) );
|
||||
|
||||
// use invokeLater because at this time the UI delegates
|
||||
// of child components are not yet updated
|
||||
EventQueue.invokeLater( () -> {
|
||||
validate();
|
||||
setSize( getPreferredSize() );
|
||||
} );
|
||||
}
|
||||
};
|
||||
popup.setOpaque( false );
|
||||
popup.add( this );
|
||||
|
||||
// calculate x/y location for hint popup
|
||||
Point pt = SwingUtilities.convertPoint( hint.owner, 0, 0, layeredPane );
|
||||
int x = pt.x;
|
||||
int y = pt.y;
|
||||
Dimension size = popup.getPreferredSize();
|
||||
int gap = UIScale.scale( 6 );
|
||||
|
||||
switch( hint.position ) {
|
||||
case SwingConstants.LEFT:
|
||||
x -= size.width + gap;
|
||||
break;
|
||||
|
||||
case SwingConstants.TOP:
|
||||
y -= size.height + gap;
|
||||
break;
|
||||
|
||||
case SwingConstants.RIGHT:
|
||||
x += hint.owner.getWidth() + gap;
|
||||
break;
|
||||
|
||||
case SwingConstants.BOTTOM:
|
||||
y += hint.owner.getHeight() + gap;
|
||||
break;
|
||||
}
|
||||
|
||||
// set hint popup size and show it
|
||||
popup.setBounds( x, y, size.width, size.height );
|
||||
layeredPane.add( popup, JLayeredPane.POPUP_LAYER );
|
||||
}
|
||||
|
||||
void hideHint() {
|
||||
if( popup != null ) {
|
||||
Container parent = popup.getParent();
|
||||
if( parent != null ) {
|
||||
parent.remove( popup );
|
||||
parent.repaint( popup.getX(), popup.getY(), popup.getWidth(), popup.getHeight() );
|
||||
}
|
||||
}
|
||||
|
||||
hintPanels.remove( this );
|
||||
}
|
||||
|
||||
private void gotIt() {
|
||||
// hide hint
|
||||
hideHint();
|
||||
|
||||
// remember that user closed the hint
|
||||
DemoPrefs.getState().putBoolean( hint.prefsKey, true );
|
||||
|
||||
// show next hint (if any)
|
||||
if( hint.nextHint != null )
|
||||
HintManager.showHint( hint.nextHint );
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
hintLabel = new JLabel();
|
||||
gotItButton = new JButton();
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
"insets dialog,hidemode 3",
|
||||
// columns
|
||||
"[::200,fill]",
|
||||
// rows
|
||||
"[]para" +
|
||||
"[]"));
|
||||
|
||||
//---- hintLabel ----
|
||||
hintLabel.setText("hint");
|
||||
add(hintLabel, "cell 0 0");
|
||||
|
||||
//---- gotItButton ----
|
||||
gotItButton.setText("Got it!");
|
||||
gotItButton.setFocusable(false);
|
||||
gotItButton.addActionListener(e -> gotIt());
|
||||
add(gotItButton, "cell 0 1,alignx right,growx 0");
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
private JLabel hintLabel;
|
||||
private JButton gotItButton;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
root: new FormRoot {
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[::200,fill]"
|
||||
"$rowConstraints": "[]para[]"
|
||||
} ) {
|
||||
name: "panel"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.className": "HintPanel"
|
||||
}
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "hintLabel"
|
||||
"text": "hint"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "gotItButton"
|
||||
"text": "Got it!"
|
||||
"focusable": false
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "gotIt", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1,alignx right,growx 0"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 400, 300 )
|
||||
} )
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,6 @@ class MoreComponentsPanel
|
||||
JSeparator separator2 = new JSeparator();
|
||||
JSlider slider2 = new JSlider();
|
||||
JSlider slider4 = new JSlider();
|
||||
JScrollPane scrollPane14 = new JScrollPane();
|
||||
progressBar3 = new JProgressBar();
|
||||
progressBar4 = new JProgressBar();
|
||||
JToolBar toolBar2 = new JToolBar();
|
||||
@@ -67,11 +66,12 @@ class MoreComponentsPanel
|
||||
JButton button10 = new JButton();
|
||||
JButton button11 = new JButton();
|
||||
JToggleButton toggleButton7 = new JToggleButton();
|
||||
JPanel panel2 = new JPanel();
|
||||
JLabel scrollBarLabel = new JLabel();
|
||||
JScrollBar scrollBar1 = new JScrollBar();
|
||||
JLabel label4 = new JLabel();
|
||||
JScrollBar scrollBar4 = new JScrollBar();
|
||||
JPanel panel3 = new JPanel();
|
||||
JLabel label4 = new JLabel();
|
||||
JLabel label3 = new JLabel();
|
||||
JScrollPane scrollPane15 = new JScrollPane();
|
||||
JEditorPane editorPane6 = new JEditorPane();
|
||||
@@ -81,7 +81,6 @@ class MoreComponentsPanel
|
||||
JScrollBar scrollBar6 = new JScrollBar();
|
||||
JLabel separatorLabel = new JLabel();
|
||||
JSeparator separator1 = new JSeparator();
|
||||
JPanel panel2 = new JPanel();
|
||||
JLabel sliderLabel = new JLabel();
|
||||
JSlider slider1 = new JSlider();
|
||||
JSlider slider6 = new JSlider();
|
||||
@@ -105,13 +104,12 @@ class MoreComponentsPanel
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
"hidemode 3",
|
||||
"insets dialog,hidemode 3",
|
||||
// columns
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]",
|
||||
// rows
|
||||
"[]" +
|
||||
@@ -142,7 +140,7 @@ class MoreComponentsPanel
|
||||
}
|
||||
scrollPane13.setViewportView(panel1);
|
||||
}
|
||||
add(scrollPane13, "cell 1 0,grow,width 70,height 70");
|
||||
add(scrollPane13, "cell 1 0,grow,width 70,height 40");
|
||||
add(scrollBar2, "cell 2 0 1 6,growy");
|
||||
|
||||
//---- scrollBar3 ----
|
||||
@@ -165,7 +163,7 @@ class MoreComponentsPanel
|
||||
//---- slider2 ----
|
||||
slider2.setOrientation(SwingConstants.VERTICAL);
|
||||
slider2.setValue(30);
|
||||
add(slider2, "cell 2 0 1 6,growy");
|
||||
add(slider2, "cell 2 0 1 6,growy,height 100");
|
||||
|
||||
//---- slider4 ----
|
||||
slider4.setMinorTickSpacing(10);
|
||||
@@ -174,19 +172,18 @@ class MoreComponentsPanel
|
||||
slider4.setPaintLabels(true);
|
||||
slider4.setOrientation(SwingConstants.VERTICAL);
|
||||
slider4.setValue(30);
|
||||
add(slider4, "cell 2 0 1 6,growy");
|
||||
add(scrollPane14, "cell 3 0,grow");
|
||||
add(slider4, "cell 2 0 1 6,growy,height 100");
|
||||
|
||||
//---- progressBar3 ----
|
||||
progressBar3.setOrientation(SwingConstants.VERTICAL);
|
||||
progressBar3.setValue(60);
|
||||
add(progressBar3, "cell 4 0 1 6,growy");
|
||||
add(progressBar3, "cell 2 0 1 6,growy");
|
||||
|
||||
//---- progressBar4 ----
|
||||
progressBar4.setOrientation(SwingConstants.VERTICAL);
|
||||
progressBar4.setValue(60);
|
||||
progressBar4.setStringPainted(true);
|
||||
add(progressBar4, "cell 4 0 1 6,growy");
|
||||
add(progressBar4, "cell 2 0 1 6,growy");
|
||||
|
||||
//======== toolBar2 ========
|
||||
{
|
||||
@@ -209,7 +206,14 @@ class MoreComponentsPanel
|
||||
toggleButton7.setIcon(UIManager.getIcon("Tree.closedIcon"));
|
||||
toolBar2.add(toggleButton7);
|
||||
}
|
||||
add(toolBar2, "cell 4 0 1 6,growy");
|
||||
add(toolBar2, "cell 2 0 1 6,growy");
|
||||
|
||||
//======== panel2 ========
|
||||
{
|
||||
panel2.setBorder(new TitledBorder("TitledBorder"));
|
||||
panel2.setLayout(new FlowLayout());
|
||||
}
|
||||
add(panel2, "cell 3 0 1 6,grow");
|
||||
|
||||
//---- scrollBarLabel ----
|
||||
scrollBarLabel.setText("JScrollBar:");
|
||||
@@ -219,10 +223,6 @@ class MoreComponentsPanel
|
||||
scrollBar1.setOrientation(Adjustable.HORIZONTAL);
|
||||
add(scrollBar1, "cell 1 1,growx");
|
||||
|
||||
//---- label4 ----
|
||||
label4.setText("HTML:");
|
||||
add(label4, "cell 5 1");
|
||||
|
||||
//---- scrollBar4 ----
|
||||
scrollBar4.setOrientation(Adjustable.HORIZONTAL);
|
||||
scrollBar4.setEnabled(false);
|
||||
@@ -238,11 +238,16 @@ class MoreComponentsPanel
|
||||
// rows
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- label4 ----
|
||||
label4.setText("HTML:");
|
||||
panel3.add(label4, "cell 0 0");
|
||||
|
||||
//---- label3 ----
|
||||
label3.setText("<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a></html>");
|
||||
panel3.add(label3, "cell 0 0");
|
||||
panel3.add(label3, "cell 0 1");
|
||||
|
||||
//======== scrollPane15 ========
|
||||
{
|
||||
@@ -252,7 +257,7 @@ class MoreComponentsPanel
|
||||
editorPane6.setText("JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a>");
|
||||
scrollPane15.setViewportView(editorPane6);
|
||||
}
|
||||
panel3.add(scrollPane15, "cell 0 1,grow");
|
||||
panel3.add(scrollPane15, "cell 0 2,grow");
|
||||
|
||||
//======== scrollPane16 ========
|
||||
{
|
||||
@@ -262,9 +267,9 @@ class MoreComponentsPanel
|
||||
textPane6.setText("JTextPane HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a>");
|
||||
scrollPane16.setViewportView(textPane6);
|
||||
}
|
||||
panel3.add(scrollPane16, "cell 0 2,grow");
|
||||
panel3.add(scrollPane16, "cell 0 3,grow");
|
||||
}
|
||||
add(panel3, "cell 5 2 1 9,aligny top,growy 0");
|
||||
add(panel3, "cell 4 0 1 8,aligny top,growy 0");
|
||||
|
||||
//---- scrollBar5 ----
|
||||
scrollBar5.setOrientation(Adjustable.HORIZONTAL);
|
||||
@@ -282,13 +287,6 @@ class MoreComponentsPanel
|
||||
add(separatorLabel, "cell 0 5");
|
||||
add(separator1, "cell 1 5,growx");
|
||||
|
||||
//======== panel2 ========
|
||||
{
|
||||
panel2.setBorder(new TitledBorder("TitledBorder"));
|
||||
panel2.setLayout(new FlowLayout());
|
||||
}
|
||||
add(panel2, "cell 3 5,grow");
|
||||
|
||||
//---- sliderLabel ----
|
||||
sliderLabel.setText("JSlider:");
|
||||
add(sliderLabel, "cell 0 6");
|
||||
@@ -389,6 +387,17 @@ class MoreComponentsPanel
|
||||
}
|
||||
add(toolBar1, "cell 1 10 3 1,growx");
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
|
||||
if( FlatLafDemo.screenshotsMode ) {
|
||||
Component[] components = new Component[] {
|
||||
indeterminateCheckBox,
|
||||
toolTipLabel, toolTip1, toolTip2,
|
||||
toolBarLabel, toolBar1, toolBar2,
|
||||
};
|
||||
|
||||
for( Component c : components )
|
||||
c.setVisible( false );
|
||||
}
|
||||
}
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
JFDML JFormDesigner: "7.0.1.0.272" Java: "13.0.2" encoding: "UTF-8"
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
@@ -7,8 +7,8 @@ new FormModel {
|
||||
"JavaCodeGenerator.defaultVariableLocal": true
|
||||
}
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "hidemode 3"
|
||||
"$columnConstraints": "[][][][][][]"
|
||||
"$layoutConstraints": "insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[][][][][]"
|
||||
"$rowConstraints": "[][][][][][][][][][][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
@@ -27,7 +27,7 @@ new FormModel {
|
||||
"preferredSize": new java.awt.Dimension( 200, 200 )
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0,grow,width 70,height 70"
|
||||
"value": "cell 1 0,grow,width 70,height 40"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JScrollBar" ) {
|
||||
name: "scrollBar2"
|
||||
@@ -64,7 +64,7 @@ new FormModel {
|
||||
"orientation": 1
|
||||
"value": 30
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 0 1 6,growy"
|
||||
"value": "cell 2 0 1 6,growy,height 100"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JSlider" ) {
|
||||
name: "slider4"
|
||||
@@ -75,12 +75,7 @@ new FormModel {
|
||||
"orientation": 1
|
||||
"value": 30
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 0 1 6,growy"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane14"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 0,grow"
|
||||
"value": "cell 2 0 1 6,growy,height 100"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JProgressBar" ) {
|
||||
name: "progressBar3"
|
||||
@@ -90,7 +85,7 @@ new FormModel {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 4 0 1 6,growy"
|
||||
"value": "cell 2 0 1 6,growy"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JProgressBar" ) {
|
||||
name: "progressBar4"
|
||||
@@ -101,7 +96,7 @@ new FormModel {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 4 0 1 6,growy"
|
||||
"value": "cell 2 0 1 6,growy"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) {
|
||||
name: "toolBar2"
|
||||
@@ -126,7 +121,13 @@ new FormModel {
|
||||
"icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" )
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 4 0 1 6,growy"
|
||||
"value": "cell 2 0 1 6,growy"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
|
||||
name: "panel2"
|
||||
"border": new javax.swing.border.TitledBorder( "TitledBorder" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 0 1 6,grow"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "scrollBarLabel"
|
||||
@@ -140,12 +141,6 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 1,growx"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label4"
|
||||
"text": "HTML:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JScrollBar" ) {
|
||||
name: "scrollBar4"
|
||||
"orientation": 0
|
||||
@@ -155,16 +150,22 @@ new FormModel {
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[]"
|
||||
"$rowConstraints": "[][][]"
|
||||
"$rowConstraints": "[][][][]"
|
||||
"$layoutConstraints": "ltr,insets 0,hidemode 3"
|
||||
} ) {
|
||||
name: "panel3"
|
||||
"opaque": false
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label4"
|
||||
"text": "HTML:"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "label3"
|
||||
"text": "<html>JLabel HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a></html>"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
"value": "cell 0 1"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane15"
|
||||
@@ -174,7 +175,7 @@ new FormModel {
|
||||
"text": "JEditorPane HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a>"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 1,grow"
|
||||
"value": "cell 0 2,grow"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
|
||||
name: "scrollPane16"
|
||||
@@ -184,10 +185,10 @@ new FormModel {
|
||||
"text": "JTextPane HTML<br>Sample <b>content</b><br> <u>text</u> with <a href=\"#\">link</a>"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 2,grow"
|
||||
"value": "cell 0 3,grow"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 5 2 1 9,aligny top,growy 0"
|
||||
"value": "cell 4 0 1 8,aligny top,growy 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JScrollBar" ) {
|
||||
name: "scrollBar5"
|
||||
@@ -215,12 +216,6 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 5,growx"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) {
|
||||
name: "panel2"
|
||||
"border": new javax.swing.border.TitledBorder( "TitledBorder" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 5,grow"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "sliderLabel"
|
||||
"text": "JSlider:"
|
||||
@@ -365,7 +360,7 @@ new FormModel {
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 790, 715 )
|
||||
"size": new java.awt.Dimension( 700, 420 )
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,11 +205,11 @@ public class IJThemesPanel
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// select first theme if none selected
|
||||
if( themesList.getSelectedIndex() < 0 )
|
||||
themesList.setSelectedIndex( 0 );
|
||||
// select first theme if none selected
|
||||
if( themesList.getSelectedIndex() < 0 )
|
||||
themesList.setSelectedIndex( 0 );
|
||||
}
|
||||
|
||||
// scroll selection into visible area
|
||||
int sel = themesList.getSelectedIndex();
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
HintPanel.backgroundColor=darken(#ffffe1,80%)
|
||||
@@ -0,0 +1,17 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
HintPanel.backgroundColor=#ffffe1
|
||||
@@ -22,7 +22,7 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
implementation( project( ":flatlaf-core" ) )
|
||||
implementation( "com.formdev:svgSalamander:1.1.2.1" )
|
||||
implementation( "com.formdev:svgSalamander:1.1.2.3" )
|
||||
}
|
||||
|
||||
flatlafModuleInfo {
|
||||
|
||||
@@ -19,10 +19,10 @@ package com.formdev.flatlaf.extras;
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Window;
|
||||
import java.util.HashMap;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.RootPaneContainer;
|
||||
@@ -56,8 +56,10 @@ public class FlatAnimatedLafChange
|
||||
public static int resolution = 40;
|
||||
|
||||
private static Animator animator;
|
||||
private static final Map<JLayeredPane, JComponent> map = new HashMap<>();
|
||||
private static final Map<JLayeredPane, JComponent> oldUIsnapshots = new WeakHashMap<>();
|
||||
private static final Map<JLayeredPane, JComponent> newUIsnapshots = new WeakHashMap<>();
|
||||
private static float alpha;
|
||||
private static boolean inShowSnapshot;
|
||||
|
||||
/**
|
||||
* Create a snapshot of the old UI and shows it on top of the UI.
|
||||
@@ -73,16 +75,27 @@ public class FlatAnimatedLafChange
|
||||
|
||||
alpha = 1;
|
||||
|
||||
// show snapshot of old UI
|
||||
showSnapshot( true, oldUIsnapshots );
|
||||
}
|
||||
|
||||
private static void showSnapshot( boolean useAlpha, Map<JLayeredPane, JComponent> map ) {
|
||||
inShowSnapshot = true;
|
||||
|
||||
// create snapshots for all shown windows
|
||||
Window[] windows = Window.getWindows();
|
||||
for( Window window : windows ) {
|
||||
if( !(window instanceof RootPaneContainer) || !window.isShowing() )
|
||||
continue;
|
||||
|
||||
JLayeredPane layeredPane = ((RootPaneContainer)window).getLayeredPane();
|
||||
// create snapshot image
|
||||
// (using volatile image to have correct sub-pixel text rendering on Java 9+)
|
||||
VolatileImage snapshot = window.createVolatileImage( window.getWidth(), window.getHeight() );
|
||||
if( snapshot == null )
|
||||
continue;
|
||||
|
||||
// create snapshot image of layered pane
|
||||
Image snapshot = window.createImage( window.getWidth(), window.getHeight() );
|
||||
// paint window to snapshot image
|
||||
JLayeredPane layeredPane = ((RootPaneContainer)window).getLayeredPane();
|
||||
layeredPane.paint( snapshot.getGraphics() );
|
||||
|
||||
// create snapshot layer, which is added to layered pane and paints
|
||||
@@ -90,16 +103,32 @@ public class FlatAnimatedLafChange
|
||||
JComponent snapshotLayer = new JComponent() {
|
||||
@Override
|
||||
public void paint( Graphics g ) {
|
||||
((Graphics2D)g).setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha ) );
|
||||
if( inShowSnapshot || snapshot.contentsLost() )
|
||||
return;
|
||||
|
||||
if( useAlpha )
|
||||
((Graphics2D)g).setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, alpha ) );
|
||||
g.drawImage( snapshot, 0, 0, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNotify() {
|
||||
super.removeNotify();
|
||||
|
||||
// release system resources used by volatile image
|
||||
snapshot.flush();
|
||||
}
|
||||
};
|
||||
if( !useAlpha )
|
||||
snapshotLayer.setOpaque( true );
|
||||
snapshotLayer.setSize( layeredPane.getSize() );
|
||||
|
||||
// add image layer to layered pane
|
||||
layeredPane.add( snapshotLayer, JLayeredPane.DRAG_LAYER );
|
||||
layeredPane.add( snapshotLayer, Integer.valueOf( JLayeredPane.DRAG_LAYER + (useAlpha ? 2 : 1) ) );
|
||||
map.put( layeredPane, snapshotLayer );
|
||||
}
|
||||
|
||||
inShowSnapshot = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,9 +140,12 @@ public class FlatAnimatedLafChange
|
||||
if( !FlatSystemProperties.getBoolean( "flatlaf.animatedLafChange", true ) )
|
||||
return;
|
||||
|
||||
if( map.isEmpty() )
|
||||
if( oldUIsnapshots.isEmpty() )
|
||||
return;
|
||||
|
||||
// show snapshot of new UI
|
||||
showSnapshot( false, newUIsnapshots );
|
||||
|
||||
// create animator
|
||||
animator = new Animator( duration, fraction -> {
|
||||
if( fraction < 0.1 || fraction > 0.9 )
|
||||
@@ -122,7 +154,7 @@ public class FlatAnimatedLafChange
|
||||
alpha = 1f - fraction;
|
||||
|
||||
// repaint snapshots
|
||||
for( Map.Entry<JLayeredPane, JComponent> e : map.entrySet() ) {
|
||||
for( Map.Entry<JLayeredPane, JComponent> e : oldUIsnapshots.entrySet() ) {
|
||||
if( e.getKey().isShowing() )
|
||||
e.getValue().repaint();
|
||||
}
|
||||
@@ -136,6 +168,11 @@ public class FlatAnimatedLafChange
|
||||
}
|
||||
|
||||
private static void hideSnapshot() {
|
||||
hideSnapshot( oldUIsnapshots );
|
||||
hideSnapshot( newUIsnapshots );
|
||||
}
|
||||
|
||||
private static void hideSnapshot( Map<JLayeredPane, JComponent> map ) {
|
||||
// remove snapshots
|
||||
for( Map.Entry<JLayeredPane, JComponent> e : map.entrySet() ) {
|
||||
e.getKey().remove( e.getValue() );
|
||||
|
||||
@@ -50,11 +50,18 @@ public class FlatSVGIcon
|
||||
private static final SVGUniverse svgUniverse = new SVGUniverse();
|
||||
|
||||
private final String name;
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
private SVGDiagram diagram;
|
||||
private boolean dark;
|
||||
|
||||
public FlatSVGIcon( String name ) {
|
||||
this( name, null );
|
||||
}
|
||||
|
||||
public FlatSVGIcon( String name, ClassLoader classLoader ) {
|
||||
this.name = name;
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
private void update() {
|
||||
@@ -79,7 +86,14 @@ public class FlatSVGIcon
|
||||
int dotIndex = name.lastIndexOf( '.' );
|
||||
name = name.substring( 0, dotIndex ) + "_dark" + name.substring( dotIndex );
|
||||
}
|
||||
return FlatSVGIcon.class.getClassLoader().getResource( name );
|
||||
|
||||
ClassLoader cl = (classLoader != null) ? classLoader : FlatSVGIcon.class.getClassLoader();
|
||||
return cl.getResource( name );
|
||||
}
|
||||
|
||||
public boolean hasFound() {
|
||||
update();
|
||||
return diagram != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
},
|
||||
"ui": {
|
||||
"*": {
|
||||
"acceleratorForeground": "colorAcceleratorForeground",
|
||||
"acceleratorSelectionForeground": "colorAcceleratorSelectionForeground",
|
||||
"background": "colorBackground",
|
||||
"caretForeground": "colorForeground",
|
||||
"disabledForeground": "colorDisabledForeground",
|
||||
@@ -68,10 +70,7 @@
|
||||
"startBorderColor": "#476069"
|
||||
},
|
||||
"CheckBox": {},
|
||||
"CheckBoxMenuItem": {
|
||||
"acceleratorForeground": "colorAcceleratorForeground",
|
||||
"acceleratorSelectionForeground": "colorAcceleratorSelectionForeground"
|
||||
},
|
||||
"CheckBoxMenuItem": {},
|
||||
"ColorChooser": {
|
||||
"swatchesDefaultRecentColor": "colorBackground"
|
||||
},
|
||||
@@ -257,8 +256,6 @@
|
||||
"usedBackground": "#566C73"
|
||||
},
|
||||
"Menu": {
|
||||
"acceleratorForeground": "colorAcceleratorForeground",
|
||||
"acceleratorSelectionForeground": "colorAcceleratorSelectionForeground",
|
||||
"borderColor": "colorSeparator",
|
||||
"separatorColor": "colorSeparator"
|
||||
},
|
||||
@@ -372,10 +369,7 @@
|
||||
"trackColor": "#36525B"
|
||||
},
|
||||
"RadioButton": {},
|
||||
"RadioButtonMenuItem": {
|
||||
"acceleratorForeground": "colorAcceleratorForeground",
|
||||
"acceleratorSelectionForeground": "colorAcceleratorSelectionForeground"
|
||||
},
|
||||
"RadioButtonMenuItem": {},
|
||||
"ScrollBar": {
|
||||
"background": "#14414F",
|
||||
"hoverThumbBorderColor": "#0A384459",
|
||||
@@ -441,6 +435,11 @@
|
||||
"Separator": {
|
||||
"separatorColor": "colorSeparator"
|
||||
},
|
||||
"Settings": {
|
||||
"Spotlight": {
|
||||
"borderColor": "#9A670064"
|
||||
}
|
||||
},
|
||||
"SidePanel": {
|
||||
"background": "#0E4155"
|
||||
},
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
},
|
||||
"ui": {
|
||||
"*": {
|
||||
"acceleratorForeground": "colorAcceleratorForeground",
|
||||
"acceleratorSelectionForeground": "colorAcceleratorSelectionForeground",
|
||||
"background": "colorBackground",
|
||||
"caretForeground": "colorForeground",
|
||||
"disabledForeground": "colorDisabledForeground",
|
||||
@@ -68,10 +70,7 @@
|
||||
"startBorderColor": "#B4BAB5"
|
||||
},
|
||||
"CheckBox": {},
|
||||
"CheckBoxMenuItem": {
|
||||
"acceleratorForeground": "colorAcceleratorForeground",
|
||||
"acceleratorSelectionForeground": "colorAcceleratorSelectionForeground"
|
||||
},
|
||||
"CheckBoxMenuItem": {},
|
||||
"ColorChooser": {
|
||||
"swatchesDefaultRecentColor": "#CFD0C3"
|
||||
},
|
||||
@@ -263,8 +262,6 @@
|
||||
"usedBackground": "#ADB5AF"
|
||||
},
|
||||
"Menu": {
|
||||
"acceleratorForeground": "colorAcceleratorForeground",
|
||||
"acceleratorSelectionForeground": "colorAcceleratorSelectionForeground",
|
||||
"borderColor": "#D3D2C6",
|
||||
"disabledBackground": "colorBackground",
|
||||
"separatorColor": "colorSeparator"
|
||||
@@ -378,10 +375,7 @@
|
||||
"trackColor": "#BAC0B8"
|
||||
},
|
||||
"RadioButton": {},
|
||||
"RadioButtonMenuItem": {
|
||||
"acceleratorForeground": "colorAcceleratorForeground",
|
||||
"acceleratorSelectionForeground": "colorAcceleratorSelectionForeground"
|
||||
},
|
||||
"RadioButtonMenuItem": {},
|
||||
"ScrollBar": {
|
||||
"background": "#F5F0E3",
|
||||
"hoverThumbBorderColor": "#4B5A5F47",
|
||||
@@ -445,6 +439,11 @@
|
||||
"Separator": {
|
||||
"separatorColor": "colorSeparator"
|
||||
},
|
||||
"Settings": {
|
||||
"Spotlight": {
|
||||
"borderColor": "#F6C00064"
|
||||
}
|
||||
},
|
||||
"SidePanel": {
|
||||
"background": "#E2E2D4"
|
||||
},
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.formdev.flatlaf.testing;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
@@ -91,6 +94,33 @@ public class FlatComponents2Test
|
||||
table1.setColumnSelectionAllowed( columnSelectionCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void showHorizontalLinesChanged() {
|
||||
table1.setShowHorizontalLines( showHorizontalLinesCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void showVerticalLinesChanged() {
|
||||
table1.setShowVerticalLines( showVerticalLinesCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void intercellSpacingChanged() {
|
||||
table1.setIntercellSpacing( intercellSpacingCheckBox.isSelected() ? new Dimension( 1, 1 ) : new Dimension() );
|
||||
}
|
||||
|
||||
private void redGridColorChanged() {
|
||||
table1.setGridColor( redGridColorCheckBox.isSelected() ? Color.red : UIManager.getColor( "Table.gridColor" ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
|
||||
EventQueue.invokeLater( () -> {
|
||||
showHorizontalLinesChanged();
|
||||
showVerticalLinesChanged();
|
||||
intercellSpacingChanged();
|
||||
} );
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" } )
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
@@ -114,6 +144,10 @@ public class FlatComponents2Test
|
||||
tableHeaderButtonCheckBox = new JCheckBox();
|
||||
rowSelectionCheckBox = new JCheckBox();
|
||||
columnSelectionCheckBox = new JCheckBox();
|
||||
showHorizontalLinesCheckBox = new JCheckBox();
|
||||
showVerticalLinesCheckBox = new JCheckBox();
|
||||
intercellSpacingCheckBox = new JCheckBox();
|
||||
redGridColorCheckBox = new JCheckBox();
|
||||
|
||||
//======== this ========
|
||||
setLayout(new MigLayout(
|
||||
@@ -127,6 +161,7 @@ public class FlatComponents2Test
|
||||
"[]" +
|
||||
"[::200]" +
|
||||
"[150,grow]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- textFieldLabel ----
|
||||
@@ -333,6 +368,26 @@ public class FlatComponents2Test
|
||||
columnSelectionCheckBox.setText("column selection");
|
||||
columnSelectionCheckBox.addActionListener(e -> columnSelectionChanged());
|
||||
add(columnSelectionCheckBox, "cell 0 4 3 1");
|
||||
|
||||
//---- showHorizontalLinesCheckBox ----
|
||||
showHorizontalLinesCheckBox.setText("show horizontal lines");
|
||||
showHorizontalLinesCheckBox.addActionListener(e -> showHorizontalLinesChanged());
|
||||
add(showHorizontalLinesCheckBox, "cell 0 5 3 1");
|
||||
|
||||
//---- showVerticalLinesCheckBox ----
|
||||
showVerticalLinesCheckBox.setText("show vertical lines");
|
||||
showVerticalLinesCheckBox.addActionListener(e -> showVerticalLinesChanged());
|
||||
add(showVerticalLinesCheckBox, "cell 0 5 3 1");
|
||||
|
||||
//---- intercellSpacingCheckBox ----
|
||||
intercellSpacingCheckBox.setText("intercell spacing");
|
||||
intercellSpacingCheckBox.addActionListener(e -> intercellSpacingChanged());
|
||||
add(intercellSpacingCheckBox, "cell 0 5 3 1");
|
||||
|
||||
//---- redGridColorCheckBox ----
|
||||
redGridColorCheckBox.setText("red grid color");
|
||||
redGridColorCheckBox.addActionListener(e -> redGridColorChanged());
|
||||
add(redGridColorCheckBox, "cell 0 5 3 1");
|
||||
// JFormDesigner - End of component initialization //GEN-END:initComponents
|
||||
|
||||
((JComboBox)((DefaultCellEditor)table1.getColumnModel().getColumn( 3 ).getCellEditor()).getComponent()).setEditable( true );
|
||||
@@ -349,6 +404,10 @@ public class FlatComponents2Test
|
||||
private JCheckBox tableHeaderButtonCheckBox;
|
||||
private JCheckBox rowSelectionCheckBox;
|
||||
private JCheckBox columnSelectionCheckBox;
|
||||
private JCheckBox showHorizontalLinesCheckBox;
|
||||
private JCheckBox showVerticalLinesCheckBox;
|
||||
private JCheckBox intercellSpacingCheckBox;
|
||||
private JCheckBox redGridColorCheckBox;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
|
||||
//---- class DummyTransferHandler -----------------------------------------
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
JFDML JFormDesigner: "7.0.1.0.272" Java: "13.0.2" encoding: "UTF-8"
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
@@ -9,7 +9,7 @@ new FormModel {
|
||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[][200][200]"
|
||||
"$rowConstraints": "[][][::200][150,grow][]"
|
||||
"$rowConstraints": "[][][::200][150,grow][][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
@@ -316,6 +316,46 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4 3 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "showHorizontalLinesCheckBox"
|
||||
"text": "show horizontal lines"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showHorizontalLinesChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5 3 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "showVerticalLinesCheckBox"
|
||||
"text": "show vertical lines"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showVerticalLinesChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5 3 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "intercellSpacingCheckBox"
|
||||
"text": "intercell spacing"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "intercellSpacingChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5 3 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "redGridColorCheckBox"
|
||||
"text": "red grid color"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "redGridColorChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5 3 1"
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 790, 715 )
|
||||
|
||||
@@ -134,6 +134,7 @@ public class FlatComponentsTest
|
||||
JLabel labelLabel = new JLabel();
|
||||
JLabel label1 = new JLabel();
|
||||
JLabel label2 = new JLabel();
|
||||
FlatComponentsTest.TestMultiLineLabel testMultiLineLabel1 = new FlatComponentsTest.TestMultiLineLabel();
|
||||
JLabel buttonLabel = new JLabel();
|
||||
JButton button1 = new JButton();
|
||||
JButton button17 = new JButton();
|
||||
@@ -367,6 +368,10 @@ public class FlatComponentsTest
|
||||
label2.setEnabled(false);
|
||||
add(label2, "cell 2 0");
|
||||
|
||||
//---- testMultiLineLabel1 ----
|
||||
testMultiLineLabel1.setText("Multi-line label based on JTextArea\n2nd line");
|
||||
add(testMultiLineLabel1, "cell 3 0 2 1");
|
||||
|
||||
//---- buttonLabel ----
|
||||
buttonLabel.setText("JButton:");
|
||||
add(buttonLabel, "cell 0 1");
|
||||
@@ -1402,4 +1407,24 @@ public class FlatComponentsTest
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//---- class TestMultiLineLabel -------------------------------------------
|
||||
|
||||
private static class TestMultiLineLabel
|
||||
extends JTextArea
|
||||
{
|
||||
public TestMultiLineLabel() {
|
||||
setEditable( false );
|
||||
setFocusable( false );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUI() {
|
||||
super.updateUI();
|
||||
setBackground( UIManager.getColor( "Label.background" ) );
|
||||
setForeground( UIManager.getColor( "Label.foreground" ) );
|
||||
setFont( UIManager.getFont( "Label.font" ) );
|
||||
setBorder( null );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,12 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 0"
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentsTest$TestMultiLineLabel" ) {
|
||||
name: "testMultiLineLabel1"
|
||||
"text": "Multi-line label based on JTextArea\n2nd line"
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 3 0 2 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "buttonLabel"
|
||||
"text": "JButton:"
|
||||
|
||||
@@ -62,6 +62,7 @@ public class FlatTestFrame
|
||||
private FlatInspector inspector;
|
||||
|
||||
public boolean useApplyComponentOrientation;
|
||||
public boolean applyComponentOrientationToFrame;
|
||||
|
||||
public static FlatTestFrame create( String[] args, String title ) {
|
||||
DemoPrefs.init( PREFS_ROOT_PATH );
|
||||
@@ -76,6 +77,9 @@ public class FlatTestFrame
|
||||
// disable animated Laf change
|
||||
System.setProperty( "flatlaf.animatedLafChange", "false" );
|
||||
|
||||
// test loading custom defaults from package
|
||||
FlatLaf.registerCustomDefaultsSource( "com.formdev.flatlaf.testing.customdefaults" );
|
||||
|
||||
// set look and feel
|
||||
DemoPrefs.initLaf( args );
|
||||
|
||||
@@ -439,7 +443,9 @@ public class FlatTestFrame
|
||||
? ComponentOrientation.RIGHT_TO_LEFT
|
||||
: ComponentOrientation.LEFT_TO_RIGHT;
|
||||
|
||||
if( useApplyComponentOrientation )
|
||||
if( applyComponentOrientationToFrame )
|
||||
applyComponentOrientation( orientation );
|
||||
else if( useApplyComponentOrientation )
|
||||
content.applyComponentOrientation( orientation );
|
||||
else {
|
||||
updateComponentsRecur( content, (c, type) -> {
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.awt.event.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import javax.swing.*;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import net.miginfocom.swing.*;
|
||||
@@ -39,6 +40,7 @@ public class FlatWindowDecorationsTest
|
||||
JDialog.setDefaultLookAndFeelDecorated( true );
|
||||
|
||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatWindowDecorationsTest" );
|
||||
frame.applyComponentOrientationToFrame = true;
|
||||
|
||||
// WARNING: Do not this in real-world programs.
|
||||
// frame.setUndecorated( true );
|
||||
@@ -117,6 +119,32 @@ public class FlatWindowDecorationsTest
|
||||
rootPane.putClientProperty( FlatClientProperties.MENU_BAR_EMBEDDED, menuBarEmbeddedCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void addMenu() {
|
||||
JMenu menu = new JMenu( "Hello" );
|
||||
menu.add( new JMenuItem( "world" ) );
|
||||
menuBar.add( menu );
|
||||
menuBar.revalidate();
|
||||
}
|
||||
|
||||
private void removeMenu() {
|
||||
int menuCount = menuBar.getMenuCount();
|
||||
if( menuCount <= 0 )
|
||||
return;
|
||||
|
||||
menuBar.remove( menuCount - 1 );
|
||||
menuBar.revalidate();
|
||||
}
|
||||
|
||||
private void changeMenu() {
|
||||
int menuCount = menuBar.getMenuCount();
|
||||
if( menuCount <= 0 )
|
||||
return;
|
||||
|
||||
int len = new Random().nextInt( 20 );
|
||||
String text = "1234567890abcdefghij".substring( 0, len + 1 );
|
||||
menuBar.getMenu( menuCount - 1 ).setText( text );
|
||||
}
|
||||
|
||||
private void resizableChanged() {
|
||||
Window window = SwingUtilities.windowForComponent( this );
|
||||
if( window instanceof Frame )
|
||||
@@ -218,6 +246,9 @@ public class FlatWindowDecorationsTest
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
menuBarCheckBox = new JCheckBox();
|
||||
JButton addMenuButton = new JButton();
|
||||
JButton removeMenuButton = new JButton();
|
||||
JButton changeMenuButton = new JButton();
|
||||
menuBarEmbeddedCheckBox = new JCheckBox();
|
||||
resizableCheckBox = new JCheckBox();
|
||||
maximizedBoundsCheckBox = new JCheckBox();
|
||||
@@ -271,7 +302,7 @@ public class FlatWindowDecorationsTest
|
||||
"ltr,insets dialog,hidemode 3",
|
||||
// columns
|
||||
"[left]para" +
|
||||
"[fill]",
|
||||
"[left]",
|
||||
// rows
|
||||
"para[]0" +
|
||||
"[]0" +
|
||||
@@ -287,6 +318,21 @@ public class FlatWindowDecorationsTest
|
||||
menuBarCheckBox.addActionListener(e -> menuBarChanged());
|
||||
add(menuBarCheckBox, "cell 0 0");
|
||||
|
||||
//---- addMenuButton ----
|
||||
addMenuButton.setText("Add menu");
|
||||
addMenuButton.addActionListener(e -> addMenu());
|
||||
add(addMenuButton, "cell 1 0 1 2,align left top,grow 0 0");
|
||||
|
||||
//---- removeMenuButton ----
|
||||
removeMenuButton.setText("Remove menu");
|
||||
removeMenuButton.addActionListener(e -> removeMenu());
|
||||
add(removeMenuButton, "cell 1 0 1 2,align left top,grow 0 0");
|
||||
|
||||
//---- changeMenuButton ----
|
||||
changeMenuButton.setText("Change menu");
|
||||
changeMenuButton.addActionListener(e -> changeMenu());
|
||||
add(changeMenuButton, "cell 1 0 1 2,align left top,grow 0 0");
|
||||
|
||||
//---- menuBarEmbeddedCheckBox ----
|
||||
menuBarEmbeddedCheckBox.setText("embedded menu bar");
|
||||
menuBarEmbeddedCheckBox.setSelected(true);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "13.0.2" encoding: "UTF-8"
|
||||
JFDML JFormDesigner: "7.0.2.0.298" Java: "14" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
@@ -8,7 +8,7 @@ new FormModel {
|
||||
}
|
||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[left]para[fill]"
|
||||
"$columnConstraints": "[left]para[left]"
|
||||
"$rowConstraints": "para[]0[]0[]0[][][top][]"
|
||||
} ) {
|
||||
name: "this"
|
||||
@@ -23,6 +23,27 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "addMenuButton"
|
||||
"text": "Add menu"
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "addMenu", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0 1 2,align left top,grow 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "removeMenuButton"
|
||||
"text": "Remove menu"
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "removeMenu", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0 1 2,align left top,grow 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JButton" ) {
|
||||
name: "changeMenuButton"
|
||||
"text": "Change menu"
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "changeMenu", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0 1 2,align left top,grow 0 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "menuBarEmbeddedCheckBox"
|
||||
"text": "embedded menu bar"
|
||||
@@ -238,7 +259,7 @@ new FormModel {
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 450, 380 )
|
||||
"size": new java.awt.Dimension( 550, 380 )
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JMenuBar", new FormLayoutManager( class javax.swing.JMenuBar ) ) {
|
||||
name: "menuBar"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
# @background=#000
|
||||
@@ -0,0 +1,2 @@
|
||||
# Component.arc=9999
|
||||
# TextComponent.arc=9999
|
||||
@@ -0,0 +1 @@
|
||||
# @background=#fff
|
||||
@@ -80,6 +80,7 @@ Button.default.pressedBackground #3f6796 com.formdev.flatlaf.util.DerivedColo
|
||||
Button.defaultButtonFollowsFocus true
|
||||
Button.disabledBackground #3c3f41 javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.disabledBorderColor #5e6060 javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.disabledSelectedBackground #53585a com.formdev.flatlaf.util.DerivedColor [UI] lighten(3% autoInverse)
|
||||
Button.disabledText #777777 javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.focusedBorderColor #466d94 javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.font [active] $defaultFont [UI]
|
||||
@@ -93,12 +94,15 @@ Button.margin 2,14,2,14 javax.swing.plaf.InsetsUIResource [U
|
||||
Button.minimumWidth 72
|
||||
Button.pressedBackground #5b5f62 com.formdev.flatlaf.util.DerivedColor [UI] lighten(6% autoInverse)
|
||||
Button.rollover true
|
||||
Button.selectedBackground #656a6c com.formdev.flatlaf.util.DerivedColor [UI] lighten(10% autoInverse)
|
||||
Button.selectedForeground #bbbbbb javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.shadow #646464 javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.textIconGap 4
|
||||
Button.textShiftOffset 0
|
||||
Button.toolbar.hoverBackground #4e5355 com.formdev.flatlaf.util.DerivedColor [UI] lighten(1% autoInverse)
|
||||
Button.toolbar.margin 3,3,3,3 javax.swing.plaf.InsetsUIResource [UI]
|
||||
Button.toolbar.pressedBackground #565a5d com.formdev.flatlaf.util.DerivedColor [UI] lighten(4% autoInverse)
|
||||
Button.toolbar.selectedBackground #5d6265 com.formdev.flatlaf.util.DerivedColor [UI] lighten(7% autoInverse)
|
||||
Button.toolbar.spacingInsets 1,2,1,2 javax.swing.plaf.InsetsUIResource [UI]
|
||||
ButtonUI com.formdev.flatlaf.ui.FlatButtonUI
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ Button.default.pressedBackground #e6e6e6 com.formdev.flatlaf.util.DerivedColo
|
||||
Button.defaultButtonFollowsFocus true
|
||||
Button.disabledBackground #f2f2f2 javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.disabledBorderColor #cfcfcf javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.disabledSelectedBackground #dedede com.formdev.flatlaf.util.DerivedColor [UI] darken(13% autoInverse)
|
||||
Button.disabledText #8c8c8c javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.focusedBackground #e3f1fa javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.focusedBorderColor #87afda javax.swing.plaf.ColorUIResource [UI]
|
||||
@@ -94,12 +95,15 @@ Button.margin 2,14,2,14 javax.swing.plaf.InsetsUIResource [U
|
||||
Button.minimumWidth 72
|
||||
Button.pressedBackground #e6e6e6 com.formdev.flatlaf.util.DerivedColor [UI] darken(10% autoInverse)
|
||||
Button.rollover true
|
||||
Button.selectedBackground #cccccc com.formdev.flatlaf.util.DerivedColor [UI] darken(20% autoInverse)
|
||||
Button.selectedForeground #000000 javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.shadow #c4c4c4 javax.swing.plaf.ColorUIResource [UI]
|
||||
Button.textIconGap 4
|
||||
Button.textShiftOffset 0
|
||||
Button.toolbar.hoverBackground #e0e0e0 com.formdev.flatlaf.util.DerivedColor [UI] darken(12% autoInverse)
|
||||
Button.toolbar.margin 3,3,3,3 javax.swing.plaf.InsetsUIResource [UI]
|
||||
Button.toolbar.pressedBackground #d9d9d9 com.formdev.flatlaf.util.DerivedColor [UI] darken(15% autoInverse)
|
||||
Button.toolbar.selectedBackground #cccccc com.formdev.flatlaf.util.DerivedColor [UI] darken(20% autoInverse)
|
||||
Button.toolbar.spacingInsets 1,2,1,2 javax.swing.plaf.InsetsUIResource [UI]
|
||||
ButtonUI com.formdev.flatlaf.ui.FlatButtonUI
|
||||
|
||||
|
||||
@@ -25,3 +25,29 @@ dependencies {
|
||||
implementation( "com.fifesoft:rsyntaxtextarea:3.1.1" )
|
||||
implementation( "com.fifesoft:autocomplete:3.1.0" )
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
dependsOn( ":flatlaf-core:jar" )
|
||||
dependsOn( ":flatlaf-extras:jar" )
|
||||
|
||||
manifest {
|
||||
attributes( "Main-Class" to "com.formdev.flatlaf.themeeditor.FlatThemeFileEditor" )
|
||||
|
||||
if( JavaVersion.current() >= JavaVersion.VERSION_1_9 )
|
||||
attributes( "Multi-Release" to "true" )
|
||||
}
|
||||
|
||||
exclude( "module-info.class" )
|
||||
exclude( "META-INF/versions/*/module-info.class" )
|
||||
|
||||
// include all dependencies in jar
|
||||
from( {
|
||||
configurations.runtimeClasspath.get()
|
||||
.filter { it.name.endsWith( "jar" ) }
|
||||
.map { zipTree( it ).matching {
|
||||
exclude( "META-INF/LICENSE" )
|
||||
} }
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ Button.default.pressedBackground
|
||||
Button.defaultButtonFollowsFocus
|
||||
Button.disabledBackground
|
||||
Button.disabledBorderColor
|
||||
Button.disabledSelectedBackground
|
||||
Button.disabledText
|
||||
Button.focusInputMap
|
||||
Button.focusedBackground
|
||||
@@ -43,12 +44,15 @@ Button.margin
|
||||
Button.minimumWidth
|
||||
Button.pressedBackground
|
||||
Button.rollover
|
||||
Button.selectedBackground
|
||||
Button.selectedForeground
|
||||
Button.shadow
|
||||
Button.textIconGap
|
||||
Button.textShiftOffset
|
||||
Button.toolbar.hoverBackground
|
||||
Button.toolbar.margin
|
||||
Button.toolbar.pressedBackground
|
||||
Button.toolbar.selectedBackground
|
||||
Button.toolbar.spacingInsets
|
||||
ButtonUI
|
||||
Caret.width
|
||||
|
||||
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 27 KiB |
BIN
images/arc_orange.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
images/carbon.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
images/cyan_light.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
images/dark_purple.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
images/flat_dark.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
images/flat_light.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
images/intellij_platform_themes.png
Normal file
|
After Width: | Height: | Size: 145 KiB |
BIN
images/one_dark.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
BIN
images/solarized_light.png
Normal file
|
After Width: | Height: | Size: 27 KiB |