mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 15:07:11 -06:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
069a7c809c | ||
|
|
883b4d735a | ||
|
|
9f39b269bb | ||
|
|
36c405c708 | ||
|
|
bc7c68ebe4 | ||
|
|
6c502ad4c5 | ||
|
|
100aa0b621 | ||
|
|
8e42b19934 | ||
|
|
1a456d5d68 | ||
|
|
e83c26a76a | ||
|
|
6e7c2a616b | ||
|
|
0699454df8 | ||
|
|
92c110548a | ||
|
|
ca88023560 | ||
|
|
12fc2299ec | ||
|
|
2089c77b84 | ||
|
|
95522846ac |
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -26,6 +26,10 @@ jobs:
|
||||
- 8
|
||||
- 11 # LTS
|
||||
- 17 # LTS
|
||||
toolchain: [""]
|
||||
include:
|
||||
- java: 17
|
||||
toolchain: 19 # latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
@@ -41,7 +45,7 @@ jobs:
|
||||
cache: gradle
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
run: ./gradlew build -Dtoolchain=${{ matrix.toolchain }}
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
25
CHANGELOG.md
25
CHANGELOG.md
@@ -1,6 +1,31 @@
|
||||
FlatLaf Change Log
|
||||
==================
|
||||
|
||||
## 2.6
|
||||
|
||||
#### New features and improvements
|
||||
|
||||
- If value of system property `flatlaf.nativeLibraryPath` is `system`, then
|
||||
`System.loadLibrary(String)` is used to load the native library.
|
||||
- TabbedPane: Switch and close tabs on left mouse click only. (PR #595)
|
||||
|
||||
#### Fixed bugs
|
||||
|
||||
- ComboBox and Spinner: Fixed missing arrow buttons if preferred height is zero.
|
||||
Minimum width of arrow buttons is 3/4 of default width.
|
||||
- MenuBar: Fixed NPE in `FlatMenuItemRenderer.getTopLevelFont()` if menu item
|
||||
does not have a parent. (issue #600; regression since implementing #589 in
|
||||
FlatLaf 2.5)
|
||||
- ScrollBar: Show "pressed" feedback on track/thumb only for left mouse button.
|
||||
If absolute positioning is enabled (the default), then also for middle mouse
|
||||
button.
|
||||
- Arrow buttons in ComboBox, Spinner, ScrollBar and TabbedPane: Show "pressed"
|
||||
feedback only for left mouse button.
|
||||
- ScaledImageIcon: Do not throw exceptions if image was has invalid size (e.g.
|
||||
not found). Instead, paint a red rectangle (similar to `FlatSVGIcon`).
|
||||
- Fixed NPE in `FlatUIUtils.isCellEditor()`. (issue #601)
|
||||
|
||||
|
||||
## 2.5
|
||||
|
||||
#### New features and improvements
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
val releaseVersion = "2.5"
|
||||
val releaseVersion = "2.6"
|
||||
val developmentVersion = "3.0-SNAPSHOT"
|
||||
|
||||
version = if( java.lang.Boolean.getBoolean( "release" ) ) releaseVersion else developmentVersion
|
||||
@@ -37,6 +37,9 @@ println( "----------------------------------------------------------------------
|
||||
println( "FlatLaf Version: ${version}" )
|
||||
println( "Gradle ${gradle.gradleVersion} at ${gradle.gradleHomeDir}" )
|
||||
println( "Java ${System.getProperty( "java.version" )}" )
|
||||
val toolchainJavaVersion = System.getProperty( "toolchain" )
|
||||
if( !toolchainJavaVersion.isNullOrEmpty() )
|
||||
println( "Java toolchain ${toolchainJavaVersion}" )
|
||||
println()
|
||||
|
||||
|
||||
|
||||
26
buildSrc/src/main/kotlin/flatlaf-toolchain.gradle.kts
Normal file
26
buildSrc/src/main/kotlin/flatlaf-toolchain.gradle.kts
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2022 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.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
java
|
||||
}
|
||||
|
||||
val toolchainJavaVersion = System.getProperty( "toolchain" )
|
||||
if( !toolchainJavaVersion.isNullOrEmpty() ) {
|
||||
java.toolchain {
|
||||
languageVersion.set( JavaLanguageVersion.of( toolchainJavaVersion ) )
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`flatlaf-toolchain`
|
||||
`flatlaf-module-info`
|
||||
`flatlaf-java9`
|
||||
`flatlaf-publish`
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Signature file v4.1
|
||||
#Version 2.4
|
||||
#Version 2.5
|
||||
|
||||
CLSS public abstract interface com.formdev.flatlaf.FlatClientProperties
|
||||
fld public final static java.lang.String BUTTON_TYPE = "JButton.buttonType"
|
||||
@@ -11,6 +11,7 @@ fld public final static java.lang.String BUTTON_TYPE_TAB = "tab"
|
||||
fld public final static java.lang.String BUTTON_TYPE_TOOLBAR_BUTTON = "toolBarButton"
|
||||
fld public final static java.lang.String COMPONENT_FOCUS_OWNER = "JComponent.focusOwner"
|
||||
fld public final static java.lang.String COMPONENT_ROUND_RECT = "JComponent.roundRect"
|
||||
fld public final static java.lang.String COMPONENT_TITLE_BAR_CAPTION = "JComponent.titleBarCaption"
|
||||
fld public final static java.lang.String MENU_BAR_EMBEDDED = "JRootPane.menuBarEmbedded"
|
||||
fld public final static java.lang.String MINIMUM_HEIGHT = "JComponent.minimumHeight"
|
||||
fld public final static java.lang.String MINIMUM_WIDTH = "JComponent.minimumWidth"
|
||||
@@ -185,6 +186,7 @@ meth public java.lang.String getID()
|
||||
meth public java.util.Map<java.lang.String,java.lang.String> getExtraDefaults()
|
||||
meth public javax.swing.Icon getDisabledIcon(javax.swing.JComponent,javax.swing.Icon)
|
||||
meth public javax.swing.UIDefaults getDefaults()
|
||||
meth public static <%0 extends java.lang.Object> {%%0} getStyleableValue(javax.swing.JComponent,java.lang.String)
|
||||
meth public static boolean install(javax.swing.LookAndFeel)
|
||||
anno 0 java.lang.Deprecated()
|
||||
meth public static boolean isLafDark()
|
||||
@@ -193,6 +195,7 @@ meth public static boolean isUseNativeWindowDecorations()
|
||||
meth public static boolean setup(javax.swing.LookAndFeel)
|
||||
meth public static boolean supportsNativeWindowDecorations()
|
||||
meth public static java.lang.Object parseDefaultsValue(java.lang.String,java.lang.String,java.lang.Class<?>)
|
||||
meth public static java.util.Map<java.lang.String,java.lang.Class<?>> getStyleableInfos(javax.swing.JComponent)
|
||||
meth public static java.util.Map<java.lang.String,java.lang.String> getGlobalExtraDefaults()
|
||||
meth public static javax.swing.UIDefaults$ActiveValue createActiveFontValue(float)
|
||||
meth public static void hideMnemonics()
|
||||
@@ -220,7 +223,7 @@ meth public void setExtraDefaults(java.util.Map<java.lang.String,java.lang.Strin
|
||||
meth public void uninitialize()
|
||||
meth public void unregisterUIDefaultsGetter(java.util.function.Function<java.lang.Object,java.lang.Object>)
|
||||
supr javax.swing.plaf.basic.BasicLookAndFeel
|
||||
hfds DESKTOPFONTHINTS,aquaLoaded,customDefaultsSources,desktopPropertyListener,desktopPropertyName,desktopPropertyName2,extraDefaults,globalExtraDefaults,mnemonicHandler,oldPopupFactory,postInitialization,subMenuUsabilityHelperInstalled,uiDefaultsGetters,updateUIPending
|
||||
hfds DESKTOPFONTHINTS,aquaLoaded,customDefaultsSources,desktopPropertyListener,desktopPropertyName,desktopPropertyName2,extraDefaults,getUIMethod,getUIMethodInitialized,globalExtraDefaults,mnemonicHandler,oldPopupFactory,postInitialization,subMenuUsabilityHelperInstalled,uiDefaultsGetters,updateUIPending
|
||||
hcls ActiveFont,FlatUIDefaults,ImageIconUIResource
|
||||
|
||||
CLSS public abstract interface static com.formdev.flatlaf.FlatLaf$DisabledIconProvider
|
||||
@@ -259,6 +262,7 @@ fld public final static java.lang.String NATIVE_LIBRARY_PATH = "flatlaf.nativeLi
|
||||
fld public final static java.lang.String UI_SCALE = "flatlaf.uiScale"
|
||||
fld public final static java.lang.String UI_SCALE_ALLOW_SCALE_DOWN = "flatlaf.uiScale.allowScaleDown"
|
||||
fld public final static java.lang.String UI_SCALE_ENABLED = "flatlaf.uiScale.enabled"
|
||||
fld public final static java.lang.String UPDATE_UI_ON_SYSTEM_FONT_CHANGE = "flatlaf.updateUIOnSystemFontChange"
|
||||
fld public final static java.lang.String USE_JETBRAINS_CUSTOM_DECORATIONS = "flatlaf.useJetBrainsCustomDecorations"
|
||||
fld public final static java.lang.String USE_TEXT_Y_CORRECTION = "flatlaf.useTextYCorrection"
|
||||
fld public final static java.lang.String USE_UBUNTU_FONT = "flatlaf.useUbuntuFont"
|
||||
|
||||
@@ -155,9 +155,19 @@ public interface FlatSystemProperties
|
||||
String UPDATE_UI_ON_SYSTEM_FONT_CHANGE = "flatlaf.updateUIOnSystemFontChange";
|
||||
|
||||
/**
|
||||
* Specifies a directory in which the native FlatLaf library have been extracted.
|
||||
* Specifies a directory in which the native FlatLaf libraries have been extracted.
|
||||
* The path can be absolute or relative to current application working directory.
|
||||
* This can be used to avoid extraction of the native libraries to the temporary directory at runtime.
|
||||
* <p>
|
||||
* If the value is {@code "system"}, then {@link System#loadLibrary(String)} is
|
||||
* used to load the native library.
|
||||
* Searches for the native library in classloader of caller
|
||||
* (using {@link ClassLoader#findLibrary(String)}) and in paths specified
|
||||
* in system properties {@code sun.boot.library.path} and {@code java.library.path}.
|
||||
* (supported since FlatLaf 2.6)
|
||||
* <p>
|
||||
* If the native library can not loaded from the given path (or via {@link System#loadLibrary(String)}),
|
||||
* then the embedded native library is extracted to the temporary directory and loaded from there.
|
||||
*
|
||||
* @since 2
|
||||
*/
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import javax.swing.plaf.basic.BasicArrowButton;
|
||||
|
||||
@@ -82,14 +83,18 @@ public class FlatArrowButton
|
||||
|
||||
@Override
|
||||
public void mousePressed( MouseEvent e ) {
|
||||
pressed = true;
|
||||
repaint();
|
||||
if( SwingUtilities.isLeftMouseButton( e ) ) {
|
||||
pressed = true;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased( MouseEvent e ) {
|
||||
pressed = false;
|
||||
repaint();
|
||||
if( SwingUtilities.isLeftMouseButton( e ) ) {
|
||||
pressed = false;
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -308,11 +308,14 @@ public class FlatComboBoxUI
|
||||
// limit button width to height of a raw combobox (without insets)
|
||||
FontMetrics fm = comboBox.getFontMetrics( comboBox.getFont() );
|
||||
int maxButtonWidth = fm.getHeight() + scale( padding.top ) + scale( padding.bottom );
|
||||
int minButtonWidth = (maxButtonWidth * 3) / 4;
|
||||
|
||||
// make button square (except if width is limited)
|
||||
Insets insets = getInsets();
|
||||
int buttonWidth = Math.min( parent.getPreferredSize().height - insets.top - insets.bottom, maxButtonWidth );
|
||||
int buttonWidth = Math.min( Math.max( parent.getHeight() - insets.top - insets.bottom, minButtonWidth ), maxButtonWidth );
|
||||
|
||||
if( buttonWidth != arrowButton.getWidth() ) {
|
||||
// set width of arrow button to preferred height of combobox
|
||||
// set width of arrow button
|
||||
int xOffset = comboBox.getComponentOrientation().isLeftToRight()
|
||||
? arrowButton.getWidth() - buttonWidth
|
||||
: 0;
|
||||
|
||||
@@ -500,7 +500,11 @@ debug*/
|
||||
|
||||
private Font getTopLevelFont() {
|
||||
Font font = menuItem.getFont();
|
||||
return (font != menuFont) ? font : menuItem.getParent().getFont();
|
||||
// menu item parent may be null if JMenu.isTopLevelMenu() is overridden
|
||||
// and does not check parent (e.g. com.jidesoft.swing.JideMenu.isTopLevelMenu())
|
||||
return (font != menuFont || menuItem.getParent() == null)
|
||||
? font
|
||||
: menuItem.getParent().getFont();
|
||||
}
|
||||
|
||||
private Icon getIconForPainting() {
|
||||
|
||||
@@ -48,27 +48,25 @@ class FlatNativeLibrary
|
||||
|
||||
String libraryName;
|
||||
if( SystemInfo.isWindows_10_orLater && (SystemInfo.isX86 || SystemInfo.isX86_64) ) {
|
||||
// Windows: requires Windows 10 (x86 or x86_64)
|
||||
// Windows: requires Windows 10/11 (x86 or x86_64)
|
||||
|
||||
libraryName = "flatlaf-windows-x86";
|
||||
if( SystemInfo.isX86_64 )
|
||||
libraryName += "_64";
|
||||
|
||||
// load jawt native library
|
||||
if( !SystemInfo.isJava_9_orLater ) {
|
||||
// In Java 8, load jawt.dll (part of JRE) explicitly because it
|
||||
// is not found when running application with <jdk>/bin/java.exe.
|
||||
// When using <jdk>/jre/bin/java.exe, it is found.
|
||||
// jawt.dll is located in <jdk>/jre/bin/.
|
||||
// Java 9 and later do not have this problem.
|
||||
loadJAWT();
|
||||
}
|
||||
// In Java 8, load jawt.dll (part of JRE) explicitly because it
|
||||
// is not found when running application with <jdk>/bin/java.exe.
|
||||
// When using <jdk>/jre/bin/java.exe, it is found.
|
||||
// jawt.dll is located in <jdk>/jre/bin/.
|
||||
// Java 9 and later do not have this problem,
|
||||
// but load jawt.dll anyway to be on the safe side.
|
||||
loadJAWT();
|
||||
} else if( SystemInfo.isLinux && SystemInfo.isX86_64 ) {
|
||||
// Linux: requires x86_64
|
||||
|
||||
libraryName = "flatlaf-linux-x86_64";
|
||||
|
||||
// Load jawt.so (part of JRE) explicitly because it is not found
|
||||
// Load libjawt.so (part of JRE) explicitly because it is not found
|
||||
// in all Java versions/distributions.
|
||||
// E.g. not found in Java 13 and later from openjdk.java.net.
|
||||
// There seems to be also differences between distributions.
|
||||
@@ -84,11 +82,19 @@ class FlatNativeLibrary
|
||||
private static NativeLibrary createNativeLibrary( String libraryName ) {
|
||||
String libraryPath = System.getProperty( FlatSystemProperties.NATIVE_LIBRARY_PATH );
|
||||
if( libraryPath != null ) {
|
||||
File libraryFile = new File( libraryPath, System.mapLibraryName( libraryName ) );
|
||||
if( libraryFile.exists() )
|
||||
return new NativeLibrary( libraryFile, true );
|
||||
else
|
||||
if( "system".equals( libraryPath ) ) {
|
||||
NativeLibrary library = new NativeLibrary( libraryName, true );
|
||||
if( library.isLoaded() )
|
||||
return library;
|
||||
|
||||
LoggingFacade.INSTANCE.logSevere( "Did not find library " + libraryName + " in java.library.path, using extracted library instead", null );
|
||||
} else {
|
||||
File libraryFile = new File( libraryPath, System.mapLibraryName( libraryName ) );
|
||||
if( libraryFile.exists() )
|
||||
return new NativeLibrary( libraryFile, true );
|
||||
|
||||
LoggingFacade.INSTANCE.logSevere( "Did not find external library " + libraryFile + ", using extracted library instead", null );
|
||||
}
|
||||
}
|
||||
|
||||
return new NativeLibrary( "com/formdev/flatlaf/natives/" + libraryName, null, true );
|
||||
@@ -101,9 +107,9 @@ class FlatNativeLibrary
|
||||
// log error only if native library jawt.dll not already loaded
|
||||
String message = ex.getMessage();
|
||||
if( message == null || !message.contains( "already loaded in another classloader" ) )
|
||||
LoggingFacade.INSTANCE.logSevere( null, ex );
|
||||
LoggingFacade.INSTANCE.logSevere( message, ex );
|
||||
} catch( Exception ex ) {
|
||||
LoggingFacade.INSTANCE.logSevere( null, ex );
|
||||
LoggingFacade.INSTANCE.logSevere( ex.getMessage(), ex );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,6 +352,9 @@ public class FlatScrollBarUI
|
||||
|
||||
@Override
|
||||
protected void paintTrack( Graphics g, JComponent c, Rectangle trackBounds ) {
|
||||
if( trackBounds.isEmpty() || !scrollbar.isEnabled() )
|
||||
return;
|
||||
|
||||
g.setColor( getTrackColor( c, hoverTrack, isPressed && hoverTrack && !hoverThumb ) );
|
||||
paintTrackOrThumb( g, c, trackBounds, trackInsets, trackArc );
|
||||
}
|
||||
@@ -452,18 +455,31 @@ public class FlatScrollBarUI
|
||||
|
||||
@Override
|
||||
public void mousePressed( MouseEvent e ) {
|
||||
isPressed = true;
|
||||
repaint();
|
||||
if( SwingUtilities.isLeftMouseButton( e ) || isAbsolutePositioning( e ) ) {
|
||||
isPressed = true;
|
||||
repaint();
|
||||
|
||||
// update hover because BasicScrollBarUI.TrackListener.mousePressed()
|
||||
// moves the track on middle-click (if absolute positioning is enabled)
|
||||
if( isAbsolutePositioning( e ) )
|
||||
update( e.getX(), e.getY() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased( MouseEvent e ) {
|
||||
isPressed = false;
|
||||
repaint();
|
||||
if( SwingUtilities.isLeftMouseButton( e ) || isAbsolutePositioning( e ) ) {
|
||||
isPressed = false;
|
||||
repaint();
|
||||
}
|
||||
|
||||
update( e.getX(), e.getY() );
|
||||
}
|
||||
|
||||
private boolean isAbsolutePositioning( MouseEvent e ) {
|
||||
return getSupportsAbsolutePositioning() && SwingUtilities.isMiddleMouseButton( e );
|
||||
}
|
||||
|
||||
private void update( int x, int y ) {
|
||||
boolean inTrack = getTrackBounds().contains( x, y );
|
||||
boolean inThumb = getThumbBounds().contains( x, y );
|
||||
|
||||
@@ -483,9 +483,10 @@ public class FlatSpinnerUI
|
||||
// limit buttons width to height of a raw spinner (without insets)
|
||||
FontMetrics fm = spinner.getFontMetrics( spinner.getFont() );
|
||||
int maxButtonWidth = fm.getHeight() + scale( padding.top ) + scale( padding.bottom );
|
||||
int minButtonWidth = (maxButtonWidth * 3) / 4;
|
||||
|
||||
// make button area square (if spinner has preferred height)
|
||||
int buttonsWidth = Math.min( parent.getPreferredSize().height - insets.top - insets.bottom, maxButtonWidth );
|
||||
// make button area square (except if width is limited)
|
||||
int buttonsWidth = Math.min( Math.max( buttonsRect.height, minButtonWidth ), maxButtonWidth );
|
||||
buttonsRect.width = buttonsWidth;
|
||||
|
||||
if( parent.getComponentOrientation().isLeftToRight() ) {
|
||||
|
||||
@@ -2589,7 +2589,7 @@ public class FlatTabbedPaneUI
|
||||
public void mousePressed( MouseEvent e ) {
|
||||
updateRollover( e );
|
||||
|
||||
if( !isPressedTabClose() )
|
||||
if( !isPressedTabClose() && SwingUtilities.isLeftMouseButton( e ) )
|
||||
mouseDelegate.mousePressed( e );
|
||||
}
|
||||
|
||||
@@ -2644,7 +2644,7 @@ public class FlatTabbedPaneUI
|
||||
|
||||
// check whether mouse hit tab close area
|
||||
boolean hitClose = isTabClosable( tabIndex ) && getTabCloseHitArea( tabIndex ).contains( x, y );
|
||||
if( e.getID() == MouseEvent.MOUSE_PRESSED )
|
||||
if( e.getID() == MouseEvent.MOUSE_PRESSED && SwingUtilities.isLeftMouseButton( e ) )
|
||||
pressedTabIndex = hitClose ? tabIndex : -1;
|
||||
setRolloverTabClose( hitClose );
|
||||
setPressedTabClose( hitClose && tabIndex == pressedTabIndex );
|
||||
|
||||
@@ -210,6 +210,9 @@ public class FlatUIUtils
|
||||
}
|
||||
|
||||
public static boolean isCellEditor( Component c ) {
|
||||
if( c == null )
|
||||
return false;
|
||||
|
||||
// check whether used in cell editor (check 3 levels up)
|
||||
Component c2 = c;
|
||||
for( int i = 0; i <= 2 && c2 != null; i++ ) {
|
||||
|
||||
@@ -73,6 +73,22 @@ public class NativeLibrary
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load native library using {@link System#loadLibrary(String)}.
|
||||
* Searches for the library in classloader of caller
|
||||
* (using {@link ClassLoader#findLibrary(String)}) and in paths specified
|
||||
* in system properties {@code sun.boot.library.path} and {@code java.library.path}.
|
||||
*
|
||||
* @param libraryName name of the native library (without "lib" prefix and without extension)
|
||||
* @param supported whether the native library is supported on the current platform
|
||||
* @since 2.6
|
||||
*/
|
||||
public NativeLibrary( String libraryName, boolean supported ) {
|
||||
this.loaded = supported
|
||||
? loadLibraryFromSystem( libraryName )
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the native library is loaded.
|
||||
* <p>
|
||||
@@ -92,7 +108,7 @@ public class NativeLibrary
|
||||
? classLoader.getResource( libraryName )
|
||||
: NativeLibrary.class.getResource( "/" + libraryName );
|
||||
if( libraryUrl == null ) {
|
||||
log( "Library '" + libraryName + "' not found", null );
|
||||
LoggingFacade.INSTANCE.logSevere( "Library '" + libraryName + "' not found", null );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -125,7 +141,7 @@ public class NativeLibrary
|
||||
|
||||
return true;
|
||||
} catch( Throwable ex ) {
|
||||
log( null, ex );
|
||||
LoggingFacade.INSTANCE.logSevere( ex.getMessage(), ex );
|
||||
|
||||
if( tempFile != null )
|
||||
deleteOrMarkForDeletion( tempFile );
|
||||
@@ -138,7 +154,24 @@ public class NativeLibrary
|
||||
System.load( libraryFile.getAbsolutePath() );
|
||||
return true;
|
||||
} catch( Throwable ex ) {
|
||||
log( ex.getMessage(), ex );
|
||||
LoggingFacade.INSTANCE.logSevere( ex.getMessage(), ex );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean loadLibraryFromSystem( String libraryName ) {
|
||||
try {
|
||||
System.loadLibrary( libraryName );
|
||||
return true;
|
||||
} catch( Throwable ex ) {
|
||||
String message = ex.getMessage();
|
||||
|
||||
// do not log error if library was not found
|
||||
// thrown in ClassLoader.loadLibrary(Class<?> fromClass, String name, boolean isAbsolute)
|
||||
if( ex instanceof UnsatisfiedLinkError && message != null && message.contains( "java.library.path" ) )
|
||||
return false;
|
||||
|
||||
LoggingFacade.INSTANCE.logSevere( message, ex );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -158,10 +191,6 @@ public class NativeLibrary
|
||||
: System.mapLibraryName( libraryName );
|
||||
}
|
||||
|
||||
private static void log( String msg, Throwable thrown ) {
|
||||
LoggingFacade.INSTANCE.logSevere( msg, thrown );
|
||||
}
|
||||
|
||||
private static Path createTempFile( String libraryName ) throws IOException {
|
||||
int sep = libraryName.lastIndexOf( '/' );
|
||||
String name = (sep >= 0) ? libraryName.substring( sep + 1 ) : libraryName;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.formdev.flatlaf.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
@@ -102,6 +103,13 @@ debug*/
|
||||
int imageWidth = image.getWidth( null );
|
||||
int imageHeight = image.getHeight( null );
|
||||
|
||||
// paint red rectangle if image has invalid size (e.g. not found)
|
||||
if( imageWidth < 0 || imageHeight < 0 ) {
|
||||
g.setColor( Color.red );
|
||||
g.fillRect( x, y, getIconWidth(), getIconHeight() );
|
||||
return;
|
||||
}
|
||||
|
||||
// scale image if necessary to destination size
|
||||
if( imageWidth != destImageWidth || imageHeight != destImageHeight ) {
|
||||
// determine scaling method; default is "quality"
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`flatlaf-toolchain`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`flatlaf-toolchain`
|
||||
`flatlaf-module-info`
|
||||
`flatlaf-publish`
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`flatlaf-toolchain`
|
||||
`flatlaf-module-info`
|
||||
`flatlaf-publish`
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`flatlaf-toolchain`
|
||||
`flatlaf-publish`
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`flatlaf-toolchain`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`flatlaf-toolchain`
|
||||
`flatlaf-module-info`
|
||||
`flatlaf-publish`
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Properties
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`flatlaf-toolchain`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -19,7 +19,9 @@ package com.formdev.flatlaf.testing;
|
||||
import static com.formdev.flatlaf.FlatClientProperties.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import javax.swing.*;
|
||||
@@ -430,14 +432,14 @@ public class FlatContainerTest
|
||||
}
|
||||
|
||||
private void customWheelScrollingChanged() {
|
||||
if( custoMouseWheelScroller != null ) {
|
||||
if( customMouseWheelScroller != null ) {
|
||||
for( FlatTabbedPane tabbedPane : allTabbedPanes )
|
||||
tabbedPane.removeMouseWheelListener( custoMouseWheelScroller );
|
||||
custoMouseWheelScroller = null;
|
||||
tabbedPane.removeMouseWheelListener( customMouseWheelScroller );
|
||||
customMouseWheelScroller = null;
|
||||
}
|
||||
|
||||
if( customWheelScrollingCheckBox.isSelected() ) {
|
||||
custoMouseWheelScroller = new MouseWheelListener() {
|
||||
customMouseWheelScroller = new MouseWheelListener() {
|
||||
@Override
|
||||
public void mouseWheelMoved( MouseWheelEvent e ) {
|
||||
if( e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL ) {
|
||||
@@ -451,7 +453,45 @@ public class FlatContainerTest
|
||||
}
|
||||
};
|
||||
for( FlatTabbedPane tabbedPane : allTabbedPanes )
|
||||
tabbedPane.addMouseWheelListener( custoMouseWheelScroller );
|
||||
tabbedPane.addMouseWheelListener( customMouseWheelScroller );
|
||||
}
|
||||
}
|
||||
|
||||
private void contextMenuChanged() {
|
||||
if( contextMenuListener != null ) {
|
||||
for( FlatTabbedPane tabbedPane : allTabbedPanes )
|
||||
tabbedPane.removeMouseListener( contextMenuListener );
|
||||
contextMenuListener = null;
|
||||
}
|
||||
|
||||
if( contextMenuCheckBox.isSelected() ) {
|
||||
contextMenuListener = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed( MouseEvent e ) {
|
||||
popupMenu( e );
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased( MouseEvent e ) {
|
||||
popupMenu( e );
|
||||
}
|
||||
private void popupMenu( MouseEvent e ) {
|
||||
if( !e.isPopupTrigger() )
|
||||
return;
|
||||
|
||||
JTabbedPane tabbedPane = (JTabbedPane) e.getComponent();
|
||||
int tabIndex = tabbedPane.indexAtLocation( e.getX(), e.getY() );
|
||||
if( tabIndex < 0 )
|
||||
return;
|
||||
|
||||
JPopupMenu popupMenu = new JPopupMenu();
|
||||
popupMenu.add( "item 1" );
|
||||
popupMenu.add( "item 2" );
|
||||
popupMenu.add( "item 3" );
|
||||
popupMenu.show( tabbedPane, e.getX(), e.getY() );
|
||||
}
|
||||
};
|
||||
for( FlatTabbedPane tabbedPane : allTabbedPanes )
|
||||
tabbedPane.addMouseListener( contextMenuListener );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,6 +555,7 @@ public class FlatContainerTest
|
||||
secondTabWiderCheckBox = new JCheckBox();
|
||||
hideTabAreaWithOneTabCheckBox = new JCheckBox();
|
||||
customWheelScrollingCheckBox = new JCheckBox();
|
||||
contextMenuCheckBox = new JCheckBox();
|
||||
CellConstraints cc = new CellConstraints();
|
||||
|
||||
//======== this ========
|
||||
@@ -546,11 +587,11 @@ public class FlatContainerTest
|
||||
splitPane1.setOneTouchExpandable(true);
|
||||
|
||||
//---- panel15 ----
|
||||
panel15.setBackground(new Color(217, 163, 67));
|
||||
panel15.setBackground(new Color(0xd9a343));
|
||||
splitPane1.setLeftComponent(panel15);
|
||||
|
||||
//---- panel21 ----
|
||||
panel21.setBackground(new Color(98, 181, 67));
|
||||
panel21.setBackground(new Color(0x62b543));
|
||||
splitPane1.setRightComponent(panel21);
|
||||
}
|
||||
splitPane3.setLeftComponent(splitPane1);
|
||||
@@ -563,7 +604,7 @@ public class FlatContainerTest
|
||||
|
||||
//======== panel12 ========
|
||||
{
|
||||
panel12.setBackground(new Color(242, 101, 34));
|
||||
panel12.setBackground(new Color(0xf26522));
|
||||
panel12.setLayout(new BorderLayout());
|
||||
|
||||
//---- label3 ----
|
||||
@@ -576,7 +617,7 @@ public class FlatContainerTest
|
||||
|
||||
//======== panel13 ========
|
||||
{
|
||||
panel13.setBackground(new Color(64, 182, 224));
|
||||
panel13.setBackground(new Color(0x40b6e0));
|
||||
panel13.setLayout(new BorderLayout());
|
||||
|
||||
//---- label4 ----
|
||||
@@ -636,6 +677,7 @@ public class FlatContainerTest
|
||||
"[]para" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]"));
|
||||
|
||||
//---- tabScrollCheckBox ----
|
||||
@@ -828,6 +870,11 @@ public class FlatContainerTest
|
||||
customWheelScrollingCheckBox.setText("Custom wheel scrolling");
|
||||
customWheelScrollingCheckBox.addActionListener(e -> customWheelScrollingChanged());
|
||||
tabbedPaneControlPanel.add(customWheelScrollingCheckBox, "cell 2 11");
|
||||
|
||||
//---- contextMenuCheckBox ----
|
||||
contextMenuCheckBox.setText("Context menu on tabs");
|
||||
contextMenuCheckBox.addActionListener(e -> contextMenuChanged());
|
||||
tabbedPaneControlPanel.add(contextMenuCheckBox, "cell 2 12");
|
||||
}
|
||||
panel9.add(tabbedPaneControlPanel, cc.xywh(1, 11, 3, 1));
|
||||
}
|
||||
@@ -875,10 +922,12 @@ public class FlatContainerTest
|
||||
private JCheckBox secondTabWiderCheckBox;
|
||||
private JCheckBox hideTabAreaWithOneTabCheckBox;
|
||||
private JCheckBox customWheelScrollingCheckBox;
|
||||
private JCheckBox contextMenuCheckBox;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
|
||||
private FlatTabbedPane[] allTabbedPanes;
|
||||
private MouseWheelListener custoMouseWheelScroller;
|
||||
private MouseWheelListener customMouseWheelScroller;
|
||||
private MouseListener contextMenuListener;
|
||||
|
||||
//---- enum TabPlacement --------------------------------------------------
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
JFDML JFormDesigner: "7.0.3.1.342" Java: "16" encoding: "UTF-8"
|
||||
JFDML JFormDesigner: "8.0.0.0.194" Java: "17.0.2" encoding: "UTF-8"
|
||||
|
||||
new FormModel {
|
||||
contentType: "form/swing"
|
||||
@@ -132,7 +132,7 @@ new FormModel {
|
||||
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestFrame$NoRightToLeftPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "insets 0,hidemode 3"
|
||||
"$columnConstraints": "[][fill][]"
|
||||
"$rowConstraints": "[center][][][][][][]para[][]para[][][]"
|
||||
"$rowConstraints": "[center][][][][][][]para[][]para[][][][]"
|
||||
} ) {
|
||||
name: "tabbedPaneControlPanel"
|
||||
"opaque": false
|
||||
@@ -529,6 +529,16 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 11"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "contextMenuCheckBox"
|
||||
"text": "Context menu on tabs"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "contextMenuChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 12"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) {
|
||||
"gridY": 11
|
||||
"gridWidth": 3
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
`flatlaf-toolchain`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
16
gradlew
vendored
16
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,10 @@
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
@@ -205,6 +205,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
||||
14
gradlew.bat
vendored
14
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,7 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
Reference in New Issue
Block a user