mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 22:47:13 -06:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e869973d4 | ||
|
|
731c8962c9 | ||
|
|
294b8bb789 | ||
|
|
4f9b819f48 | ||
|
|
5318d5fa8e | ||
|
|
98b156bdde | ||
|
|
511dd02107 | ||
|
|
f1f7a2e7b6 | ||
|
|
d557cf5427 | ||
|
|
39d2941099 | ||
|
|
2a732306a1 | ||
|
|
8a72b30cbc | ||
|
|
ed9cb0f918 | ||
|
|
7e0915cb9c | ||
|
|
a51294d570 | ||
|
|
d962f218a1 | ||
|
|
7b248427f0 | ||
|
|
b99fb8b11f | ||
|
|
26250e790f | ||
|
|
b26dbe81f4 | ||
|
|
903212345b |
8
.gitbugtraq
Normal file
8
.gitbugtraq
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# links issue numbers in git commit messages to issue tracker
|
||||||
|
# https://github.com/mstrap/bugtraq
|
||||||
|
# for SmartGit - https://www.syntevo.com/smartgit/
|
||||||
|
|
||||||
|
[bugtraq]
|
||||||
|
url = "https://github.com/JFormDesigner/FlatLaf/issues/%BUGID%"
|
||||||
|
loglinkregex = "#[0-9]{1,5}"
|
||||||
|
logregex = "[0-9]{1,5}"
|
||||||
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,6 +1,27 @@
|
|||||||
FlatLaf Change Log
|
FlatLaf Change Log
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
## 1.3
|
||||||
|
|
||||||
|
#### New features and improvements
|
||||||
|
|
||||||
|
- TextComponents, ComboBox and Spinner: Support different background color when
|
||||||
|
component is focused (use UI values `TextField.focusedBackground`,
|
||||||
|
`PasswordField.focusedBackground`, `FormattedTextField.focusedBackground`,
|
||||||
|
`TextArea.focusedBackground`, `TextPane.focusedBackground`,
|
||||||
|
`EditorPane.focusedBackground`, `ComboBox.focusedBackground`,
|
||||||
|
`ComboBox.buttonFocusedBackground`, `ComboBox.popupFocusedBackground` and
|
||||||
|
`Spinner.focusedBackground`). (issue #335)
|
||||||
|
|
||||||
|
#### Fixed bugs
|
||||||
|
|
||||||
|
- Fixed white lines at bottom and right side of window (in dark themes on HiDPI
|
||||||
|
screens with scaling enabled).
|
||||||
|
- ScrollBar: Fixed left/top arrow icon location (if visible). (issue #329)
|
||||||
|
- Spinner: Fixed up/down arrow icon location.
|
||||||
|
- ToolTip: Fixed positioning of huge tooltips. (issue #333)
|
||||||
|
|
||||||
|
|
||||||
## 1.2
|
## 1.2
|
||||||
|
|
||||||
#### New features and improvements
|
#### New features and improvements
|
||||||
|
|||||||
@@ -76,11 +76,11 @@ Addons
|
|||||||
Getting started
|
Getting started
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
To enable FlatLaf, add following code to your main method before you create any
|
To use FlatLaf, add following code to your main method before you create any
|
||||||
Swing component:
|
Swing component:
|
||||||
|
|
||||||
~~~java
|
~~~java
|
||||||
FlatLightLaf.install();
|
FlatLightLaf.setup();
|
||||||
|
|
||||||
// create UI here...
|
// create UI here...
|
||||||
~~~
|
~~~
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
val releaseVersion = "1.2"
|
val releaseVersion = "1.3"
|
||||||
val developmentVersion = "1.3-SNAPSHOT"
|
val developmentVersion = "1.4-SNAPSHOT"
|
||||||
|
|
||||||
version = if( java.lang.Boolean.getBoolean( "release" ) ) releaseVersion else developmentVersion
|
version = if( java.lang.Boolean.getBoolean( "release" ) ) releaseVersion else developmentVersion
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class LinuxFontPolicy
|
|||||||
// find last word in family
|
// find last word in family
|
||||||
int index = family.lastIndexOf( ' ' );
|
int index = family.lastIndexOf( ' ' );
|
||||||
if( index < 0 )
|
if( index < 0 )
|
||||||
return createFont( "Dialog", style, size, dsize );;
|
return createFont( "Dialog", style, size, dsize );
|
||||||
|
|
||||||
// check whether last work contains some font weight (e.g. Ultra-Bold or Heavy)
|
// check whether last work contains some font weight (e.g. Ultra-Bold or Heavy)
|
||||||
String lastWord = family.substring( index + 1 ).toLowerCase();
|
String lastWord = family.substring( index + 1 ).toLowerCase();
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public class FlatArrowButton
|
|||||||
protected final Color pressedBackground;
|
protected final Color pressedBackground;
|
||||||
|
|
||||||
private int arrowWidth = DEFAULT_ARROW_WIDTH;
|
private int arrowWidth = DEFAULT_ARROW_WIDTH;
|
||||||
private int xOffset = 0;
|
private float xOffset = 0;
|
||||||
private int yOffset = 0;
|
private float yOffset = 0;
|
||||||
|
|
||||||
private boolean hover;
|
private boolean hover;
|
||||||
private boolean pressed;
|
private boolean pressed;
|
||||||
@@ -117,19 +117,19 @@ public class FlatArrowButton
|
|||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getXOffset() {
|
public float getXOffset() {
|
||||||
return xOffset;
|
return xOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setXOffset( int xOffset ) {
|
public void setXOffset( float xOffset ) {
|
||||||
this.xOffset = xOffset;
|
this.xOffset = xOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getYOffset() {
|
public float getYOffset() {
|
||||||
return yOffset;
|
return yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setYOffset( int yOffset ) {
|
public void setYOffset( float yOffset ) {
|
||||||
this.yOffset = yOffset;
|
this.yOffset = yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,17 +22,12 @@ import java.awt.Component;
|
|||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.KeyboardFocusManager;
|
|
||||||
import java.awt.Paint;
|
import java.awt.Paint;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.JTree;
|
|
||||||
import javax.swing.JViewport;
|
import javax.swing.JViewport;
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.basic.BasicBorders;
|
import javax.swing.plaf.basic.BasicBorders;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
@@ -164,37 +159,13 @@ public class FlatBorder
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isFocused( Component c ) {
|
protected boolean isFocused( Component c ) {
|
||||||
if( c instanceof JScrollPane ) {
|
if( c instanceof JScrollPane )
|
||||||
JViewport viewport = ((JScrollPane)c).getViewport();
|
return FlatScrollPaneUI.isPermanentFocusOwner( (JScrollPane) c );
|
||||||
Component view = (viewport != null) ? viewport.getView() : null;
|
else if( c instanceof JComboBox )
|
||||||
if( view != null ) {
|
return FlatComboBoxUI.isPermanentFocusOwner( (JComboBox<?>) c );
|
||||||
if( FlatUIUtils.isPermanentFocusOwner( view ) )
|
else if( c instanceof JSpinner )
|
||||||
return true;
|
return FlatSpinnerUI.isPermanentFocusOwner( (JSpinner) c );
|
||||||
|
else
|
||||||
if( (view instanceof JTable && ((JTable)view).isEditing()) ||
|
|
||||||
(view instanceof JTree && ((JTree)view).isEditing()) )
|
|
||||||
{
|
|
||||||
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
|
||||||
if( focusOwner != null )
|
|
||||||
return SwingUtilities.isDescendingFrom( focusOwner, view );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else if( c instanceof JComboBox && ((JComboBox<?>)c).isEditable() ) {
|
|
||||||
Component editorComponent = ((JComboBox<?>)c).getEditor().getEditorComponent();
|
|
||||||
return (editorComponent != null) ? FlatUIUtils.isPermanentFocusOwner( editorComponent ) : false;
|
|
||||||
} else if( c instanceof JSpinner ) {
|
|
||||||
if( FlatUIUtils.isPermanentFocusOwner( c ) )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
JComponent editor = ((JSpinner)c).getEditor();
|
|
||||||
if( editor instanceof JSpinner.DefaultEditor ) {
|
|
||||||
JTextField textField = ((JSpinner.DefaultEditor)editor).getTextField();
|
|
||||||
if( textField != null )
|
|
||||||
return FlatUIUtils.isPermanentFocusOwner( textField );
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else
|
|
||||||
return FlatUIUtils.isPermanentFocusOwner( c );
|
return FlatUIUtils.isPermanentFocusOwner( c );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ import javax.swing.UIManager;
|
|||||||
import javax.swing.border.AbstractBorder;
|
import javax.swing.border.AbstractBorder;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.plaf.basic.BasicComboBoxUI;
|
import javax.swing.plaf.basic.BasicComboBoxUI;
|
||||||
import javax.swing.plaf.basic.BasicComboPopup;
|
import javax.swing.plaf.basic.BasicComboPopup;
|
||||||
import javax.swing.plaf.basic.ComboPopup;
|
import javax.swing.plaf.basic.ComboPopup;
|
||||||
@@ -92,14 +93,17 @@ import com.formdev.flatlaf.util.UIScale;
|
|||||||
* @uiDefault Component.borderColor Color
|
* @uiDefault Component.borderColor Color
|
||||||
* @uiDefault Component.disabledBorderColor Color
|
* @uiDefault Component.disabledBorderColor Color
|
||||||
* @uiDefault ComboBox.editableBackground Color optional; defaults to ComboBox.background
|
* @uiDefault ComboBox.editableBackground Color optional; defaults to ComboBox.background
|
||||||
|
* @uiDefault ComboBox.focusedBackground Color optional
|
||||||
* @uiDefault ComboBox.disabledBackground Color
|
* @uiDefault ComboBox.disabledBackground Color
|
||||||
* @uiDefault ComboBox.disabledForeground Color
|
* @uiDefault ComboBox.disabledForeground Color
|
||||||
* @uiDefault ComboBox.buttonBackground Color
|
* @uiDefault ComboBox.buttonBackground Color
|
||||||
* @uiDefault ComboBox.buttonEditableBackground Color
|
* @uiDefault ComboBox.buttonEditableBackground Color
|
||||||
|
* @uiDefault ComboBox.buttonFocusedBackground Color optional; defaults to ComboBox.focusedBackground
|
||||||
* @uiDefault ComboBox.buttonArrowColor Color
|
* @uiDefault ComboBox.buttonArrowColor Color
|
||||||
* @uiDefault ComboBox.buttonDisabledArrowColor Color
|
* @uiDefault ComboBox.buttonDisabledArrowColor Color
|
||||||
* @uiDefault ComboBox.buttonHoverArrowColor Color
|
* @uiDefault ComboBox.buttonHoverArrowColor Color
|
||||||
* @uiDefault ComboBox.buttonPressedArrowColor Color
|
* @uiDefault ComboBox.buttonPressedArrowColor Color
|
||||||
|
* @uiDefault ComboBox.popupBackground Color optional
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -115,16 +119,20 @@ public class FlatComboBoxUI
|
|||||||
protected Color disabledBorderColor;
|
protected Color disabledBorderColor;
|
||||||
|
|
||||||
protected Color editableBackground;
|
protected Color editableBackground;
|
||||||
|
protected Color focusedBackground;
|
||||||
protected Color disabledBackground;
|
protected Color disabledBackground;
|
||||||
protected Color disabledForeground;
|
protected Color disabledForeground;
|
||||||
|
|
||||||
protected Color buttonBackground;
|
protected Color buttonBackground;
|
||||||
protected Color buttonEditableBackground;
|
protected Color buttonEditableBackground;
|
||||||
|
protected Color buttonFocusedBackground;
|
||||||
protected Color buttonArrowColor;
|
protected Color buttonArrowColor;
|
||||||
protected Color buttonDisabledArrowColor;
|
protected Color buttonDisabledArrowColor;
|
||||||
protected Color buttonHoverArrowColor;
|
protected Color buttonHoverArrowColor;
|
||||||
protected Color buttonPressedArrowColor;
|
protected Color buttonPressedArrowColor;
|
||||||
|
|
||||||
|
protected Color popupBackground;
|
||||||
|
|
||||||
private MouseListener hoverListener;
|
private MouseListener hoverListener;
|
||||||
protected boolean hover;
|
protected boolean hover;
|
||||||
protected boolean pressed;
|
protected boolean pressed;
|
||||||
@@ -195,16 +203,20 @@ public class FlatComboBoxUI
|
|||||||
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
||||||
|
|
||||||
editableBackground = UIManager.getColor( "ComboBox.editableBackground" );
|
editableBackground = UIManager.getColor( "ComboBox.editableBackground" );
|
||||||
|
focusedBackground = UIManager.getColor( "ComboBox.focusedBackground" );
|
||||||
disabledBackground = UIManager.getColor( "ComboBox.disabledBackground" );
|
disabledBackground = UIManager.getColor( "ComboBox.disabledBackground" );
|
||||||
disabledForeground = UIManager.getColor( "ComboBox.disabledForeground" );
|
disabledForeground = UIManager.getColor( "ComboBox.disabledForeground" );
|
||||||
|
|
||||||
buttonBackground = UIManager.getColor( "ComboBox.buttonBackground" );
|
buttonBackground = UIManager.getColor( "ComboBox.buttonBackground" );
|
||||||
|
buttonFocusedBackground = UIManager.getColor( "ComboBox.buttonFocusedBackground" );
|
||||||
buttonEditableBackground = UIManager.getColor( "ComboBox.buttonEditableBackground" );
|
buttonEditableBackground = UIManager.getColor( "ComboBox.buttonEditableBackground" );
|
||||||
buttonArrowColor = UIManager.getColor( "ComboBox.buttonArrowColor" );
|
buttonArrowColor = UIManager.getColor( "ComboBox.buttonArrowColor" );
|
||||||
buttonDisabledArrowColor = UIManager.getColor( "ComboBox.buttonDisabledArrowColor" );
|
buttonDisabledArrowColor = UIManager.getColor( "ComboBox.buttonDisabledArrowColor" );
|
||||||
buttonHoverArrowColor = UIManager.getColor( "ComboBox.buttonHoverArrowColor" );
|
buttonHoverArrowColor = UIManager.getColor( "ComboBox.buttonHoverArrowColor" );
|
||||||
buttonPressedArrowColor = UIManager.getColor( "ComboBox.buttonPressedArrowColor" );
|
buttonPressedArrowColor = UIManager.getColor( "ComboBox.buttonPressedArrowColor" );
|
||||||
|
|
||||||
|
popupBackground = UIManager.getColor( "ComboBox.popupBackground" );
|
||||||
|
|
||||||
// set maximumRowCount
|
// set maximumRowCount
|
||||||
int maximumRowCount = UIManager.getInt( "ComboBox.maximumRowCount" );
|
int maximumRowCount = UIManager.getInt( "ComboBox.maximumRowCount" );
|
||||||
if( maximumRowCount > 0 && maximumRowCount != 8 && comboBox.getMaximumRowCount() == 8 )
|
if( maximumRowCount > 0 && maximumRowCount != 8 && comboBox.getMaximumRowCount() == 8 )
|
||||||
@@ -224,16 +236,20 @@ public class FlatComboBoxUI
|
|||||||
disabledBorderColor = null;
|
disabledBorderColor = null;
|
||||||
|
|
||||||
editableBackground = null;
|
editableBackground = null;
|
||||||
|
focusedBackground = null;
|
||||||
disabledBackground = null;
|
disabledBackground = null;
|
||||||
disabledForeground = null;
|
disabledForeground = null;
|
||||||
|
|
||||||
buttonBackground = null;
|
buttonBackground = null;
|
||||||
buttonEditableBackground = null;
|
buttonEditableBackground = null;
|
||||||
|
buttonFocusedBackground = null;
|
||||||
buttonArrowColor = null;
|
buttonArrowColor = null;
|
||||||
buttonDisabledArrowColor = null;
|
buttonDisabledArrowColor = null;
|
||||||
buttonHoverArrowColor = null;
|
buttonHoverArrowColor = null;
|
||||||
buttonPressedArrowColor = null;
|
buttonPressedArrowColor = null;
|
||||||
|
|
||||||
|
popupBackground = null;
|
||||||
|
|
||||||
MigLayoutVisualPadding.uninstall( comboBox );
|
MigLayoutVisualPadding.uninstall( comboBox );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +439,11 @@ public class FlatComboBoxUI
|
|||||||
|
|
||||||
// paint arrow button background
|
// paint arrow button background
|
||||||
if( enabled && !isCellRenderer ) {
|
if( enabled && !isCellRenderer ) {
|
||||||
g2.setColor( paintButton ? buttonEditableBackground : buttonBackground );
|
g2.setColor( paintButton
|
||||||
|
? buttonEditableBackground
|
||||||
|
: (buttonFocusedBackground != null || focusedBackground != null) && isPermanentFocusOwner( comboBox )
|
||||||
|
? (buttonFocusedBackground != null ? buttonFocusedBackground : focusedBackground)
|
||||||
|
: buttonBackground );
|
||||||
Shape oldClip = g2.getClip();
|
Shape oldClip = g2.getClip();
|
||||||
if( isLeftToRight )
|
if( isLeftToRight )
|
||||||
g2.clipRect( arrowX, 0, width - arrowX, height );
|
g2.clipRect( arrowX, 0, width - arrowX, height );
|
||||||
@@ -483,9 +503,20 @@ public class FlatComboBoxUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Color getBackground( boolean enabled ) {
|
protected Color getBackground( boolean enabled ) {
|
||||||
return enabled
|
if( enabled ) {
|
||||||
? (editableBackground != null && comboBox.isEditable() ? editableBackground : comboBox.getBackground())
|
Color background = comboBox.getBackground();
|
||||||
: (isIntelliJTheme ? FlatUIUtils.getParentBackground( comboBox ) : disabledBackground);
|
|
||||||
|
// always use explicitly set color
|
||||||
|
if( !(background instanceof UIResource) )
|
||||||
|
return background;
|
||||||
|
|
||||||
|
// focused
|
||||||
|
if( focusedBackground != null && isPermanentFocusOwner( comboBox ) )
|
||||||
|
return focusedBackground;
|
||||||
|
|
||||||
|
return (editableBackground != null && comboBox.isEditable()) ? editableBackground : background;
|
||||||
|
} else
|
||||||
|
return isIntelliJTheme ? FlatUIUtils.getParentBackground( comboBox ) : disabledBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Color getForeground( boolean enabled ) {
|
protected Color getForeground( boolean enabled ) {
|
||||||
@@ -576,6 +607,17 @@ public class FlatComboBoxUI
|
|||||||
return parentParent != null && !comboBox.getBackground().equals( parentParent.getBackground() );
|
return parentParent != null && !comboBox.getBackground().equals( parentParent.getBackground() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.3
|
||||||
|
*/
|
||||||
|
public static boolean isPermanentFocusOwner( JComboBox<?> comboBox ) {
|
||||||
|
if( comboBox.isEditable() ) {
|
||||||
|
Component editorComponent = comboBox.getEditor().getEditorComponent();
|
||||||
|
return (editorComponent != null) ? FlatUIUtils.isPermanentFocusOwner( editorComponent ) : false;
|
||||||
|
} else
|
||||||
|
return FlatUIUtils.isPermanentFocusOwner( comboBox );
|
||||||
|
}
|
||||||
|
|
||||||
//---- class FlatComboBoxButton -------------------------------------------
|
//---- class FlatComboBoxButton -------------------------------------------
|
||||||
|
|
||||||
protected class FlatComboBoxButton
|
protected class FlatComboBoxButton
|
||||||
@@ -688,6 +730,8 @@ public class FlatComboBoxUI
|
|||||||
super.configureList();
|
super.configureList();
|
||||||
|
|
||||||
list.setCellRenderer( new PopupListCellRenderer() );
|
list.setCellRenderer( new PopupListCellRenderer() );
|
||||||
|
if( popupBackground != null )
|
||||||
|
list.setBackground( popupBackground );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,15 +17,16 @@
|
|||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import static com.formdev.flatlaf.util.UIScale.scale;
|
import static com.formdev.flatlaf.util.UIScale.scale;
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JEditorPane;
|
import javax.swing.JEditorPane;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.UIResource;
|
|
||||||
import javax.swing.plaf.basic.BasicEditorPaneUI;
|
import javax.swing.plaf.basic.BasicEditorPaneUI;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
@@ -53,6 +54,7 @@ import com.formdev.flatlaf.util.HiDPIUtils;
|
|||||||
*
|
*
|
||||||
* @uiDefault Component.minimumWidth int
|
* @uiDefault Component.minimumWidth int
|
||||||
* @uiDefault Component.isIntelliJTheme boolean
|
* @uiDefault Component.isIntelliJTheme boolean
|
||||||
|
* @uiDefault EditorPane.focusedBackground Color optional
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -61,8 +63,10 @@ public class FlatEditorPaneUI
|
|||||||
{
|
{
|
||||||
protected int minimumWidth;
|
protected int minimumWidth;
|
||||||
protected boolean isIntelliJTheme;
|
protected boolean isIntelliJTheme;
|
||||||
|
protected Color focusedBackground;
|
||||||
|
|
||||||
private Object oldHonorDisplayProperties;
|
private Object oldHonorDisplayProperties;
|
||||||
|
private FocusListener focusListener;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatEditorPaneUI();
|
return new FlatEditorPaneUI();
|
||||||
@@ -72,8 +76,10 @@ public class FlatEditorPaneUI
|
|||||||
protected void installDefaults() {
|
protected void installDefaults() {
|
||||||
super.installDefaults();
|
super.installDefaults();
|
||||||
|
|
||||||
|
String prefix = getPropertyPrefix();
|
||||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||||
|
focusedBackground = UIManager.getColor( prefix + ".focusedBackground" );
|
||||||
|
|
||||||
// use component font and foreground for HTML text
|
// use component font and foreground for HTML text
|
||||||
oldHonorDisplayProperties = getComponent().getClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES );
|
oldHonorDisplayProperties = getComponent().getClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES );
|
||||||
@@ -84,9 +90,28 @@ public class FlatEditorPaneUI
|
|||||||
protected void uninstallDefaults() {
|
protected void uninstallDefaults() {
|
||||||
super.uninstallDefaults();
|
super.uninstallDefaults();
|
||||||
|
|
||||||
|
focusedBackground = null;
|
||||||
|
|
||||||
getComponent().putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, oldHonorDisplayProperties );
|
getComponent().putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, oldHonorDisplayProperties );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installListeners() {
|
||||||
|
super.installListeners();
|
||||||
|
|
||||||
|
// necessary to update focus background
|
||||||
|
focusListener = new FlatUIUtils.RepaintFocusListener( getComponent(), c -> focusedBackground != null );
|
||||||
|
getComponent().addFocusListener( focusListener );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void uninstallListeners() {
|
||||||
|
super.uninstallListeners();
|
||||||
|
|
||||||
|
getComponent().removeFocusListener( focusListener );
|
||||||
|
focusListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void propertyChange( PropertyChangeEvent e ) {
|
protected void propertyChange( PropertyChangeEvent e ) {
|
||||||
super.propertyChange( e );
|
super.propertyChange( e );
|
||||||
@@ -128,14 +153,11 @@ public class FlatEditorPaneUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintBackground( Graphics g ) {
|
protected void paintBackground( Graphics g ) {
|
||||||
JTextComponent c = getComponent();
|
paintBackground( g, getComponent(), isIntelliJTheme, focusedBackground );
|
||||||
|
}
|
||||||
|
|
||||||
// for compatibility with IntelliJ themes
|
static void paintBackground( Graphics g, JTextComponent c, boolean isIntelliJTheme, Color focusedBackground ) {
|
||||||
if( isIntelliJTheme && (!c.isEnabled() || !c.isEditable()) && (c.getBackground() instanceof UIResource) ) {
|
g.setColor( FlatTextFieldUI.getBackground( c, isIntelliJTheme, focusedBackground ) );
|
||||||
FlatUIUtils.paintParentBackground( g, c );
|
g.fillRect( 0, 0, c.getWidth(), c.getHeight() );
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.paintBackground( g );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import javax.swing.plaf.ComponentUI;
|
|||||||
* @uiDefault Component.minimumWidth int
|
* @uiDefault Component.minimumWidth int
|
||||||
* @uiDefault Component.isIntelliJTheme boolean
|
* @uiDefault Component.isIntelliJTheme boolean
|
||||||
* @uiDefault FormattedTextField.placeholderForeground Color
|
* @uiDefault FormattedTextField.placeholderForeground Color
|
||||||
|
* @uiDefault FormattedTextField.focusedBackground Color optional
|
||||||
* @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
|
* @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
|
||||||
* @uiDefault TextComponent.selectAllOnMouseClick boolean
|
* @uiDefault TextComponent.selectAllOnMouseClick boolean
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ import com.formdev.flatlaf.util.HiDPIUtils;
|
|||||||
* @uiDefault Component.minimumWidth int
|
* @uiDefault Component.minimumWidth int
|
||||||
* @uiDefault Component.isIntelliJTheme boolean
|
* @uiDefault Component.isIntelliJTheme boolean
|
||||||
* @uiDefault PasswordField.placeholderForeground Color
|
* @uiDefault PasswordField.placeholderForeground Color
|
||||||
|
* @uiDefault PasswordField.focusedBackground Color optional
|
||||||
* @uiDefault PasswordField.showCapsLock boolean
|
* @uiDefault PasswordField.showCapsLock boolean
|
||||||
* @uiDefault PasswordField.capsLockIcon Icon
|
* @uiDefault PasswordField.capsLockIcon Icon
|
||||||
* @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
|
* @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
|
||||||
@@ -73,6 +74,7 @@ public class FlatPasswordFieldUI
|
|||||||
protected int minimumWidth;
|
protected int minimumWidth;
|
||||||
protected boolean isIntelliJTheme;
|
protected boolean isIntelliJTheme;
|
||||||
protected Color placeholderForeground;
|
protected Color placeholderForeground;
|
||||||
|
protected Color focusedBackground;
|
||||||
protected boolean showCapsLock;
|
protected boolean showCapsLock;
|
||||||
protected Icon capsLockIcon;
|
protected Icon capsLockIcon;
|
||||||
|
|
||||||
@@ -91,6 +93,7 @@ public class FlatPasswordFieldUI
|
|||||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||||
placeholderForeground = UIManager.getColor( prefix + ".placeholderForeground" );
|
placeholderForeground = UIManager.getColor( prefix + ".placeholderForeground" );
|
||||||
|
focusedBackground = UIManager.getColor( prefix + ".focusedBackground" );
|
||||||
showCapsLock = UIManager.getBoolean( "PasswordField.showCapsLock" );
|
showCapsLock = UIManager.getBoolean( "PasswordField.showCapsLock" );
|
||||||
capsLockIcon = UIManager.getIcon( "PasswordField.capsLockIcon" );
|
capsLockIcon = UIManager.getIcon( "PasswordField.capsLockIcon" );
|
||||||
|
|
||||||
@@ -104,6 +107,7 @@ public class FlatPasswordFieldUI
|
|||||||
super.uninstallDefaults();
|
super.uninstallDefaults();
|
||||||
|
|
||||||
placeholderForeground = null;
|
placeholderForeground = null;
|
||||||
|
focusedBackground = null;
|
||||||
capsLockIcon = null;
|
capsLockIcon = null;
|
||||||
|
|
||||||
MigLayoutVisualPadding.uninstall( getComponent() );
|
MigLayoutVisualPadding.uninstall( getComponent() );
|
||||||
@@ -113,7 +117,10 @@ public class FlatPasswordFieldUI
|
|||||||
protected void installListeners() {
|
protected void installListeners() {
|
||||||
super.installListeners();
|
super.installListeners();
|
||||||
|
|
||||||
focusListener = new FlatUIUtils.RepaintFocusListener( getComponent() );
|
// necessary to update focus border and background
|
||||||
|
focusListener = new FlatUIUtils.RepaintFocusListener( getComponent(), null );
|
||||||
|
|
||||||
|
// update caps lock indicator
|
||||||
capsLockListener = new KeyAdapter() {
|
capsLockListener = new KeyAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed( KeyEvent e ) {
|
public void keyPressed( KeyEvent e ) {
|
||||||
@@ -157,7 +164,7 @@ public class FlatPasswordFieldUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintSafely( Graphics g ) {
|
protected void paintSafely( Graphics g ) {
|
||||||
FlatTextFieldUI.paintBackground( g, getComponent(), isIntelliJTheme );
|
FlatTextFieldUI.paintBackground( g, getComponent(), isIntelliJTheme, focusedBackground );
|
||||||
FlatTextFieldUI.paintPlaceholder( g, getComponent(), placeholderForeground );
|
FlatTextFieldUI.paintPlaceholder( g, getComponent(), placeholderForeground );
|
||||||
paintCapsLock( g );
|
paintCapsLock( g );
|
||||||
|
|
||||||
|
|||||||
@@ -20,12 +20,16 @@ import java.awt.Color;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.MouseInfo;
|
import java.awt.MouseInfo;
|
||||||
import java.awt.Panel;
|
import java.awt.Panel;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.PointerInfo;
|
import java.awt.PointerInfo;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.Toolkit;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.ComponentEvent;
|
import java.awt.event.ComponentEvent;
|
||||||
import java.awt.event.ComponentListener;
|
import java.awt.event.ComponentListener;
|
||||||
@@ -63,7 +67,7 @@ public class FlatPopupFactory
|
|||||||
public Popup getPopup( Component owner, Component contents, int x, int y )
|
public Popup getPopup( Component owner, Component contents, int x, int y )
|
||||||
throws IllegalArgumentException
|
throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
Point pt = fixToolTipLocation( contents, x, y );
|
Point pt = fixToolTipLocation( owner, contents, x, y );
|
||||||
if( pt != null ) {
|
if( pt != null ) {
|
||||||
x = pt.x;
|
x = pt.x;
|
||||||
y = pt.y;
|
y = pt.y;
|
||||||
@@ -207,13 +211,13 @@ public class FlatPopupFactory
|
|||||||
/**
|
/**
|
||||||
* Usually ToolTipManager places a tooltip at (mouseLocation.x, mouseLocation.y + 20).
|
* Usually ToolTipManager places a tooltip at (mouseLocation.x, mouseLocation.y + 20).
|
||||||
* In case that the tooltip would be partly outside of the screen,
|
* In case that the tooltip would be partly outside of the screen,
|
||||||
* ToolTipManagerthe changes the location so that the entire tooltip fits on screen.
|
* the ToolTipManager changes the location so that the entire tooltip fits on screen.
|
||||||
* But this can place the tooltip under the mouse location and hide the owner component.
|
* But this can place the tooltip under the mouse location and hide the owner component.
|
||||||
* <p>
|
* <p>
|
||||||
* This method checks whether the current mouse location is within tooltip bounds
|
* This method checks whether the current mouse location is within tooltip bounds
|
||||||
* and corrects the y-location so that the tooltip is placed above the mouse location.
|
* and corrects the y-location so that the tooltip is placed above the mouse location.
|
||||||
*/
|
*/
|
||||||
private Point fixToolTipLocation( Component contents, int x, int y ) {
|
private Point fixToolTipLocation( Component owner, Component contents, int x, int y ) {
|
||||||
if( !(contents instanceof JToolTip) || !wasInvokedFromToolTipManager() )
|
if( !(contents instanceof JToolTip) || !wasInvokedFromToolTipManager() )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -229,8 +233,30 @@ public class FlatPopupFactory
|
|||||||
if( !tipBounds.contains( mouseLocation ) )
|
if( !tipBounds.contains( mouseLocation ) )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// place tooltip above mouse location
|
// find GraphicsConfiguration at mouse location (similar to ToolTipManager.getDrawingGC())
|
||||||
return new Point( x, mouseLocation.y - tipSize.height - UIScale.scale( 20 ) );
|
GraphicsConfiguration gc = null;
|
||||||
|
for( GraphicsDevice device : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices() ) {
|
||||||
|
GraphicsConfiguration dgc = device.getDefaultConfiguration();
|
||||||
|
if( dgc.getBounds().contains( mouseLocation ) ) {
|
||||||
|
gc = dgc;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( gc == null )
|
||||||
|
gc = owner.getGraphicsConfiguration();
|
||||||
|
if( gc == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Rectangle screenBounds = gc.getBounds();
|
||||||
|
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( gc );
|
||||||
|
int screenTop = screenBounds.y + screenInsets.top;
|
||||||
|
|
||||||
|
// place tooltip above mouse location if there is enough space
|
||||||
|
int newY = mouseLocation.y - tipSize.height - UIScale.scale( 20 );
|
||||||
|
if( newY < screenTop )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return new Point( x, newY );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean wasInvokedFromToolTipManager() {
|
private boolean wasInvokedFromToolTipManager() {
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ import java.awt.Insets;
|
|||||||
import java.awt.LayoutManager;
|
import java.awt.LayoutManager;
|
||||||
import java.awt.LayoutManager2;
|
import java.awt.LayoutManager2;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
|
import java.awt.event.HierarchyEvent;
|
||||||
|
import java.awt.event.HierarchyListener;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
@@ -79,6 +81,7 @@ public class FlatRootPaneUI
|
|||||||
|
|
||||||
private Object nativeWindowBorderData;
|
private Object nativeWindowBorderData;
|
||||||
private LayoutManager oldLayout;
|
private LayoutManager oldLayout;
|
||||||
|
private HierarchyListener hierarchyListener;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatRootPaneUI();
|
return new FlatRootPaneUI();
|
||||||
@@ -136,6 +139,39 @@ public class FlatRootPaneUI
|
|||||||
c.putClientProperty( "jetbrains.awt.windowDarkAppearance", FlatLaf.isLafDark() );
|
c.putClientProperty( "jetbrains.awt.windowDarkAppearance", FlatLaf.isLafDark() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installListeners( JRootPane root ) {
|
||||||
|
super.installListeners( root );
|
||||||
|
|
||||||
|
if( SystemInfo.isJava_9_orLater ) {
|
||||||
|
// On HiDPI screens, where scaling is used, there may be white lines at the
|
||||||
|
// bottom and at the right side of the window when it is initially shown.
|
||||||
|
// This is very disturbing in dark themes, but hard to notice in light themes.
|
||||||
|
// Seems to be a rounding issue when Swing adds dirty region of window
|
||||||
|
// using RepaintManager.nativeAddDirtyRegion().
|
||||||
|
hierarchyListener = e -> {
|
||||||
|
if( (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 &&
|
||||||
|
rootPane.getParent() instanceof Window )
|
||||||
|
{
|
||||||
|
// add whole root pane to dirty regions when window is initially shown
|
||||||
|
rootPane.getParent().repaint( rootPane.getX(), rootPane.getY(),
|
||||||
|
rootPane.getWidth(), rootPane.getHeight() );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
root.addHierarchyListener( hierarchyListener );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void uninstallListeners( JRootPane root ) {
|
||||||
|
super.uninstallListeners( root );
|
||||||
|
|
||||||
|
if( SystemInfo.isJava_9_orLater ) {
|
||||||
|
root.removeHierarchyListener( hierarchyListener );
|
||||||
|
hierarchyListener = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 1.1.2
|
* @since 1.1.2
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.ui;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.KeyboardFocusManager;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.ContainerEvent;
|
import java.awt.event.ContainerEvent;
|
||||||
import java.awt.event.ContainerListener;
|
import java.awt.event.ContainerListener;
|
||||||
@@ -34,11 +35,13 @@ import javax.swing.JComponent;
|
|||||||
import javax.swing.JScrollBar;
|
import javax.swing.JScrollBar;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JTree;
|
||||||
import javax.swing.JViewport;
|
import javax.swing.JViewport;
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
import javax.swing.ScrollPaneConstants;
|
import javax.swing.ScrollPaneConstants;
|
||||||
import javax.swing.Scrollable;
|
import javax.swing.Scrollable;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicScrollPaneUI;
|
import javax.swing.plaf.basic.BasicScrollPaneUI;
|
||||||
@@ -329,6 +332,31 @@ public class FlatScrollPaneUI
|
|||||||
paint( g, c );
|
paint( g, c );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.3
|
||||||
|
*/
|
||||||
|
public static boolean isPermanentFocusOwner( JScrollPane scrollPane ) {
|
||||||
|
JViewport viewport = scrollPane.getViewport();
|
||||||
|
Component view = (viewport != null) ? viewport.getView() : null;
|
||||||
|
if( view == null )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// check whether view is focus owner
|
||||||
|
if( FlatUIUtils.isPermanentFocusOwner( view ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// check whether editor component in JTable or JTree is focus owner
|
||||||
|
if( (view instanceof JTable && ((JTable)view).isEditing()) ||
|
||||||
|
(view instanceof JTree && ((JTree)view).isEditing()) )
|
||||||
|
{
|
||||||
|
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||||
|
if( focusOwner != null )
|
||||||
|
return SwingUtilities.isDescendingFrom( focusOwner, view );
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//---- class Handler ------------------------------------------------------
|
//---- class Handler ------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -350,11 +378,13 @@ public class FlatScrollPaneUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void focusGained( FocusEvent e ) {
|
public void focusGained( FocusEvent e ) {
|
||||||
|
// necessary to update focus border
|
||||||
scrollpane.repaint();
|
scrollpane.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void focusLost( FocusEvent e ) {
|
public void focusLost( FocusEvent e ) {
|
||||||
|
// necessary to update focus border
|
||||||
scrollpane.repaint();
|
scrollpane.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import javax.swing.LookAndFeel;
|
|||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
|
import javax.swing.plaf.UIResource;
|
||||||
import javax.swing.plaf.basic.BasicSpinnerUI;
|
import javax.swing.plaf.basic.BasicSpinnerUI;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ import com.formdev.flatlaf.FlatClientProperties;
|
|||||||
* @uiDefault Component.disabledBorderColor Color
|
* @uiDefault Component.disabledBorderColor Color
|
||||||
* @uiDefault Spinner.disabledBackground Color
|
* @uiDefault Spinner.disabledBackground Color
|
||||||
* @uiDefault Spinner.disabledForeground Color
|
* @uiDefault Spinner.disabledForeground Color
|
||||||
|
* @uiDefault Spinner.focusedBackground Color optional
|
||||||
* @uiDefault Spinner.buttonBackground Color
|
* @uiDefault Spinner.buttonBackground Color
|
||||||
* @uiDefault Spinner.buttonArrowColor Color
|
* @uiDefault Spinner.buttonArrowColor Color
|
||||||
* @uiDefault Spinner.buttonDisabledArrowColor Color
|
* @uiDefault Spinner.buttonDisabledArrowColor Color
|
||||||
@@ -87,6 +89,7 @@ public class FlatSpinnerUI
|
|||||||
protected Color disabledBorderColor;
|
protected Color disabledBorderColor;
|
||||||
protected Color disabledBackground;
|
protected Color disabledBackground;
|
||||||
protected Color disabledForeground;
|
protected Color disabledForeground;
|
||||||
|
protected Color focusedBackground;
|
||||||
protected Color buttonBackground;
|
protected Color buttonBackground;
|
||||||
protected Color buttonArrowColor;
|
protected Color buttonArrowColor;
|
||||||
protected Color buttonDisabledArrowColor;
|
protected Color buttonDisabledArrowColor;
|
||||||
@@ -112,6 +115,7 @@ public class FlatSpinnerUI
|
|||||||
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
|
||||||
disabledBackground = UIManager.getColor( "Spinner.disabledBackground" );
|
disabledBackground = UIManager.getColor( "Spinner.disabledBackground" );
|
||||||
disabledForeground = UIManager.getColor( "Spinner.disabledForeground" );
|
disabledForeground = UIManager.getColor( "Spinner.disabledForeground" );
|
||||||
|
focusedBackground = UIManager.getColor( "Spinner.focusedBackground" );
|
||||||
buttonBackground = UIManager.getColor( "Spinner.buttonBackground" );
|
buttonBackground = UIManager.getColor( "Spinner.buttonBackground" );
|
||||||
buttonArrowColor = UIManager.getColor( "Spinner.buttonArrowColor" );
|
buttonArrowColor = UIManager.getColor( "Spinner.buttonArrowColor" );
|
||||||
buttonDisabledArrowColor = UIManager.getColor( "Spinner.buttonDisabledArrowColor" );
|
buttonDisabledArrowColor = UIManager.getColor( "Spinner.buttonDisabledArrowColor" );
|
||||||
@@ -133,6 +137,7 @@ public class FlatSpinnerUI
|
|||||||
disabledBorderColor = null;
|
disabledBorderColor = null;
|
||||||
disabledBackground = null;
|
disabledBackground = null;
|
||||||
disabledForeground = null;
|
disabledForeground = null;
|
||||||
|
focusedBackground = null;
|
||||||
buttonBackground = null;
|
buttonBackground = null;
|
||||||
buttonArrowColor = null;
|
buttonArrowColor = null;
|
||||||
buttonDisabledArrowColor = null;
|
buttonDisabledArrowColor = null;
|
||||||
@@ -221,10 +226,34 @@ public class FlatSpinnerUI
|
|||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.3
|
||||||
|
*/
|
||||||
|
public static boolean isPermanentFocusOwner( JSpinner spinner ) {
|
||||||
|
if( FlatUIUtils.isPermanentFocusOwner( spinner ) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
JTextField textField = getEditorTextField( spinner.getEditor() );
|
||||||
|
return (textField != null)
|
||||||
|
? FlatUIUtils.isPermanentFocusOwner( textField )
|
||||||
|
: false;
|
||||||
|
}
|
||||||
|
|
||||||
protected Color getBackground( boolean enabled ) {
|
protected Color getBackground( boolean enabled ) {
|
||||||
return enabled
|
if( enabled ) {
|
||||||
? spinner.getBackground()
|
Color background = spinner.getBackground();
|
||||||
: (isIntelliJTheme ? FlatUIUtils.getParentBackground( spinner ) : disabledBackground);
|
|
||||||
|
// always use explicitly set color
|
||||||
|
if( !(background instanceof UIResource) )
|
||||||
|
return background;
|
||||||
|
|
||||||
|
// focused
|
||||||
|
if( focusedBackground != null && isPermanentFocusOwner( spinner ) )
|
||||||
|
return focusedBackground;
|
||||||
|
|
||||||
|
return background;
|
||||||
|
} else
|
||||||
|
return isIntelliJTheme ? FlatUIUtils.getParentBackground( spinner ) : disabledBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Color getForeground( boolean enabled ) {
|
protected Color getForeground( boolean enabled ) {
|
||||||
@@ -250,7 +279,7 @@ public class FlatSpinnerUI
|
|||||||
FlatArrowButton button = new FlatArrowButton( direction, arrowType, buttonArrowColor,
|
FlatArrowButton button = new FlatArrowButton( direction, arrowType, buttonArrowColor,
|
||||||
buttonDisabledArrowColor, buttonHoverArrowColor, null, buttonPressedArrowColor, null );
|
buttonDisabledArrowColor, buttonHoverArrowColor, null, buttonPressedArrowColor, null );
|
||||||
button.setName( name );
|
button.setName( name );
|
||||||
button.setYOffset( (direction == SwingConstants.NORTH) ? 1 : -1 );
|
button.setYOffset( (direction == SwingConstants.NORTH) ? 1.25f : -1.25f );
|
||||||
if( direction == SwingConstants.NORTH )
|
if( direction == SwingConstants.NORTH )
|
||||||
installNextButtonListeners( button );
|
installNextButtonListeners( button );
|
||||||
else
|
else
|
||||||
@@ -405,6 +434,7 @@ public class FlatSpinnerUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void focusGained( FocusEvent e ) {
|
public void focusGained( FocusEvent e ) {
|
||||||
|
// necessary to update focus border
|
||||||
spinner.repaint();
|
spinner.repaint();
|
||||||
|
|
||||||
// if spinner gained focus, transfer it to the editor text field
|
// if spinner gained focus, transfer it to the editor text field
|
||||||
@@ -417,6 +447,7 @@ public class FlatSpinnerUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void focusLost( FocusEvent e ) {
|
public void focusLost( FocusEvent e ) {
|
||||||
|
// necessary to update focus border
|
||||||
spinner.repaint();
|
spinner.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
@@ -52,6 +53,7 @@ import com.formdev.flatlaf.util.HiDPIUtils;
|
|||||||
* @uiDefault Component.isIntelliJTheme boolean
|
* @uiDefault Component.isIntelliJTheme boolean
|
||||||
* @uiDefault TextArea.disabledBackground Color used if not enabled
|
* @uiDefault TextArea.disabledBackground Color used if not enabled
|
||||||
* @uiDefault TextArea.inactiveBackground Color used if not editable
|
* @uiDefault TextArea.inactiveBackground Color used if not editable
|
||||||
|
* @uiDefault TextArea.focusedBackground Color optional
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -63,6 +65,9 @@ public class FlatTextAreaUI
|
|||||||
protected Color background;
|
protected Color background;
|
||||||
protected Color disabledBackground;
|
protected Color disabledBackground;
|
||||||
protected Color inactiveBackground;
|
protected Color inactiveBackground;
|
||||||
|
protected Color focusedBackground;
|
||||||
|
|
||||||
|
private FocusListener focusListener;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatTextAreaUI();
|
return new FlatTextAreaUI();
|
||||||
@@ -84,6 +89,7 @@ public class FlatTextAreaUI
|
|||||||
background = UIManager.getColor( "TextArea.background" );
|
background = UIManager.getColor( "TextArea.background" );
|
||||||
disabledBackground = UIManager.getColor( "TextArea.disabledBackground" );
|
disabledBackground = UIManager.getColor( "TextArea.disabledBackground" );
|
||||||
inactiveBackground = UIManager.getColor( "TextArea.inactiveBackground" );
|
inactiveBackground = UIManager.getColor( "TextArea.inactiveBackground" );
|
||||||
|
focusedBackground = UIManager.getColor( "TextArea.focusedBackground" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,6 +99,24 @@ public class FlatTextAreaUI
|
|||||||
background = null;
|
background = null;
|
||||||
disabledBackground = null;
|
disabledBackground = null;
|
||||||
inactiveBackground = null;
|
inactiveBackground = null;
|
||||||
|
focusedBackground = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installListeners() {
|
||||||
|
super.installListeners();
|
||||||
|
|
||||||
|
// necessary to update focus background
|
||||||
|
focusListener = new FlatUIUtils.RepaintFocusListener( getComponent(), c -> focusedBackground != null );
|
||||||
|
getComponent().addFocusListener( focusListener );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void uninstallListeners() {
|
||||||
|
super.uninstallListeners();
|
||||||
|
|
||||||
|
getComponent().removeFocusListener( focusListener );
|
||||||
|
focusListener = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -156,14 +180,6 @@ public class FlatTextAreaUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintBackground( Graphics g ) {
|
protected void paintBackground( Graphics g ) {
|
||||||
JTextComponent c = getComponent();
|
FlatEditorPaneUI.paintBackground( g, getComponent(), isIntelliJTheme, focusedBackground );
|
||||||
|
|
||||||
// for compatibility with IntelliJ themes
|
|
||||||
if( isIntelliJTheme && (!c.isEnabled() || !c.isEditable()) && (c.getBackground() instanceof UIResource) ) {
|
|
||||||
FlatUIUtils.paintParentBackground( g, c );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.paintBackground( g );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ import com.formdev.flatlaf.util.JavaCompatibility;
|
|||||||
* @uiDefault Component.minimumWidth int
|
* @uiDefault Component.minimumWidth int
|
||||||
* @uiDefault Component.isIntelliJTheme boolean
|
* @uiDefault Component.isIntelliJTheme boolean
|
||||||
* @uiDefault TextField.placeholderForeground Color
|
* @uiDefault TextField.placeholderForeground Color
|
||||||
|
* @uiDefault TextField.focusedBackground Color optional
|
||||||
* @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
|
* @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
|
||||||
* @uiDefault TextComponent.selectAllOnMouseClick boolean
|
* @uiDefault TextComponent.selectAllOnMouseClick boolean
|
||||||
*
|
*
|
||||||
@@ -75,6 +76,7 @@ public class FlatTextFieldUI
|
|||||||
protected int minimumWidth;
|
protected int minimumWidth;
|
||||||
protected boolean isIntelliJTheme;
|
protected boolean isIntelliJTheme;
|
||||||
protected Color placeholderForeground;
|
protected Color placeholderForeground;
|
||||||
|
protected Color focusedBackground;
|
||||||
|
|
||||||
private FocusListener focusListener;
|
private FocusListener focusListener;
|
||||||
|
|
||||||
@@ -90,6 +92,7 @@ public class FlatTextFieldUI
|
|||||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||||
placeholderForeground = UIManager.getColor( prefix + ".placeholderForeground" );
|
placeholderForeground = UIManager.getColor( prefix + ".placeholderForeground" );
|
||||||
|
focusedBackground = UIManager.getColor( prefix + ".focusedBackground" );
|
||||||
|
|
||||||
LookAndFeel.installProperty( getComponent(), "opaque", false );
|
LookAndFeel.installProperty( getComponent(), "opaque", false );
|
||||||
|
|
||||||
@@ -101,6 +104,7 @@ public class FlatTextFieldUI
|
|||||||
super.uninstallDefaults();
|
super.uninstallDefaults();
|
||||||
|
|
||||||
placeholderForeground = null;
|
placeholderForeground = null;
|
||||||
|
focusedBackground = null;
|
||||||
|
|
||||||
MigLayoutVisualPadding.uninstall( getComponent() );
|
MigLayoutVisualPadding.uninstall( getComponent() );
|
||||||
}
|
}
|
||||||
@@ -109,7 +113,8 @@ public class FlatTextFieldUI
|
|||||||
protected void installListeners() {
|
protected void installListeners() {
|
||||||
super.installListeners();
|
super.installListeners();
|
||||||
|
|
||||||
focusListener = new FlatUIUtils.RepaintFocusListener( getComponent() );
|
// necessary to update focus border and background
|
||||||
|
focusListener = new FlatUIUtils.RepaintFocusListener( getComponent(), null );
|
||||||
getComponent().addFocusListener( focusListener );
|
getComponent().addFocusListener( focusListener );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +153,7 @@ public class FlatTextFieldUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintSafely( Graphics g ) {
|
protected void paintSafely( Graphics g ) {
|
||||||
paintBackground( g, getComponent(), isIntelliJTheme );
|
paintBackground( g, getComponent(), isIntelliJTheme, focusedBackground );
|
||||||
paintPlaceholder( g, getComponent(), placeholderForeground );
|
paintPlaceholder( g, getComponent(), placeholderForeground );
|
||||||
|
|
||||||
super.paintSafely( HiDPIUtils.createGraphicsTextYCorrection( (Graphics2D) g ) );
|
super.paintSafely( HiDPIUtils.createGraphicsTextYCorrection( (Graphics2D) g ) );
|
||||||
@@ -159,7 +164,7 @@ public class FlatTextFieldUI
|
|||||||
// background is painted elsewhere
|
// background is painted elsewhere
|
||||||
}
|
}
|
||||||
|
|
||||||
static void paintBackground( Graphics g, JTextComponent c, boolean isIntelliJTheme ) {
|
static void paintBackground( Graphics g, JTextComponent c, boolean isIntelliJTheme, Color focusedBackground ) {
|
||||||
// do not paint background if:
|
// do not paint background if:
|
||||||
// - not opaque and
|
// - not opaque and
|
||||||
// - border is not a flat border and
|
// - border is not a flat border and
|
||||||
@@ -180,18 +185,31 @@ public class FlatTextFieldUI
|
|||||||
try {
|
try {
|
||||||
FlatUIUtils.setRenderingHints( g2 );
|
FlatUIUtils.setRenderingHints( g2 );
|
||||||
|
|
||||||
Color background = c.getBackground();
|
g2.setColor( getBackground( c, isIntelliJTheme, focusedBackground ) );
|
||||||
g2.setColor( !(background instanceof UIResource)
|
|
||||||
? background
|
|
||||||
: (isIntelliJTheme && (!c.isEnabled() || !c.isEditable())
|
|
||||||
? FlatUIUtils.getParentBackground( c )
|
|
||||||
: background) );
|
|
||||||
FlatUIUtils.paintComponentBackground( g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, arc );
|
FlatUIUtils.paintComponentBackground( g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, arc );
|
||||||
} finally {
|
} finally {
|
||||||
g2.dispose();
|
g2.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Color getBackground( JTextComponent c, boolean isIntelliJTheme, Color focusedBackground ) {
|
||||||
|
Color background = c.getBackground();
|
||||||
|
|
||||||
|
// always use explicitly set color
|
||||||
|
if( !(background instanceof UIResource) )
|
||||||
|
return background;
|
||||||
|
|
||||||
|
// focused
|
||||||
|
if( focusedBackground != null && FlatUIUtils.isPermanentFocusOwner( c ) )
|
||||||
|
return focusedBackground;
|
||||||
|
|
||||||
|
// for compatibility with IntelliJ themes
|
||||||
|
if( isIntelliJTheme && (!c.isEnabled() || !c.isEditable()) )
|
||||||
|
return FlatUIUtils.getParentBackground( c );
|
||||||
|
|
||||||
|
return background;
|
||||||
|
}
|
||||||
|
|
||||||
static void paintPlaceholder( Graphics g, JTextComponent c, Color placeholderForeground ) {
|
static void paintPlaceholder( Graphics g, JTextComponent c, Color placeholderForeground ) {
|
||||||
// check whether text component is empty
|
// check whether text component is empty
|
||||||
if( c.getDocument().getLength() > 0 )
|
if( c.getDocument().getLength() > 0 )
|
||||||
|
|||||||
@@ -16,17 +16,17 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JEditorPane;
|
import javax.swing.JEditorPane;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.UIResource;
|
|
||||||
import javax.swing.plaf.basic.BasicTextPaneUI;
|
import javax.swing.plaf.basic.BasicTextPaneUI;
|
||||||
import javax.swing.text.JTextComponent;
|
|
||||||
import com.formdev.flatlaf.util.HiDPIUtils;
|
import com.formdev.flatlaf.util.HiDPIUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +51,7 @@ import com.formdev.flatlaf.util.HiDPIUtils;
|
|||||||
*
|
*
|
||||||
* @uiDefault Component.minimumWidth int
|
* @uiDefault Component.minimumWidth int
|
||||||
* @uiDefault Component.isIntelliJTheme boolean
|
* @uiDefault Component.isIntelliJTheme boolean
|
||||||
|
* @uiDefault TextPane.focusedBackground Color optional
|
||||||
*
|
*
|
||||||
* @author Karl Tauber
|
* @author Karl Tauber
|
||||||
*/
|
*/
|
||||||
@@ -59,8 +60,10 @@ public class FlatTextPaneUI
|
|||||||
{
|
{
|
||||||
protected int minimumWidth;
|
protected int minimumWidth;
|
||||||
protected boolean isIntelliJTheme;
|
protected boolean isIntelliJTheme;
|
||||||
|
protected Color focusedBackground;
|
||||||
|
|
||||||
private Object oldHonorDisplayProperties;
|
private Object oldHonorDisplayProperties;
|
||||||
|
private FocusListener focusListener;
|
||||||
|
|
||||||
public static ComponentUI createUI( JComponent c ) {
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
return new FlatTextPaneUI();
|
return new FlatTextPaneUI();
|
||||||
@@ -70,8 +73,10 @@ public class FlatTextPaneUI
|
|||||||
protected void installDefaults() {
|
protected void installDefaults() {
|
||||||
super.installDefaults();
|
super.installDefaults();
|
||||||
|
|
||||||
|
String prefix = getPropertyPrefix();
|
||||||
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
minimumWidth = UIManager.getInt( "Component.minimumWidth" );
|
||||||
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
isIntelliJTheme = UIManager.getBoolean( "Component.isIntelliJTheme" );
|
||||||
|
focusedBackground = UIManager.getColor( prefix + ".focusedBackground" );
|
||||||
|
|
||||||
// use component font and foreground for HTML text
|
// use component font and foreground for HTML text
|
||||||
oldHonorDisplayProperties = getComponent().getClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES );
|
oldHonorDisplayProperties = getComponent().getClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES );
|
||||||
@@ -82,9 +87,28 @@ public class FlatTextPaneUI
|
|||||||
protected void uninstallDefaults() {
|
protected void uninstallDefaults() {
|
||||||
super.uninstallDefaults();
|
super.uninstallDefaults();
|
||||||
|
|
||||||
|
focusedBackground = null;
|
||||||
|
|
||||||
getComponent().putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, oldHonorDisplayProperties );
|
getComponent().putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, oldHonorDisplayProperties );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installListeners() {
|
||||||
|
super.installListeners();
|
||||||
|
|
||||||
|
// necessary to update focus background
|
||||||
|
focusListener = new FlatUIUtils.RepaintFocusListener( getComponent(), c -> focusedBackground != null );
|
||||||
|
getComponent().addFocusListener( focusListener );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void uninstallListeners() {
|
||||||
|
super.uninstallListeners();
|
||||||
|
|
||||||
|
getComponent().removeFocusListener( focusListener );
|
||||||
|
focusListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void propertyChange( PropertyChangeEvent e ) {
|
protected void propertyChange( PropertyChangeEvent e ) {
|
||||||
super.propertyChange( e );
|
super.propertyChange( e );
|
||||||
@@ -108,14 +132,6 @@ public class FlatTextPaneUI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintBackground( Graphics g ) {
|
protected void paintBackground( Graphics g ) {
|
||||||
JTextComponent c = getComponent();
|
FlatEditorPaneUI.paintBackground( g, getComponent(), isIntelliJTheme, focusedBackground );
|
||||||
|
|
||||||
// for compatibility with IntelliJ themes
|
|
||||||
if( isIntelliJTheme && (!c.isEnabled() || !c.isEditable()) && (c.getBackground() instanceof UIResource) ) {
|
|
||||||
FlatUIUtils.paintParentBackground( g, c );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
super.paintBackground( g );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -660,7 +660,7 @@ public class FlatUIUtils
|
|||||||
* @since 1.1
|
* @since 1.1
|
||||||
*/
|
*/
|
||||||
public static void paintArrow( Graphics2D g, int x, int y, int width, int height,
|
public static void paintArrow( Graphics2D g, int x, int y, int width, int height,
|
||||||
int direction, boolean chevron, int arrowSize, int xOffset, int yOffset )
|
int direction, boolean chevron, int arrowSize, float xOffset, float yOffset )
|
||||||
{
|
{
|
||||||
// compute arrow width/height
|
// compute arrow width/height
|
||||||
int aw = UIScale.scale( arrowSize + (chevron ? 0 : 1) );
|
int aw = UIScale.scale( arrowSize + (chevron ? 0 : 1) );
|
||||||
@@ -679,8 +679,10 @@ public class FlatUIUtils
|
|||||||
int extra = chevron ? 1 : 0;
|
int extra = chevron ? 1 : 0;
|
||||||
|
|
||||||
// compute arrow location
|
// compute arrow location
|
||||||
int ax = x + Math.round( ((width - (aw + extra)) / 2f) + UIScale.scale( (float) xOffset ) );
|
float ox = ((width - (aw + extra)) / 2f) + UIScale.scale( xOffset );
|
||||||
int ay = y + Math.round( ((height - (ah + extra)) / 2f) + UIScale.scale( (float) yOffset ) );
|
float oy = ((height - (ah + extra)) / 2f) + UIScale.scale( yOffset );
|
||||||
|
int ax = x + ((direction == SwingConstants.WEST) ? -Math.round( -ox ) : Math.round( ox ));
|
||||||
|
int ay = y + ((direction == SwingConstants.NORTH) ? -Math.round( -oy ) : Math.round( oy ));
|
||||||
|
|
||||||
// paint arrow
|
// paint arrow
|
||||||
g.translate( ax, ay );
|
g.translate( ax, ay );
|
||||||
@@ -837,19 +839,23 @@ debug*/
|
|||||||
implements FocusListener
|
implements FocusListener
|
||||||
{
|
{
|
||||||
private final Component repaintComponent;
|
private final Component repaintComponent;
|
||||||
|
private final Predicate<Component> repaintCondition;
|
||||||
|
|
||||||
public RepaintFocusListener( Component repaintComponent ) {
|
public RepaintFocusListener( Component repaintComponent, Predicate<Component> repaintCondition ) {
|
||||||
this.repaintComponent = repaintComponent;
|
this.repaintComponent = repaintComponent;
|
||||||
|
this.repaintCondition = repaintCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void focusGained( FocusEvent e ) {
|
public void focusGained( FocusEvent e ) {
|
||||||
repaintComponent.repaint();
|
if( repaintCondition == null || repaintCondition.test( repaintComponent ) )
|
||||||
|
repaintComponent.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void focusLost( FocusEvent e ) {
|
public void focusLost( FocusEvent e ) {
|
||||||
repaintComponent.repaint();
|
if( repaintCondition == null || repaintCondition.test( repaintComponent ) )
|
||||||
|
repaintComponent.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import java.awt.event.WindowListener;
|
|||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.beans.PropertyChangeSupport;
|
import java.beans.PropertyChangeSupport;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import javax.swing.AbstractButton;
|
import javax.swing.AbstractButton;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JLayeredPane;
|
import javax.swing.JLayeredPane;
|
||||||
@@ -64,6 +65,7 @@ import javax.swing.plaf.UIResource;
|
|||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
import com.formdev.flatlaf.FlatClientProperties;
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
import com.formdev.flatlaf.util.UIScale;
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -478,9 +480,17 @@ public class FlatInspector
|
|||||||
|
|
||||||
if( c instanceof JComponent ) {
|
if( c instanceof JComponent ) {
|
||||||
try {
|
try {
|
||||||
Field f = JComponent.class.getDeclaredField( "ui" );
|
Object ui;
|
||||||
f.setAccessible( true );
|
if( SystemInfo.isJava_9_orLater ) {
|
||||||
Object ui = f.get( c );
|
// Java 9+: use public method JComponent.getUI()
|
||||||
|
Method m = JComponent.class.getMethod( "getUI" );
|
||||||
|
ui = m.invoke( c );
|
||||||
|
} else {
|
||||||
|
// Java 8: read protected field 'ui'
|
||||||
|
Field f = JComponent.class.getDeclaredField( "ui" );
|
||||||
|
f.setAccessible( true );
|
||||||
|
ui = f.get( c );
|
||||||
|
}
|
||||||
appendRow( buf, "UI", (ui != null ? toString( ui.getClass(), classHierarchy ) : "null") );
|
appendRow( buf, "UI", (ui != null ? toString( ui.getClass(), classHierarchy ) : "null") );
|
||||||
} catch( Exception ex ) {
|
} catch( Exception ex ) {
|
||||||
// ignore
|
// ignore
|
||||||
@@ -553,6 +563,9 @@ public class FlatInspector
|
|||||||
String simpleName = (dot >= 0) ? name.substring( dot + 1 ) : name;
|
String simpleName = (dot >= 0) ? name.substring( dot + 1 ) : name;
|
||||||
buf.append( simpleName ).append( ' ' ).append( toDimmedText( "(" + pkg + ")" ) );
|
buf.append( simpleName ).append( ' ' ).append( toDimmedText( "(" + pkg + ")" ) );
|
||||||
|
|
||||||
|
if( UIResource.class.isAssignableFrom( cls ) )
|
||||||
|
buf.append( " UI" );
|
||||||
|
|
||||||
if( !classHierarchy )
|
if( !classHierarchy )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -613,11 +626,14 @@ public class FlatInspector
|
|||||||
|
|
||||||
String s = toString( b.getClass(), classHierarchy );
|
String s = toString( b.getClass(), classHierarchy );
|
||||||
|
|
||||||
if( b instanceof EmptyBorder )
|
if( b instanceof EmptyBorder ) {
|
||||||
s += '(' + toString( ((EmptyBorder)b).getBorderInsets() ) + ')';
|
String borderInsets = " (" + toString( ((EmptyBorder)b).getBorderInsets() ) + ')';
|
||||||
|
int brIndex = s.indexOf( "<br>" );
|
||||||
if( b instanceof UIResource )
|
if( brIndex >= 0 )
|
||||||
s += " UI";
|
s = s.substring( 0, brIndex ) + borderInsets + s.substring( brIndex );
|
||||||
|
else
|
||||||
|
s += borderInsets;
|
||||||
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ dependencies {
|
|||||||
implementation( project( ":flatlaf-core" ) )
|
implementation( project( ":flatlaf-core" ) )
|
||||||
|
|
||||||
// use compileOnly() because there are various JIDE libraries available on Maven Central
|
// use compileOnly() because there are various JIDE libraries available on Maven Central
|
||||||
compileOnly( "com.formdev:jide-oss:3.7.11.1" )
|
compileOnly( "com.formdev:jide-oss:3.7.12" )
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ public class FlatDatePickerUI
|
|||||||
editor.setName( "dateField" );
|
editor.setName( "dateField" );
|
||||||
editor.setBorder( BorderFactory.createEmptyBorder() );
|
editor.setBorder( BorderFactory.createEmptyBorder() );
|
||||||
editor.setOpaque( false );
|
editor.setOpaque( false );
|
||||||
editor.addFocusListener( new FlatUIUtils.RepaintFocusListener( datePicker ) );
|
editor.addFocusListener( new FlatUIUtils.RepaintFocusListener( datePicker, null ) );
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ dependencies {
|
|||||||
implementation( "com.jgoodies:jgoodies-forms:1.9.0" )
|
implementation( "com.jgoodies:jgoodies-forms:1.9.0" )
|
||||||
implementation( "org.swinglabs.swingx:swingx-all:1.6.5-1" )
|
implementation( "org.swinglabs.swingx:swingx-all:1.6.5-1" )
|
||||||
implementation( "org.swinglabs.swingx:swingx-beaninfo:1.6.5-1" )
|
implementation( "org.swinglabs.swingx:swingx-beaninfo:1.6.5-1" )
|
||||||
implementation( "com.formdev:jide-oss:3.7.11.1" )
|
implementation( "com.formdev:jide-oss:3.7.12" )
|
||||||
implementation( "com.glazedlists:glazedlists:1.11.0" )
|
implementation( "com.glazedlists:glazedlists:1.11.0" )
|
||||||
implementation( "org.netbeans.api:org-openide-awt:RELEASE112" )
|
implementation( "org.netbeans.api:org-openide-awt:RELEASE112" )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public class FlatAnimatedIconTest
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue ) {
|
public void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue ) {
|
||||||
Color color = ColorFunctions.mix( onColor, offColor, animatedValue );;
|
Color color = ColorFunctions.mix( onColor, offColor, animatedValue );
|
||||||
|
|
||||||
// border
|
// border
|
||||||
g.setColor( color );
|
g.setColor( color );
|
||||||
@@ -190,7 +190,7 @@ public class FlatAnimatedIconTest
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue ) {
|
public void paintIconAnimated( Component c, Graphics g, int x, int y, float animatedValue ) {
|
||||||
Color color = ColorFunctions.mix( onColor, offColor, animatedValue );;
|
Color color = ColorFunctions.mix( onColor, offColor, animatedValue );
|
||||||
|
|
||||||
g.setColor( color );
|
g.setColor( color );
|
||||||
g.fillRoundRect( x, y, width, height, height, height );
|
g.fillRoundRect( x, y, width, height, height, height );
|
||||||
|
|||||||
@@ -73,6 +73,25 @@ public class FlatPaintingTest
|
|||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void offsetChanged() {
|
||||||
|
float offset = (float) offsetSpinner.getValue();
|
||||||
|
System.out.println( offset );
|
||||||
|
|
||||||
|
arrowPainter5.setYOffset( offset );
|
||||||
|
arrowPainter6.setYOffset( -offset );
|
||||||
|
|
||||||
|
arrowPainter7.setXOffset( offset );
|
||||||
|
arrowPainter8.setXOffset( -offset );
|
||||||
|
|
||||||
|
arrowPainter13.setYOffset( offset );
|
||||||
|
arrowPainter14.setYOffset( -offset );
|
||||||
|
|
||||||
|
arrowPainter15.setXOffset( offset );
|
||||||
|
arrowPainter16.setXOffset( -offset );
|
||||||
|
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
private void vectorChanged() {
|
private void vectorChanged() {
|
||||||
boolean vector = vectorCheckBox.isSelected();
|
boolean vector = vectorCheckBox.isSelected();
|
||||||
|
|
||||||
@@ -84,7 +103,7 @@ public class FlatPaintingTest
|
|||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBox1ActionPerformed() {
|
private void arrowButtonChanged() {
|
||||||
boolean button = buttonCheckBox.isSelected();
|
boolean button = buttonCheckBox.isSelected();
|
||||||
|
|
||||||
FlatTestFrame.updateComponentsRecur( (Container) getViewport().getView(), (c, type) -> {
|
FlatTestFrame.updateComponentsRecur( (Container) getViewport().getView(), (c, type) -> {
|
||||||
@@ -143,11 +162,11 @@ public class FlatPaintingTest
|
|||||||
FlatPaintingTest.ArrowPainter arrowPainter3 = new FlatPaintingTest.ArrowPainter();
|
FlatPaintingTest.ArrowPainter arrowPainter3 = new FlatPaintingTest.ArrowPainter();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter4 = new FlatPaintingTest.ArrowPainter();
|
FlatPaintingTest.ArrowPainter arrowPainter4 = new FlatPaintingTest.ArrowPainter();
|
||||||
JPanel panel1 = new JPanel();
|
JPanel panel1 = new JPanel();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter5 = new FlatPaintingTest.ArrowPainter();
|
arrowPainter5 = new FlatPaintingTest.ArrowPainter();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter6 = new FlatPaintingTest.ArrowPainter();
|
arrowPainter6 = new FlatPaintingTest.ArrowPainter();
|
||||||
JPanel panel2 = new JPanel();
|
JPanel panel2 = new JPanel();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter7 = new FlatPaintingTest.ArrowPainter();
|
arrowPainter7 = new FlatPaintingTest.ArrowPainter();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter8 = new FlatPaintingTest.ArrowPainter();
|
arrowPainter8 = new FlatPaintingTest.ArrowPainter();
|
||||||
JPanel panel5 = new JPanel();
|
JPanel panel5 = new JPanel();
|
||||||
JLabel arrowWidthLabel = new JLabel();
|
JLabel arrowWidthLabel = new JLabel();
|
||||||
arrowWidthSpinner = new JSpinner();
|
arrowWidthSpinner = new JSpinner();
|
||||||
@@ -155,6 +174,8 @@ public class FlatPaintingTest
|
|||||||
arrowHeightSpinner = new JSpinner();
|
arrowHeightSpinner = new JSpinner();
|
||||||
JLabel arrowSizeLabel = new JLabel();
|
JLabel arrowSizeLabel = new JLabel();
|
||||||
arrowSizeSpinner = new JSpinner();
|
arrowSizeSpinner = new JSpinner();
|
||||||
|
JLabel offsetLabel = new JLabel();
|
||||||
|
offsetSpinner = new JSpinner();
|
||||||
vectorCheckBox = new JCheckBox();
|
vectorCheckBox = new JCheckBox();
|
||||||
buttonCheckBox = new JCheckBox();
|
buttonCheckBox = new JCheckBox();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter9 = new FlatPaintingTest.ArrowPainter();
|
FlatPaintingTest.ArrowPainter arrowPainter9 = new FlatPaintingTest.ArrowPainter();
|
||||||
@@ -162,11 +183,11 @@ public class FlatPaintingTest
|
|||||||
FlatPaintingTest.ArrowPainter arrowPainter11 = new FlatPaintingTest.ArrowPainter();
|
FlatPaintingTest.ArrowPainter arrowPainter11 = new FlatPaintingTest.ArrowPainter();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter12 = new FlatPaintingTest.ArrowPainter();
|
FlatPaintingTest.ArrowPainter arrowPainter12 = new FlatPaintingTest.ArrowPainter();
|
||||||
JPanel panel3 = new JPanel();
|
JPanel panel3 = new JPanel();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter13 = new FlatPaintingTest.ArrowPainter();
|
arrowPainter13 = new FlatPaintingTest.ArrowPainter();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter14 = new FlatPaintingTest.ArrowPainter();
|
arrowPainter14 = new FlatPaintingTest.ArrowPainter();
|
||||||
JPanel panel4 = new JPanel();
|
JPanel panel4 = new JPanel();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter15 = new FlatPaintingTest.ArrowPainter();
|
arrowPainter15 = new FlatPaintingTest.ArrowPainter();
|
||||||
FlatPaintingTest.ArrowPainter arrowPainter16 = new FlatPaintingTest.ArrowPainter();
|
arrowPainter16 = new FlatPaintingTest.ArrowPainter();
|
||||||
|
|
||||||
//======== this ========
|
//======== this ========
|
||||||
setBorder(null);
|
setBorder(null);
|
||||||
@@ -519,6 +540,7 @@ public class FlatPaintingTest
|
|||||||
"[]" +
|
"[]" +
|
||||||
"[]" +
|
"[]" +
|
||||||
"[]" +
|
"[]" +
|
||||||
|
"[]" +
|
||||||
"[]"));
|
"[]"));
|
||||||
|
|
||||||
//---- arrowWidthLabel ----
|
//---- arrowWidthLabel ----
|
||||||
@@ -548,17 +570,26 @@ public class FlatPaintingTest
|
|||||||
arrowSizeSpinner.addChangeListener(e -> arrowSizeChanged());
|
arrowSizeSpinner.addChangeListener(e -> arrowSizeChanged());
|
||||||
panel5.add(arrowSizeSpinner, "cell 1 2");
|
panel5.add(arrowSizeSpinner, "cell 1 2");
|
||||||
|
|
||||||
|
//---- offsetLabel ----
|
||||||
|
offsetLabel.setText("Offset:");
|
||||||
|
panel5.add(offsetLabel, "cell 0 3");
|
||||||
|
|
||||||
|
//---- offsetSpinner ----
|
||||||
|
offsetSpinner.setModel(new SpinnerNumberModel(1.0F, null, null, 0.05F));
|
||||||
|
offsetSpinner.addChangeListener(e -> offsetChanged());
|
||||||
|
panel5.add(offsetSpinner, "cell 1 3");
|
||||||
|
|
||||||
//---- vectorCheckBox ----
|
//---- vectorCheckBox ----
|
||||||
vectorCheckBox.setText("vector");
|
vectorCheckBox.setText("vector");
|
||||||
vectorCheckBox.addActionListener(e -> vectorChanged());
|
vectorCheckBox.addActionListener(e -> vectorChanged());
|
||||||
panel5.add(vectorCheckBox, "cell 0 3 2 1,alignx left,growx 0");
|
panel5.add(vectorCheckBox, "cell 0 4 2 1,alignx left,growx 0");
|
||||||
|
|
||||||
//---- buttonCheckBox ----
|
//---- buttonCheckBox ----
|
||||||
buttonCheckBox.setText("FlatArrowButton");
|
buttonCheckBox.setText("FlatArrowButton");
|
||||||
buttonCheckBox.addActionListener(e -> checkBox1ActionPerformed());
|
buttonCheckBox.addActionListener(e -> arrowButtonChanged());
|
||||||
panel5.add(buttonCheckBox, "cell 0 4 2 1,alignx left,growx 0");
|
panel5.add(buttonCheckBox, "cell 0 5 2 1,alignx left,growx 0");
|
||||||
}
|
}
|
||||||
flatTestPanel1.add(panel5, "cell 6 5,aligny top,growy 0");
|
flatTestPanel1.add(panel5, "cell 6 5 1 2,aligny top,growy 0");
|
||||||
|
|
||||||
//---- arrowPainter9 ----
|
//---- arrowPainter9 ----
|
||||||
arrowPainter9.setScale(8.0F);
|
arrowPainter9.setScale(8.0F);
|
||||||
@@ -635,11 +666,20 @@ public class FlatPaintingTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||||
|
private FlatPaintingTest.ArrowPainter arrowPainter5;
|
||||||
|
private FlatPaintingTest.ArrowPainter arrowPainter6;
|
||||||
|
private FlatPaintingTest.ArrowPainter arrowPainter7;
|
||||||
|
private FlatPaintingTest.ArrowPainter arrowPainter8;
|
||||||
private JSpinner arrowWidthSpinner;
|
private JSpinner arrowWidthSpinner;
|
||||||
private JSpinner arrowHeightSpinner;
|
private JSpinner arrowHeightSpinner;
|
||||||
private JSpinner arrowSizeSpinner;
|
private JSpinner arrowSizeSpinner;
|
||||||
|
private JSpinner offsetSpinner;
|
||||||
private JCheckBox vectorCheckBox;
|
private JCheckBox vectorCheckBox;
|
||||||
private JCheckBox buttonCheckBox;
|
private JCheckBox buttonCheckBox;
|
||||||
|
private FlatPaintingTest.ArrowPainter arrowPainter13;
|
||||||
|
private FlatPaintingTest.ArrowPainter arrowPainter14;
|
||||||
|
private FlatPaintingTest.ArrowPainter arrowPainter15;
|
||||||
|
private FlatPaintingTest.ArrowPainter arrowPainter16;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
|
|
||||||
//---- class BorderPainter ------------------------------------------------
|
//---- class BorderPainter ------------------------------------------------
|
||||||
@@ -792,8 +832,8 @@ public class FlatPaintingTest
|
|||||||
private int direction = SwingConstants.SOUTH;
|
private int direction = SwingConstants.SOUTH;
|
||||||
private boolean chevron = true;
|
private boolean chevron = true;
|
||||||
private int arrowSize = FlatArrowButton.DEFAULT_ARROW_WIDTH;
|
private int arrowSize = FlatArrowButton.DEFAULT_ARROW_WIDTH;
|
||||||
private int xOffset = 0;
|
private float xOffset = 0;
|
||||||
private int yOffset = 0;
|
private float yOffset = 0;
|
||||||
private float scale = 1;
|
private float scale = 1;
|
||||||
private boolean halfWidth;
|
private boolean halfWidth;
|
||||||
private boolean halfHeight;
|
private boolean halfHeight;
|
||||||
@@ -845,19 +885,19 @@ public class FlatPaintingTest
|
|||||||
this.arrowSize = arrowSize;
|
this.arrowSize = arrowSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getXOffset() {
|
public float getXOffset() {
|
||||||
return xOffset;
|
return xOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setXOffset( int xOffset ) {
|
public void setXOffset( float xOffset ) {
|
||||||
this.xOffset = xOffset;
|
this.xOffset = xOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getYOffset() {
|
public float getYOffset() {
|
||||||
return yOffset;
|
return yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setYOffset( int yOffset ) {
|
public void setYOffset( float yOffset ) {
|
||||||
this.yOffset = yOffset;
|
this.yOffset = yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
JFDML JFormDesigner: "7.0.3.1.342" Java: "15" encoding: "UTF-8"
|
JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8"
|
||||||
|
|
||||||
new FormModel {
|
new FormModel {
|
||||||
contentType: "form/swing"
|
contentType: "form/swing"
|
||||||
@@ -383,6 +383,9 @@ new FormModel {
|
|||||||
"h": 10
|
"h": 10
|
||||||
"halfHeight": true
|
"halfHeight": true
|
||||||
"YOffset": 1
|
"YOffset": 1
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||||
name: "arrowPainter6"
|
name: "arrowPainter6"
|
||||||
@@ -390,6 +393,9 @@ new FormModel {
|
|||||||
"h": 10
|
"h": 10
|
||||||
"halfHeight": true
|
"halfHeight": true
|
||||||
"YOffset": -1
|
"YOffset": -1
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 5,align left top,grow 0 0"
|
"value": "cell 4 5,align left top,grow 0 0"
|
||||||
@@ -403,6 +409,9 @@ new FormModel {
|
|||||||
"w": 10
|
"w": 10
|
||||||
"halfWidth": true
|
"halfWidth": true
|
||||||
"XOffset": 1
|
"XOffset": 1
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||||
name: "arrowPainter8"
|
name: "arrowPainter8"
|
||||||
@@ -411,6 +420,9 @@ new FormModel {
|
|||||||
"w": 10
|
"w": 10
|
||||||
"halfWidth": true
|
"halfWidth": true
|
||||||
"XOffset": -1
|
"XOffset": -1
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 5,align left top,grow 0 0"
|
"value": "cell 5 5,align left top,grow 0 0"
|
||||||
@@ -418,7 +430,7 @@ new FormModel {
|
|||||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||||
"$layoutConstraints": "hidemode 3"
|
"$layoutConstraints": "hidemode 3"
|
||||||
"$columnConstraints": "[fill][fill]"
|
"$columnConstraints": "[fill][fill]"
|
||||||
"$rowConstraints": "[][][][][]"
|
"$rowConstraints": "[][][][][][]"
|
||||||
} ) {
|
} ) {
|
||||||
name: "panel5"
|
name: "panel5"
|
||||||
"border": new javax.swing.border.TitledBorder( "Arrow Control" )
|
"border": new javax.swing.border.TitledBorder( "Arrow Control" )
|
||||||
@@ -479,6 +491,25 @@ new FormModel {
|
|||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 1 2"
|
"value": "cell 1 2"
|
||||||
} )
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||||
|
name: "offsetLabel"
|
||||||
|
"text": "Offset:"
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 0 3"
|
||||||
|
} )
|
||||||
|
add( new FormComponent( "javax.swing.JSpinner" ) {
|
||||||
|
name: "offsetSpinner"
|
||||||
|
"model": new javax.swing.SpinnerNumberModel {
|
||||||
|
stepSize: 0.05f
|
||||||
|
value: 1.0f
|
||||||
|
}
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
|
addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "offsetChanged", false ) )
|
||||||
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
|
"value": "cell 1 3"
|
||||||
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "vectorCheckBox"
|
name: "vectorCheckBox"
|
||||||
"text": "vector"
|
"text": "vector"
|
||||||
@@ -487,7 +518,7 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "vectorChanged", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "vectorChanged", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 3 2 1,alignx left,growx 0"
|
"value": "cell 0 4 2 1,alignx left,growx 0"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||||
name: "buttonCheckBox"
|
name: "buttonCheckBox"
|
||||||
@@ -495,12 +526,12 @@ new FormModel {
|
|||||||
auxiliary() {
|
auxiliary() {
|
||||||
"JavaCodeGenerator.variableLocal": false
|
"JavaCodeGenerator.variableLocal": false
|
||||||
}
|
}
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "checkBox1ActionPerformed", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "arrowButtonChanged", false ) )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 0 4 2 1,alignx left,growx 0"
|
"value": "cell 0 5 2 1,alignx left,growx 0"
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 6 5,aligny top,growy 0"
|
"value": "cell 6 5 1 2,aligny top,growy 0"
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||||
name: "arrowPainter9"
|
name: "arrowPainter9"
|
||||||
@@ -545,6 +576,9 @@ new FormModel {
|
|||||||
"chevron": false
|
"chevron": false
|
||||||
"halfHeight": true
|
"halfHeight": true
|
||||||
"YOffset": 1
|
"YOffset": 1
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||||
name: "arrowPainter14"
|
name: "arrowPainter14"
|
||||||
@@ -553,6 +587,9 @@ new FormModel {
|
|||||||
"chevron": false
|
"chevron": false
|
||||||
"halfHeight": true
|
"halfHeight": true
|
||||||
"YOffset": -1
|
"YOffset": -1
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 4 6,align left top,grow 0 0"
|
"value": "cell 4 6,align left top,grow 0 0"
|
||||||
@@ -567,6 +604,9 @@ new FormModel {
|
|||||||
"chevron": false
|
"chevron": false
|
||||||
"halfWidth": true
|
"halfWidth": true
|
||||||
"XOffset": 1
|
"XOffset": 1
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
add( new FormComponent( "com.formdev.flatlaf.testing.FlatPaintingTest$ArrowPainter" ) {
|
||||||
name: "arrowPainter16"
|
name: "arrowPainter16"
|
||||||
@@ -576,6 +616,9 @@ new FormModel {
|
|||||||
"chevron": false
|
"chevron": false
|
||||||
"halfWidth": true
|
"halfWidth": true
|
||||||
"XOffset": -1
|
"XOffset": -1
|
||||||
|
auxiliary() {
|
||||||
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
}
|
||||||
} )
|
} )
|
||||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||||
"value": "cell 5 6,align left top,grow 0 0"
|
"value": "cell 5 6,align left top,grow 0 0"
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.awt.event.KeyEvent;
|
|||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -284,6 +285,8 @@ public class FlatTestFrame
|
|||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
try( InputStream in = new FileInputStream( "lafs.properties" ) ) {
|
try( InputStream in = new FileInputStream( "lafs.properties" ) ) {
|
||||||
properties.load( in );
|
properties.load( in );
|
||||||
|
} catch( FileNotFoundException ex ) {
|
||||||
|
// ignore
|
||||||
} catch( IOException ex ) {
|
} catch( IOException ex ) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,10 @@ ComboBox.background = #fff
|
|||||||
ComboBox.buttonBackground = #f0f0f0
|
ComboBox.buttonBackground = #f0f0f0
|
||||||
ComboBox.buttonEditableBackground = #ccc
|
ComboBox.buttonEditableBackground = #ccc
|
||||||
|
|
||||||
|
ComboBox.focusedBackground = #ff8
|
||||||
|
ComboBox.buttonFocusedBackground = #ff0
|
||||||
|
ComboBox.popupBackground = #ffc
|
||||||
|
|
||||||
|
|
||||||
#---- Component ----
|
#---- Component ----
|
||||||
|
|
||||||
@@ -152,6 +156,16 @@ Desktop.background = #afe
|
|||||||
DesktopIcon.background = darken($Desktop.background,20%)
|
DesktopIcon.background = darken($Desktop.background,20%)
|
||||||
|
|
||||||
|
|
||||||
|
#---- EditorPane ----
|
||||||
|
|
||||||
|
EditorPane.focusedBackground = #ff8
|
||||||
|
|
||||||
|
|
||||||
|
#---- FormattedTextField ----
|
||||||
|
|
||||||
|
FormattedTextField.focusedBackground = #ff8
|
||||||
|
|
||||||
|
|
||||||
#---- HelpButton ----
|
#---- HelpButton ----
|
||||||
|
|
||||||
HelpButton.focusedBackground = #0ff
|
HelpButton.focusedBackground = #0ff
|
||||||
@@ -223,6 +237,11 @@ OptionPane.icon.warningColor = #fc0
|
|||||||
OptionPane.icon.foreground = #fff
|
OptionPane.icon.foreground = #fff
|
||||||
|
|
||||||
|
|
||||||
|
#---- PasswordField ----
|
||||||
|
|
||||||
|
PasswordField.focusedBackground = #ff8
|
||||||
|
|
||||||
|
|
||||||
#---- Popup ----
|
#---- Popup ----
|
||||||
|
|
||||||
Popup.dropShadowColor = #0f0
|
Popup.dropShadowColor = #0f0
|
||||||
@@ -280,6 +299,11 @@ Slider.disabledTrackColor = #ff8
|
|||||||
Slider.disabledThumbColor = #880
|
Slider.disabledThumbColor = #880
|
||||||
|
|
||||||
|
|
||||||
|
#---- Spinner ----
|
||||||
|
|
||||||
|
Spinner.focusedBackground = #ff8
|
||||||
|
|
||||||
|
|
||||||
#---- SplitPane ----
|
#---- SplitPane ----
|
||||||
|
|
||||||
SplitPaneDivider.draggingColor = #800
|
SplitPaneDivider.draggingColor = #800
|
||||||
@@ -332,6 +356,21 @@ TableHeader.separatorColor = #0f0
|
|||||||
TableHeader.bottomSeparatorColor = #0f0
|
TableHeader.bottomSeparatorColor = #0f0
|
||||||
|
|
||||||
|
|
||||||
|
#---- TextArea ----
|
||||||
|
|
||||||
|
TextArea.focusedBackground = #ff8
|
||||||
|
|
||||||
|
|
||||||
|
#---- TextField ----
|
||||||
|
|
||||||
|
TextField.focusedBackground = #ff8
|
||||||
|
|
||||||
|
|
||||||
|
#---- TextPane ----
|
||||||
|
|
||||||
|
TextPane.focusedBackground = #ff8
|
||||||
|
|
||||||
|
|
||||||
#---- TitledBorder ----
|
#---- TitledBorder ----
|
||||||
|
|
||||||
TitledBorder.titleColor = #f0f
|
TitledBorder.titleColor = #f0f
|
||||||
|
|||||||
Reference in New Issue
Block a user