mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
use AtomicReference for method parameters that return values
This commit is contained in:
@@ -23,6 +23,7 @@ import java.awt.event.ComponentListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComponent;
|
||||
@@ -143,7 +144,7 @@ public class FlatWindowMaximizeTest
|
||||
}
|
||||
|
||||
private static void testMaximize( String msg, int expectedState, boolean showLater, Consumer<JFrame> testFunc ) {
|
||||
JFrame[] pFrame = new JFrame[1];
|
||||
AtomicReference<JFrame> pFrame = new AtomicReference<>();
|
||||
EventQueue.invokeLater( () -> {
|
||||
JFrame frame = new JFrame( "test" );
|
||||
frame.setName( msg );
|
||||
@@ -164,7 +165,7 @@ public class FlatWindowMaximizeTest
|
||||
testFunc.accept( frame );
|
||||
if( !showLater )
|
||||
frame.setVisible( true );
|
||||
pFrame[0] = frame;
|
||||
pFrame.set( frame );
|
||||
} );
|
||||
|
||||
try {
|
||||
@@ -172,14 +173,14 @@ public class FlatWindowMaximizeTest
|
||||
Thread.sleep( 500 );
|
||||
|
||||
EventQueue.invokeLater( () -> {
|
||||
pFrame[0].setVisible( true );
|
||||
pFrame.get().setVisible( true );
|
||||
} );
|
||||
}
|
||||
|
||||
Thread.sleep( 500 );
|
||||
|
||||
EventQueue.invokeAndWait( () -> {
|
||||
int state = pFrame[0].getExtendedState();
|
||||
int state = pFrame.get().getExtendedState();
|
||||
System.out.printf( " %-15s: %d %s\n", msg, state, (state != expectedState ? " FAILED" : "") );
|
||||
} );
|
||||
} catch( Exception ex ) {
|
||||
|
||||
@@ -645,14 +645,14 @@ public class UIDefaultsDump
|
||||
}
|
||||
|
||||
private void dumpColor( PrintWriter out, String key, Color color ) {
|
||||
Color[] retBaseColor = new Color[1];
|
||||
AtomicReference<Color> retBaseColor = new AtomicReference<>();
|
||||
Color resolvedColor = resolveDerivedColor( key, color, retBaseColor );
|
||||
if( resolvedColor != color && resolvedColor.getRGB() != color.getRGB() ) {
|
||||
if( !isIntelliJTheme ) {
|
||||
System.err.println( "Key '" + key + "': derived colors not equal" );
|
||||
System.err.println( " Default color: " + dumpColorHexAndHSL( color ) );
|
||||
System.err.println( " Resolved color: " + dumpColorHexAndHSL( resolvedColor ) );
|
||||
System.err.println( " Base color: " + dumpColorHexAndHSL( retBaseColor[0] ) );
|
||||
System.err.println( " Base color: " + dumpColorHexAndHSL( retBaseColor.get() ) );
|
||||
}
|
||||
|
||||
out.printf( "%s / ",
|
||||
@@ -891,7 +891,7 @@ public class UIDefaultsDump
|
||||
return properties;
|
||||
}
|
||||
|
||||
private Color resolveDerivedColor( String key, Color color, Color[] retBaseColor ) {
|
||||
private Color resolveDerivedColor( String key, Color color, AtomicReference<Color> retBaseColor ) {
|
||||
if( !(color instanceof DerivedColor) )
|
||||
return color;
|
||||
|
||||
@@ -914,7 +914,7 @@ public class UIDefaultsDump
|
||||
if( baseColor instanceof DerivedColor )
|
||||
baseColor = resolveDerivedColor( (String) baseKey, baseColor, retBaseColor );
|
||||
|
||||
retBaseColor[0] = baseColor;
|
||||
retBaseColor.set( baseColor );
|
||||
|
||||
Color newColor = FlatUIUtils.deriveColor( color, baseColor );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user