diff --git a/CHANGELOG.md b/CHANGELOG.md index dd42c9df..b48ca658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ FlatLaf Change Log ================== +## Unreleased + +- TextField, FormattedTextField and PasswordField: Select all text when a text + field gains focus for the first time and selection was not set explicitly. + This can be configured to newer or always select all text on focus gain (see + UI default value `TextComponent.selectAllOnFocusPolicy`). + + ## 0.25.1 Re-release of 0.25 because of problems with Maven Central. diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java index 98ca89c2..33065d19 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/FlatClientProperties.java @@ -141,10 +141,44 @@ public interface FlatClientProperties */ String TABBED_PANE_TAB_HEIGHT = "JTabbedPane.tabHeight"; + /** + * Specifies whether all text is selected when the text component gains focus. + *
+ * Component {@link javax.swing.JTextField} (and subclasses)
+ * Value type {@link java.lang.String}
+ * Allowed Values {@link #SELECT_ALL_ON_FOCUS_POLICY_NEVER},
+ * {@link #SELECT_ALL_ON_FOCUS_POLICY_ONCE} (default) or
+ * {@link #SELECT_ALL_ON_FOCUS_POLICY_ALWAYS}
+ */
+ String SELECT_ALL_ON_FOCUS_POLICY = "JTextField.selectAllOnFocusPolicy";
+
+ /**
+ * Never select all text when the text component gains focus.
+ *
+ * @see #SELECT_ALL_ON_FOCUS_POLICY
+ */
+ String SELECT_ALL_ON_FOCUS_POLICY_NEVER = "never";
+
+ /**
+ * Select all text when the text component gains focus for the first time
+ * and selection was not modified (is at end of text).
+ * This is the default.
+ *
+ * @see #SELECT_ALL_ON_FOCUS_POLICY
+ */
+ String SELECT_ALL_ON_FOCUS_POLICY_ONCE = "once";
+
+ /**
+ * Always select all text when the text component gains focus.
+ *
+ * @see #SELECT_ALL_ON_FOCUS_POLICY
+ */
+ String SELECT_ALL_ON_FOCUS_POLICY_ALWAYS = "always";
+
/**
* Placeholder text that is only painted if the text field is empty.
*
- * Component {@link javax.swing.JTextField} or {@link javax.swing.JComboBox}
+ * Component {@link javax.swing.JTextField} (and subclasses) or {@link javax.swing.JComboBox}
* Value type {@link java.lang.String}
*/
String PLACEHOLDER_TEXT = "JTextField.placeholderText";
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCaret.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCaret.java
new file mode 100644
index 00000000..5704135c
--- /dev/null
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatCaret.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2020 FormDev Software GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.formdev.flatlaf.ui;
+
+import static com.formdev.flatlaf.FlatClientProperties.*;
+import java.awt.EventQueue;
+import java.awt.event.FocusEvent;
+import java.awt.event.MouseEvent;
+import javax.swing.JFormattedTextField;
+import javax.swing.plaf.UIResource;
+import javax.swing.text.DefaultCaret;
+import javax.swing.text.Document;
+import javax.swing.text.JTextComponent;
+
+/**
+ * Caret that can select all text on focus gained.
+ *
+ * @author Karl Tauber
+ */
+class FlatCaret
+ extends DefaultCaret
+ implements UIResource
+{
+ private final String selectAllOnFocusPolicy;
+
+ private boolean wasFocused;
+ private boolean wasTemporaryLost;
+ private boolean isMousePressed;
+
+ FlatCaret( String selectAllOnFocusPolicy ) {
+ this.selectAllOnFocusPolicy = selectAllOnFocusPolicy;
+ }
+
+ @Override
+ public void install( JTextComponent c ) {
+ super.install( c );
+
+ // the dot and mark are lost when switching LaF
+ // --> move dot to end of text so that all text may be selected when it gains focus
+ Document doc = c.getDocument();
+ if( doc != null && getDot() == 0 && getMark() == 0 ) {
+ int length = doc.getLength();
+ if( length > 0 )
+ setDot( length );
+ }
+ }
+
+ @Override
+ public void focusGained( FocusEvent e ) {
+ if( !wasTemporaryLost && !isMousePressed )
+ selectAllOnFocusGained();
+ wasTemporaryLost = false;
+ wasFocused = true;
+
+ super.focusGained( e );
+ }
+
+ @Override
+ public void focusLost( FocusEvent e ) {
+ wasTemporaryLost = e.isTemporary();
+ super.focusLost( e );
+ }
+
+ @Override
+ public void mousePressed( MouseEvent e ) {
+ isMousePressed = true;
+ super.mousePressed( e );
+ }
+
+ @Override
+ public void mouseReleased( MouseEvent e ) {
+ isMousePressed = false;
+ super.mouseReleased( e );
+ }
+
+ private void selectAllOnFocusGained() {
+ JTextComponent c = getComponent();
+ Document doc = c.getDocument();
+ if( doc == null || !c.isEnabled() || !c.isEditable() )
+ return;
+
+ Object selectAllOnFocusPolicy = c.getClientProperty( SELECT_ALL_ON_FOCUS_POLICY );
+ if( selectAllOnFocusPolicy == null )
+ selectAllOnFocusPolicy = this.selectAllOnFocusPolicy;
+
+ if( SELECT_ALL_ON_FOCUS_POLICY_NEVER.equals( selectAllOnFocusPolicy ) )
+ return;
+
+ if( !SELECT_ALL_ON_FOCUS_POLICY_ALWAYS.equals( selectAllOnFocusPolicy ) ) {
+ // policy is "once" (or null or unknown)
+
+ // was already focused?
+ if( wasFocused )
+ return;
+
+ // check whether selection was modified before gaining focus
+ int dot = getDot();
+ int mark = getMark();
+ if( dot != mark || dot != doc.getLength() )
+ return;
+ }
+
+ // select all
+ if( c instanceof JFormattedTextField ) {
+ EventQueue.invokeLater( () -> {
+ setDot( 0 );
+ moveDot( doc.getLength() );
+ } );
+ } else {
+ setDot( 0 );
+ moveDot( doc.getLength() );
+ }
+ }
+}
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFormattedTextFieldUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFormattedTextFieldUI.java
index 3bbcbbc6..8322ba64 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFormattedTextFieldUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatFormattedTextFieldUI.java
@@ -43,6 +43,7 @@ import javax.swing.plaf.ComponentUI;
* @uiDefault Component.minimumWidth int
* @uiDefault Component.isIntelliJTheme boolean
* @uiDefault FormattedTextField.placeholderForeground Color
+ * @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
*
* @author Karl Tauber
*/
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPasswordFieldUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPasswordFieldUI.java
index 40fe9586..d915aec1 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPasswordFieldUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatPasswordFieldUI.java
@@ -27,6 +27,7 @@ import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicPasswordFieldUI;
+import javax.swing.text.Caret;
import com.formdev.flatlaf.FlatClientProperties;
import com.formdev.flatlaf.util.SystemInfo;
@@ -55,6 +56,7 @@ import com.formdev.flatlaf.util.SystemInfo;
* @uiDefault Component.minimumWidth int
* @uiDefault Component.isIntelliJTheme boolean
* @uiDefault PasswordField.placeholderForeground Color
+ * @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
*
* @author Karl Tauber
*/
@@ -116,6 +118,11 @@ public class FlatPasswordFieldUI
focusListener = null;
}
+ @Override
+ protected Caret createCaret() {
+ return new FlatCaret( UIManager.getString( "TextComponent.selectAllOnFocusPolicy" ) );
+ }
+
@Override
protected void propertyChange( PropertyChangeEvent e ) {
super.propertyChange( e );
diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java
index 47f97005..35deedbb 100644
--- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java
+++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTextFieldUI.java
@@ -35,6 +35,7 @@ import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.plaf.basic.BasicTextFieldUI;
+import javax.swing.text.Caret;
import javax.swing.text.JTextComponent;
import com.formdev.flatlaf.FlatClientProperties;
@@ -62,6 +63,7 @@ import com.formdev.flatlaf.FlatClientProperties;
* @uiDefault Component.minimumWidth int
* @uiDefault Component.isIntelliJTheme boolean
* @uiDefault TextField.placeholderForeground Color
+ * @uiDefault TextComponent.selectAllOnFocusPolicy String never, once (default) or always
*
* @author Karl Tauber
*/
@@ -119,6 +121,11 @@ public class FlatTextFieldUI
focusListener = null;
}
+ @Override
+ protected Caret createCaret() {
+ return new FlatCaret( UIManager.getString( "TextComponent.selectAllOnFocusPolicy" ) );
+ }
+
@Override
protected void propertyChange( PropertyChangeEvent e ) {
super.propertyChange( e );
diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties
index e7505ba1..e1ea0c5b 100644
--- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties
+++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties
@@ -407,6 +407,12 @@ TextArea.margin=@textComponentMargin
TextArea.background=@textComponentBackground
+#---- TextComponent ----
+
+# allowed values: "never", "once" (default) or "always"
+TextComponent.selectAllOnFocusPolicy=once
+
+
#---- TextField ----
TextField.border=com.formdev.flatlaf.ui.FlatBorder
diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java
index b7ca8714..2e73567c 100644
--- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java
+++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java
@@ -17,6 +17,7 @@
package com.formdev.flatlaf.demo;
import javax.swing.*;
+import javax.swing.text.DefaultEditorKit;
import net.miginfocom.swing.*;
/**
@@ -113,6 +114,10 @@ class BasicComponentsPanel
JScrollPane scrollPane12 = new JScrollPane();
JTextPane textPane4 = new JTextPane();
JTextPane textPane5 = new JTextPane();
+ JPopupMenu popupMenu1 = new JPopupMenu();
+ JMenuItem cutMenuItem = new JMenuItem();
+ JMenuItem copyMenuItem = new JMenuItem();
+ JMenuItem pasteMenuItem = new JMenuItem();
//======== this ========
setLayout(new MigLayout(
@@ -260,6 +265,8 @@ class BasicComponentsPanel
//---- comboBoxLabel ----
comboBoxLabel.setText("JComboBox:");
+ comboBoxLabel.setDisplayedMnemonic('C');
+ comboBoxLabel.setLabelFor(comboBox1);
add(comboBoxLabel, "cell 0 4");
//---- comboBox1 ----
@@ -314,6 +321,8 @@ class BasicComponentsPanel
//---- spinnerLabel ----
spinnerLabel.setText("JSpinner:");
+ spinnerLabel.setLabelFor(spinner1);
+ spinnerLabel.setDisplayedMnemonic('S');
add(spinnerLabel, "cell 0 5");
add(spinner1, "cell 1 5,growx");
@@ -328,10 +337,13 @@ class BasicComponentsPanel
//---- textFieldLabel ----
textFieldLabel.setText("JTextField:");
+ textFieldLabel.setDisplayedMnemonic('T');
+ textFieldLabel.setLabelFor(textField1);
add(textFieldLabel, "cell 0 6");
//---- textField1 ----
textField1.setText("editable");
+ textField1.setComponentPopupMenu(popupMenu1);
add(textField1, "cell 1 6,growx");
//---- textField2 ----
@@ -356,10 +368,13 @@ class BasicComponentsPanel
//---- formattedTextFieldLabel ----
formattedTextFieldLabel.setText("JFormattedTextField:");
+ formattedTextFieldLabel.setLabelFor(formattedTextField1);
+ formattedTextFieldLabel.setDisplayedMnemonic('O');
add(formattedTextFieldLabel, "cell 0 7");
//---- formattedTextField1 ----
formattedTextField1.setText("editable");
+ formattedTextField1.setComponentPopupMenu(popupMenu1);
add(formattedTextField1, "cell 1 7,growx");
//---- formattedTextField2 ----
@@ -582,7 +597,27 @@ class BasicComponentsPanel
//---- textPane5 ----
textPane5.setText("no scroll pane");
add(textPane5, "cell 5 11,growx");
+
+ //======== popupMenu1 ========
+ {
+
+ //---- cutMenuItem ----
+ cutMenuItem.setText("Cut");
+ popupMenu1.add(cutMenuItem);
+
+ //---- copyMenuItem ----
+ copyMenuItem.setText("Copy");
+ popupMenu1.add(copyMenuItem);
+
+ //---- pasteMenuItem ----
+ pasteMenuItem.setText("Paste");
+ popupMenu1.add(pasteMenuItem);
+ }
// JFormDesigner - End of component initialization //GEN-END:initComponents
+
+ cutMenuItem.addActionListener( new DefaultEditorKit.CutAction() );
+ copyMenuItem.addActionListener( new DefaultEditorKit.CopyAction() );
+ pasteMenuItem.addActionListener( new DefaultEditorKit.PasteAction() );
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd
index 469a8884..81c6bb83 100644
--- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd
+++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd
@@ -183,6 +183,8 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "comboBoxLabel"
"text": "JComboBox:"
+ "displayedMnemonic": 67
+ "labelFor": new FormReference( "comboBox1" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
@@ -254,6 +256,8 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "spinnerLabel"
"text": "JSpinner:"
+ "labelFor": new FormReference( "spinner1" )
+ "displayedMnemonic": 83
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
@@ -281,12 +285,15 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "textFieldLabel"
"text": "JTextField:"
+ "displayedMnemonic": 84
+ "labelFor": new FormReference( "textField1" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 6"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField1"
"text": "editable"
+ "componentPopupMenu": &FormReference0 new FormReference( "popupMenu1" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 6,growx"
} )
@@ -321,12 +328,15 @@ new FormModel {
add( new FormComponent( "javax.swing.JLabel" ) {
name: "formattedTextFieldLabel"
"text": "JFormattedTextField:"
+ "labelFor": new FormReference( "formattedTextField1" )
+ "displayedMnemonic": 79
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 7"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField1"
"text": "editable"
+ "componentPopupMenu": #FormReference0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 7,growx"
} )
@@ -585,7 +595,25 @@ new FormModel {
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
- "size": new java.awt.Dimension( 790, 715 )
+ "size": new java.awt.Dimension( 790, 440 )
+ } )
+ add( new FormContainer( "javax.swing.JPopupMenu", new FormLayoutManager( class javax.swing.JPopupMenu ) ) {
+ name: "popupMenu1"
+ add( new FormComponent( "javax.swing.JMenuItem" ) {
+ name: "cutMenuItem"
+ "text": "Cut"
+ } )
+ add( new FormComponent( "javax.swing.JMenuItem" ) {
+ name: "copyMenuItem"
+ "text": "Copy"
+ } )
+ add( new FormComponent( "javax.swing.JMenuItem" ) {
+ name: "pasteMenuItem"
+ "text": "Paste"
+ } )
+ }, new FormLayoutConstraints( null ) {
+ "location": new java.awt.Point( 0, 500 )
+ "size": new java.awt.Dimension( 91, 87 )
} )
}
}
diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java
index 9a7c5208..3b365b21 100644
--- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java
+++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java
@@ -19,6 +19,7 @@ package com.formdev.flatlaf.demo;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
+import javax.swing.text.DefaultEditorKit;
import com.formdev.flatlaf.demo.intellijthemes.*;
import com.formdev.flatlaf.extras.FlatSVGIcon;
import net.miginfocom.swing.*;
@@ -175,21 +176,18 @@ class DemoFrame
cutMenuItem.setText("Cut");
cutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
cutMenuItem.setMnemonic('C');
- cutMenuItem.addActionListener(e -> menuItemActionPerformed(e));
editMenu.add(cutMenuItem);
//---- copyMenuItem ----
copyMenuItem.setText("Copy");
copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
copyMenuItem.setMnemonic('O');
- copyMenuItem.addActionListener(e -> menuItemActionPerformed(e));
editMenu.add(copyMenuItem);
//---- pasteMenuItem ----
pasteMenuItem.setText("Paste");
pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
pasteMenuItem.setMnemonic('P');
- pasteMenuItem.addActionListener(e -> menuItemActionPerformed(e));
editMenu.add(pasteMenuItem);
editMenu.addSeparator();
@@ -385,6 +383,10 @@ class DemoFrame
pasteButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/menu-paste.svg" ) );
refreshButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/refresh.svg" ) );
showToggleButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/demo/icons/show.svg" ) );
+
+ cutMenuItem.addActionListener( new DefaultEditorKit.CutAction() );
+ copyMenuItem.addActionListener( new DefaultEditorKit.CopyAction() );
+ pasteMenuItem.addActionListener( new DefaultEditorKit.PasteAction() );
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd
index 4912b254..179c618a 100644
--- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd
+++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd
@@ -179,21 +179,18 @@ new FormModel {
"text": "Cut"
"accelerator": static javax.swing.KeyStroke getKeyStroke( 88, 4226, false )
"mnemonic": 67
- addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) )
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "copyMenuItem"
"text": "Copy"
"accelerator": static javax.swing.KeyStroke getKeyStroke( 67, 4226, false )
"mnemonic": 79
- addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) )
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "pasteMenuItem"
"text": "Paste"
"accelerator": static javax.swing.KeyStroke getKeyStroke( 86, 4226, false )
"mnemonic": 80
- addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "menuItemActionPerformed", true ) )
} )
add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) {
name: "separator3"
diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTextComponentsTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTextComponentsTest.java
new file mode 100644
index 00000000..06f722cd
--- /dev/null
+++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTextComponentsTest.java
@@ -0,0 +1,339 @@
+/*
+ * Copyright 2020 FormDev Software GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.formdev.flatlaf.testing;
+
+import javax.swing.*;
+import javax.swing.text.DefaultEditorKit;
+import net.miginfocom.swing.*;
+
+/**
+ * @author Karl Tauber
+ */
+public class FlatTextComponentsTest
+ extends FlatTestPanel
+{
+ public static void main( String[] args ) {
+ SwingUtilities.invokeLater( () -> {
+ FlatTestFrame frame = FlatTestFrame.create( args, "FlatTextComponentsTest" );
+ frame.showFrame( FlatTextComponentsTest::new );
+ } );
+ }
+
+ FlatTextComponentsTest() {
+ initComponents();
+ }
+
+ private void changeText() {
+ textField1.setText( "new text" );
+ }
+
+ private void initComponents() {
+ // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
+ JLabel textFieldLabel = new JLabel();
+ textField1 = new JTextField();
+ JTextField textField3 = new JTextField();
+ JTextField textField2 = new JTextField();
+ JButton button1 = new JButton();
+ JLabel formattedTextFieldLabel = new JLabel();
+ JFormattedTextField formattedTextField1 = new JFormattedTextField();
+ JFormattedTextField formattedTextField3 = new JFormattedTextField();
+ JLabel passwordFieldLabel = new JLabel();
+ JPasswordField passwordField1 = new JPasswordField();
+ JPasswordField passwordField3 = new JPasswordField();
+ JLabel textAreaLabel = new JLabel();
+ JScrollPane scrollPane1 = new JScrollPane();
+ JTextArea textArea1 = new JTextArea();
+ JScrollPane scrollPane3 = new JScrollPane();
+ JTextArea textArea3 = new JTextArea();
+ JLabel editorPaneLabel = new JLabel();
+ JScrollPane scrollPane5 = new JScrollPane();
+ JEditorPane editorPane1 = new JEditorPane();
+ JScrollPane scrollPane7 = new JScrollPane();
+ JEditorPane editorPane3 = new JEditorPane();
+ JLabel textPaneLabel = new JLabel();
+ JScrollPane scrollPane9 = new JScrollPane();
+ JTextPane textPane1 = new JTextPane();
+ JScrollPane scrollPane11 = new JScrollPane();
+ JTextPane textPane3 = new JTextPane();
+ JLabel comboBoxLabel = new JLabel();
+ JComboBox