TextComponents: selectAllOnFocusPolicy related changes:
Some checks failed
CI / build (11) (push) Has been cancelled
CI / build-on (17, ) (push) Has been cancelled
CI / build-on (21, ) (push) Has been cancelled
CI / build-on (23, ) (push) Has been cancelled
CI / build-on (8, ) (push) Has been cancelled
CI / snapshot (push) Has been cancelled
CI / release (push) Has been cancelled

- No longer select all text if selection (or caret position) was changed by
  application and `selectAllOnFocusPolicy` is `once` (the default). (issue #983)
- FormattedTextField and Spinner: `selectAllOnFocusPolicy = once` behaves now
  as `always` (was `never` before), which means that all text is selected when
  component gains focus. This is because of special behavior of
  `JFormattedTextField` that did not allow implementation of `once`.
- Client property `JTextField.selectAllOnFocusPolicy` now also works on
  (editable) `JComboBox` and on `JSpinner`.
- Added client property `JTextField.selectAllOnMouseClick` to override UI
  property `TextComponent.selectAllOnMouseClick`. (issue #961)
- For `selectAllOnMouseClick = true`, clicking with the mouse into the text
  field, to focus it, now always selects all text, even if
  `selectAllOnFocusPolicy` is `once`.
This commit is contained in:
Karl Tauber
2025-03-16 11:10:02 +01:00
parent 666b99971d
commit d8e59f2cf3
8 changed files with 976 additions and 77 deletions

View File

@@ -70,6 +70,21 @@ FlatLaf Change Log
application where multiple class loaders are involved. E.g. in Eclipse plugin
or in LibreOffice extension. (issues #955 and #851)
- HTML: Fixed rendering of `<hr noshade>` in dark themes. (issue #932)
- TextComponents: `selectAllOnFocusPolicy` related changes:
- No longer select all text if selection (or caret position) was changed by
application and `selectAllOnFocusPolicy` is `once` (the default). (issue
#983)
- FormattedTextField and Spinner: `selectAllOnFocusPolicy = once` behaves now
as `always` (was `never` before), which means that all text is selected when
component gains focus. This is because of special behavior of
`JFormattedTextField` that did not allow implementation of `once`.
- Client property `JTextField.selectAllOnFocusPolicy` now also works on
(editable) `JComboBox` and on `JSpinner`.
- Added client property `JTextField.selectAllOnMouseClick` to override UI
property `TextComponent.selectAllOnMouseClick`. (issue #961)
- For `selectAllOnMouseClick = true`, clicking with the mouse into the text
field, to focus it, now always selects all text, even if
`selectAllOnFocusPolicy` is `once`.
#### Incompatibilities

View File

@@ -21,6 +21,8 @@ import java.awt.IllegalComponentStateException;
import java.awt.Window;
import java.util.Objects;
import javax.swing.JComponent;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SwingConstants;
/**
@@ -1209,12 +1211,15 @@ public interface FlatClientProperties
/**
* Specifies whether all text is selected when the text component gains focus.
* <p>
* <strong>Component</strong> {@link javax.swing.JTextField} (and subclasses)<br>
* <strong>Components</strong> {@link javax.swing.text.JTextComponent} (and subclasses),
* {@link javax.swing.JComboBox} (since 3.6) and {@link javax.swing.JSpinner} (since 3.6)<br>
* <strong>Value type</strong> {@link java.lang.String}<br>
* <strong>Allowed Values</strong>
* {@link #SELECT_ALL_ON_FOCUS_POLICY_NEVER},
* {@link #SELECT_ALL_ON_FOCUS_POLICY_ONCE} (default) or
* {@link #SELECT_ALL_ON_FOCUS_POLICY_ALWAYS}
*
* @see #SELECT_ALL_ON_MOUSE_CLICK
*/
String SELECT_ALL_ON_FOCUS_POLICY = "JTextField.selectAllOnFocusPolicy";
@@ -1229,6 +1234,12 @@ public interface FlatClientProperties
* 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.
* <p>
* <b>Limitations:</b>
* For {@link JFormattedTextField} and {@link JSpinner} this behaves
* as {@link #SELECT_ALL_ON_FOCUS_POLICY_ALWAYS}.
* This is because of special behavior of {@link JFormattedTextField}
* that did not allow implementation of {@code "once"}.
*
* @see #SELECT_ALL_ON_FOCUS_POLICY
*/
@@ -1241,6 +1252,19 @@ public interface FlatClientProperties
*/
String SELECT_ALL_ON_FOCUS_POLICY_ALWAYS = "always";
/**
* Specifies whether all text is selected when when clicking with the mouse
* into the text field (and if "select all on focus" policy is enabled).
* <p>
* <strong>Components</strong> {@link javax.swing.text.JTextComponent} (and subclasses),
* {@link javax.swing.JComboBox} and {@link javax.swing.JSpinner}<br>
* <strong>Value type</strong> {@link java.lang.Boolean}
*
* @see #SELECT_ALL_ON_FOCUS_POLICY
* @since 3.6
*/
String SELECT_ALL_ON_MOUSE_CLICK = "JTextField.selectAllOnMouseClick";
/**
* Placeholder text that is only painted if the text field is empty.
* <p>

View File

@@ -17,6 +17,7 @@
package com.formdev.flatlaf.ui;
import static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.Container;
import java.awt.EventQueue;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
@@ -24,7 +25,9 @@ import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.UIResource;
@@ -33,6 +36,7 @@ import javax.swing.text.DefaultCaret;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import javax.swing.text.Position;
import javax.swing.text.Utilities;
/**
@@ -48,12 +52,15 @@ public class FlatCaret
{
private static final String KEY_CARET_INFO = "FlatLaf.internal.caretInfo";
// selectAllOnFocusPolicy
private static final int NEVER = 0, ONCE = 1, ALWAYS = 2;
private final String selectAllOnFocusPolicy;
private final boolean selectAllOnMouseClick;
private boolean inInstall;
private boolean wasFocused;
private boolean wasTemporaryLost;
private boolean wasFocusTemporaryLost;
private boolean isMousePressed;
private boolean isWordSelection;
private boolean isLineSelection;
@@ -94,6 +101,9 @@ public class FlatCaret
// restore selection
select( (int) ci[1], (int) ci[0] );
if( ci[4] != 0 )
wasFocused = true;
// if text component is focused, then caret and selection are visible,
// but when switching theme, the component does not yet have
// a highlighter and the selection is not painted
@@ -121,6 +131,7 @@ public class FlatCaret
getMark(),
getBlinkRate(),
System.currentTimeMillis(),
wasFocused ? 1 : 0,
} );
super.deinstall( c );
@@ -140,11 +151,36 @@ public class FlatCaret
super.adjustVisibility( nloc );
}
@Override
public void setDot( int dot ) {
super.setDot( dot );
// mark as focused if invoked from JTextComponent.setCaretPosition()
// to disable SELECT_ALL_ON_FOCUS_POLICY_ONCE if application explicitly changes selection
if( !wasFocused &&
getSelectAllOnFocusPolicy() == ONCE &&
StackUtils.wasInvokedFrom( JTextComponent.class.getName(), "setCaretPosition", 6 ) )
wasFocused = true;
}
@Override
public void moveDot( int dot ) {
super.moveDot( dot );
// mark as focused if invoked from JTextComponent.moveCaretPosition()
// to disable SELECT_ALL_ON_FOCUS_POLICY_ONCE if application explicitly changes selection
if( !wasFocused &&
getSelectAllOnFocusPolicy() == ONCE &&
StackUtils.wasInvokedFrom( JTextComponent.class.getName(), "moveCaretPosition", 6 ) )
wasFocused = true;
}
@Override
public void focusGained( FocusEvent e ) {
if( !inInstall && !wasTemporaryLost && (!isMousePressed || selectAllOnMouseClick) )
if( !inInstall && !wasFocusTemporaryLost && (!isMousePressed || isSelectAllOnMouseClick()) )
selectAllOnFocusGained();
wasTemporaryLost = false;
wasFocusTemporaryLost = false;
wasFocused = true;
super.focusGained( e );
@@ -152,7 +188,7 @@ public class FlatCaret
@Override
public void focusLost( FocusEvent e ) {
wasTemporaryLost = e.isTemporary();
wasFocusTemporaryLost = e.isTemporary();
super.focusLost( e );
}
@@ -232,24 +268,13 @@ public class FlatCaret
if( doc == null || !c.isEnabled() || !c.isEditable() || FlatUIUtils.isCellEditor( c ) )
return;
Object selectAllOnFocusPolicy = c.getClientProperty( SELECT_ALL_ON_FOCUS_POLICY );
if( selectAllOnFocusPolicy == null )
selectAllOnFocusPolicy = this.selectAllOnFocusPolicy;
if( selectAllOnFocusPolicy == null || SELECT_ALL_ON_FOCUS_POLICY_NEVER.equals( selectAllOnFocusPolicy ) )
int selectAllOnFocusPolicy = getSelectAllOnFocusPolicy();
if( selectAllOnFocusPolicy == NEVER )
return;
if( !SELECT_ALL_ON_FOCUS_POLICY_ALWAYS.equals( selectAllOnFocusPolicy ) ) {
// policy is "once" (or null or unknown)
if( selectAllOnFocusPolicy == ONCE && !isMousePressed ) {
// 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() )
if( wasFocused && !(c instanceof JFormattedTextField) )
return;
}
@@ -265,16 +290,51 @@ public class FlatCaret
select( 0, c2.getDocument().getLength() );
} );
} else {
} else
select( 0, doc.getLength() );
}
}
private void select( int mark, int dot ) {
if( mark != getMark() )
setDot( mark );
setDot( mark, Position.Bias.Forward );
if( dot != getDot() )
moveDot( dot );
moveDot( dot, Position.Bias.Forward );
}
private int getSelectAllOnFocusPolicy() {
Object value = getClientProperty( SELECT_ALL_ON_FOCUS_POLICY );
// Note: using String.valueOf() because selectAllOnFocusPolicy may be null
switch( String.valueOf( value instanceof String ? value : selectAllOnFocusPolicy ) ) {
default:
case SELECT_ALL_ON_FOCUS_POLICY_NEVER: return NEVER;
case SELECT_ALL_ON_FOCUS_POLICY_ONCE: return ONCE;
case SELECT_ALL_ON_FOCUS_POLICY_ALWAYS: return ALWAYS;
}
}
private boolean isSelectAllOnMouseClick() {
Object value = getClientProperty( SELECT_ALL_ON_MOUSE_CLICK );
return (value instanceof Boolean) ? (boolean) value : selectAllOnMouseClick;
}
private Object getClientProperty( String key ) {
JTextComponent c = getComponent();
if( c == null )
return null;
Object value = c.getClientProperty( key );
if( value != null )
return value;
Container parent = c.getParent();
if( parent instanceof JComboBox )
return ((JComboBox<?>)parent).getClientProperty( key );
if( parent instanceof JSpinner.DefaultEditor ) {
parent = parent.getParent();
if( parent instanceof JSpinner )
return ((JSpinner)parent).getClientProperty( key );
}
return null;
}
/** @since 1.4 */

View File

@@ -24,13 +24,8 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
import javax.swing.UIManager;
import java.util.function.Supplier;
import javax.swing.*;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import com.formdev.flatlaf.FlatDarculaLaf;
@@ -59,11 +54,18 @@ public class FlatSingleComponentTest
private final JLabel infoLabel;
private JComponent createSingleComponent() {
protected JComponent createSingleComponent() {
return new JButton( "hello" );
}
public static void main( String[] args ) {
EventQueue.invokeLater( () -> {
launch( FlatSingleComponentTest::new, args );
} );
}
@SuppressWarnings( "ReturnValueIgnored" ) // Error Prone
protected static void launch( Supplier<FlatSingleComponentTest> factory, String[] args ) {
DemoPrefs.init( PREFS_ROOT_PATH );
DemoPrefs.initSystemScale();
@@ -88,10 +90,10 @@ public class FlatSingleComponentTest
DemoPrefs.setupLaf( args );
// create and show frame
new FlatSingleComponentTest();
factory.get();
}
private FlatSingleComponentTest() {
protected FlatSingleComponentTest() {
super( "FlatSingleComponentTest" );
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

View File

@@ -18,7 +18,9 @@ package com.formdev.flatlaf.testing;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FocusTraversalPolicy;
import java.awt.Graphics;
import java.awt.Insets;
import java.util.function.Supplier;
@@ -47,6 +49,12 @@ public class FlatTextComponentsTest
FlatTextComponentsTest() {
initComponents();
updatePreferredSizes();
// exclude from tab focus traversal
controlPanel.setFocusTraversalPolicyProvider( true );
controlPanel.setFocusTraversalPolicy( new NotFocusableTraversalPolicy() );
placeholderPanel.setFocusTraversalPolicyProvider( true );
placeholderPanel.setFocusTraversalPolicy( new NotFocusableTraversalPolicy() );
}
@Override
@@ -196,7 +204,7 @@ public class FlatTextComponentsTest
JLabel formattedTextFieldLabel = new JLabel();
JFormattedTextField formattedTextField1 = new JFormattedTextField();
JFormattedTextField formattedTextField3 = new JFormattedTextField();
JPanel panel1 = new JPanel();
controlPanel = new JPanel();
editableCheckBox = new JCheckBox();
JButton button1 = new JButton();
JLabel leftPaddingLabel = new JLabel();
@@ -215,7 +223,7 @@ public class FlatTextComponentsTest
trailingComponentVisibleCheckBox = new JCheckBox();
showClearButtonCheckBox = new JCheckBox();
showRevealButtonCheckBox = new JCheckBox();
JPanel panel2 = new JPanel();
placeholderPanel = new JPanel();
JLabel label7 = new JLabel();
FlatTextField flatTextField1 = new FlatTextField();
JLabel label8 = new JLabel();
@@ -351,11 +359,11 @@ public class FlatTextComponentsTest
formattedTextField3.putClientProperty(FlatClientProperties.PLACEHOLDER_TEXT, "place");
add(formattedTextField3, "cell 2 1,growx");
//======== panel1 ========
//======== controlPanel ========
{
panel1.setBorder(new TitledBorder("Control"));
panel1.putClientProperty("FlatLaf.internal.testing.ignore", true);
panel1.setLayout(new MigLayout(
controlPanel.setBorder(new TitledBorder("Control"));
controlPanel.putClientProperty("FlatLaf.internal.testing.ignore", true);
controlPanel.setLayout(new MigLayout(
"hidemode 3",
// columns
"[fill]" +
@@ -379,94 +387,104 @@ public class FlatTextComponentsTest
//---- editableCheckBox ----
editableCheckBox.setText("editable");
editableCheckBox.setSelected(true);
editableCheckBox.setFocusable(false);
editableCheckBox.addActionListener(e -> editableChanged());
panel1.add(editableCheckBox, "cell 0 0 2 1,alignx left,growx 0");
controlPanel.add(editableCheckBox, "cell 0 0 2 1,alignx left,growx 0");
//---- button1 ----
button1.setText("change text");
button1.setFocusable(false);
button1.addActionListener(e -> changeText());
panel1.add(button1, "cell 0 1 2 1,alignx left,growx 0");
controlPanel.add(button1, "cell 0 1 2 1,alignx left,growx 0");
//---- leftPaddingLabel ----
leftPaddingLabel.setText("Left padding:");
panel1.add(leftPaddingLabel, "cell 0 2");
controlPanel.add(leftPaddingLabel, "cell 0 2");
//---- leftPaddingField ----
leftPaddingField.addChangeListener(e -> paddingChanged());
panel1.add(leftPaddingField, "cell 1 2");
controlPanel.add(leftPaddingField, "cell 1 2");
//---- rightPaddingLabel ----
rightPaddingLabel.setText("Right padding:");
panel1.add(rightPaddingLabel, "cell 0 3");
controlPanel.add(rightPaddingLabel, "cell 0 3");
//---- rightPaddingField ----
rightPaddingField.addChangeListener(e -> paddingChanged());
panel1.add(rightPaddingField, "cell 1 3");
controlPanel.add(rightPaddingField, "cell 1 3");
//---- topPaddingLabel ----
topPaddingLabel.setText("Top padding:");
panel1.add(topPaddingLabel, "cell 0 4");
controlPanel.add(topPaddingLabel, "cell 0 4");
//---- topPaddingField ----
topPaddingField.addChangeListener(e -> paddingChanged());
panel1.add(topPaddingField, "cell 1 4");
controlPanel.add(topPaddingField, "cell 1 4");
//---- bottomPaddingLabel ----
bottomPaddingLabel.setText("Bottom padding:");
panel1.add(bottomPaddingLabel, "cell 0 5");
controlPanel.add(bottomPaddingLabel, "cell 0 5");
//---- bottomPaddingField ----
bottomPaddingField.addChangeListener(e -> paddingChanged());
panel1.add(bottomPaddingField, "cell 1 5");
controlPanel.add(bottomPaddingField, "cell 1 5");
//---- leadingIconCheckBox ----
leadingIconCheckBox.setText("leading icon");
leadingIconCheckBox.setFocusable(false);
leadingIconCheckBox.addActionListener(e -> leadingIcon());
panel1.add(leadingIconCheckBox, "cell 0 6 2 1,alignx left,growx 0");
controlPanel.add(leadingIconCheckBox, "cell 0 6 2 1,alignx left,growx 0");
//---- trailingIconCheckBox ----
trailingIconCheckBox.setText("trailing icon");
trailingIconCheckBox.setFocusable(false);
trailingIconCheckBox.addActionListener(e -> trailingIcon());
panel1.add(trailingIconCheckBox, "cell 0 7 2 1,alignx left,growx 0");
controlPanel.add(trailingIconCheckBox, "cell 0 7 2 1,alignx left,growx 0");
//---- leadingComponentCheckBox ----
leadingComponentCheckBox.setText("leading component");
leadingComponentCheckBox.setFocusable(false);
leadingComponentCheckBox.addActionListener(e -> leadingComponent());
panel1.add(leadingComponentCheckBox, "cell 0 8 2 1,alignx left,growx 0");
controlPanel.add(leadingComponentCheckBox, "cell 0 8 2 1,alignx left,growx 0");
//---- trailingComponentCheckBox ----
trailingComponentCheckBox.setText("trailing component");
trailingComponentCheckBox.setFocusable(false);
trailingComponentCheckBox.addActionListener(e -> trailingComponent());
panel1.add(trailingComponentCheckBox, "cell 0 9 2 1,alignx left,growx 0");
controlPanel.add(trailingComponentCheckBox, "cell 0 9 2 1,alignx left,growx 0");
//---- leadingComponentVisibleCheckBox ----
leadingComponentVisibleCheckBox.setText("leading component visible");
leadingComponentVisibleCheckBox.setSelected(true);
leadingComponentVisibleCheckBox.setFocusable(false);
leadingComponentVisibleCheckBox.addActionListener(e -> leadingComponentVisible());
panel1.add(leadingComponentVisibleCheckBox, "cell 0 10 2 1,alignx left,growx 0");
controlPanel.add(leadingComponentVisibleCheckBox, "cell 0 10 2 1,alignx left,growx 0");
//---- trailingComponentVisibleCheckBox ----
trailingComponentVisibleCheckBox.setText("trailing component visible");
trailingComponentVisibleCheckBox.setSelected(true);
trailingComponentVisibleCheckBox.setFocusable(false);
trailingComponentVisibleCheckBox.addActionListener(e -> trailingComponentVisible());
panel1.add(trailingComponentVisibleCheckBox, "cell 0 11 2 1,alignx left,growx 0");
controlPanel.add(trailingComponentVisibleCheckBox, "cell 0 11 2 1,alignx left,growx 0");
//---- showClearButtonCheckBox ----
showClearButtonCheckBox.setText("clear button");
showClearButtonCheckBox.setFocusable(false);
showClearButtonCheckBox.addActionListener(e -> showClearButton());
panel1.add(showClearButtonCheckBox, "cell 0 12 2 1,alignx left,growx 0");
controlPanel.add(showClearButtonCheckBox, "cell 0 12 2 1,alignx left,growx 0");
//---- showRevealButtonCheckBox ----
showRevealButtonCheckBox.setText("password reveal button");
showRevealButtonCheckBox.setFocusable(false);
showRevealButtonCheckBox.addActionListener(e -> showRevealButton());
panel1.add(showRevealButtonCheckBox, "cell 0 13 2 1,alignx left,growx 0");
controlPanel.add(showRevealButtonCheckBox, "cell 0 13 2 1,alignx left,growx 0");
}
add(panel1, "cell 4 0 1 10,aligny top,growy 0");
add(controlPanel, "cell 4 0 1 10,aligny top,growy 0");
//======== panel2 ========
//======== placeholderPanel ========
{
panel2.setBorder(new TitledBorder("Placeholder"));
panel2.setLayout(new MigLayout(
placeholderPanel.setBorder(new TitledBorder("Placeholder"));
placeholderPanel.setLayout(new MigLayout(
"hidemode 3",
// columns
"[fill]" +
@@ -480,55 +498,55 @@ public class FlatTextComponentsTest
//---- label7 ----
label7.setText("leading");
panel2.add(label7, "cell 0 0");
placeholderPanel.add(label7, "cell 0 0");
//---- flatTextField1 ----
flatTextField1.setHorizontalAlignment(SwingConstants.LEADING);
flatTextField1.setPlaceholderText("text");
flatTextField1.setColumns(10);
panel2.add(flatTextField1, "cell 1 0");
placeholderPanel.add(flatTextField1, "cell 1 0");
//---- label8 ----
label8.setText("left");
panel2.add(label8, "cell 0 1");
placeholderPanel.add(label8, "cell 0 1");
//---- flatTextField2 ----
flatTextField2.setHorizontalAlignment(SwingConstants.LEFT);
flatTextField2.setPlaceholderText("text");
flatTextField2.setColumns(10);
panel2.add(flatTextField2, "cell 1 1");
placeholderPanel.add(flatTextField2, "cell 1 1");
//---- label9 ----
label9.setText("center");
panel2.add(label9, "cell 0 2");
placeholderPanel.add(label9, "cell 0 2");
//---- flatTextField3 ----
flatTextField3.setHorizontalAlignment(SwingConstants.CENTER);
flatTextField3.setPlaceholderText("text");
flatTextField3.setColumns(10);
panel2.add(flatTextField3, "cell 1 2");
placeholderPanel.add(flatTextField3, "cell 1 2");
//---- label10 ----
label10.setText("right");
panel2.add(label10, "cell 0 3");
placeholderPanel.add(label10, "cell 0 3");
//---- flatTextField4 ----
flatTextField4.setHorizontalAlignment(SwingConstants.RIGHT);
flatTextField4.setPlaceholderText("text");
flatTextField4.setColumns(10);
panel2.add(flatTextField4, "cell 1 3");
placeholderPanel.add(flatTextField4, "cell 1 3");
//---- label11 ----
label11.setText("trailing");
panel2.add(label11, "cell 0 4");
placeholderPanel.add(label11, "cell 0 4");
//---- flatTextField5 ----
flatTextField5.setHorizontalAlignment(SwingConstants.TRAILING);
flatTextField5.setPlaceholderText("text");
flatTextField5.setColumns(10);
panel2.add(flatTextField5, "cell 1 4");
placeholderPanel.add(flatTextField5, "cell 1 4");
}
add(panel2, "cell 5 0 1 9,aligny top,growy 0");
add(placeholderPanel, "cell 5 0 1 10,aligny top,growy 0");
//---- passwordFieldLabel ----
passwordFieldLabel.setText("JPasswordField:");
@@ -783,6 +801,7 @@ public class FlatTextComponentsTest
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JTextField textField1;
private JPanel controlPanel;
private JCheckBox editableCheckBox;
private JSpinner leftPaddingField;
private JSpinner rightPaddingField;
@@ -796,6 +815,7 @@ public class FlatTextComponentsTest
private JCheckBox trailingComponentVisibleCheckBox;
private JCheckBox showClearButtonCheckBox;
private JCheckBox showRevealButtonCheckBox;
private JPanel placeholderPanel;
private JComboBox<String> comboBox5;
private JSpinner spinner4;
private JComboBox<String> comboBox6;
@@ -807,6 +827,18 @@ public class FlatTextComponentsTest
private JEditorPane editorPane;
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- NotFocusableTraversalPolicy ----------------------------------------
private static class NotFocusableTraversalPolicy
extends FocusTraversalPolicy
{
@Override public Component getComponentAfter( Container aContainer, Component aComponent ) { return null; }
@Override public Component getComponentBefore( Container aContainer, Component aComponent ) { return null; }
@Override public Component getFirstComponent( Container aContainer ) { return null; }
@Override public Component getLastComponent( Container aContainer ) { return null; }
@Override public Component getDefaultComponent( Container aContainer ) { return null; }
}
//---- TestIcon -----------------------------------------------------------
private static class TestIcon

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "8.1.0.0.283" Java: "19.0.2" encoding: "UTF-8"
JFDML JFormDesigner: "8.3" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -78,13 +78,17 @@ new FormModel {
"$columnConstraints": "[fill][fill]"
"$rowConstraints": "[][][][][][][]0[][]0[][]0[][][]"
} ) {
name: "panel1"
name: "controlPanel"
"border": new javax.swing.border.TitledBorder( "Control" )
"$client.FlatLaf.internal.testing.ignore": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "editableCheckBox"
"text": "editable"
"selected": true
"focusable": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -95,6 +99,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JButton" ) {
name: "button1"
"text": "change text"
"focusable": false
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "changeText", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 1 2 1,alignx left,growx 0"
@@ -162,6 +167,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "leadingIconCheckBox"
"text": "leading icon"
"focusable": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -172,6 +178,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "trailingIconCheckBox"
"text": "trailing icon"
"focusable": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -182,6 +189,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "leadingComponentCheckBox"
"text": "leading component"
"focusable": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -192,6 +200,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "trailingComponentCheckBox"
"text": "trailing component"
"focusable": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -203,6 +212,7 @@ new FormModel {
name: "leadingComponentVisibleCheckBox"
"text": "leading component visible"
"selected": true
"focusable": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -214,6 +224,7 @@ new FormModel {
name: "trailingComponentVisibleCheckBox"
"text": "trailing component visible"
"selected": true
"focusable": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -224,6 +235,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "showClearButtonCheckBox"
"text": "clear button"
"focusable": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -234,6 +246,7 @@ new FormModel {
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "showRevealButtonCheckBox"
"text": "password reveal button"
"focusable": false
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -249,8 +262,11 @@ new FormModel {
"$columnConstraints": "[fill][fill]"
"$rowConstraints": "[][][][][]"
} ) {
name: "panel2"
name: "placeholderPanel"
"border": new javax.swing.border.TitledBorder( "Placeholder" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label7"
"text": "leading"
@@ -325,7 +341,7 @@ new FormModel {
"value": "cell 1 4"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 0 1 9,aligny top,growy 0"
"value": "cell 5 0 1 10,aligny top,growy 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "passwordFieldLabel"

View File

@@ -0,0 +1,423 @@
/*
* Copyright 2025 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 static com.formdev.flatlaf.FlatClientProperties.*;
import java.awt.EventQueue;
import java.text.ParseException;
import javax.swing.*;
import javax.swing.text.DefaultFormatterFactory;
import javax.swing.text.MaskFormatter;
import net.miginfocom.swing.*;
/**
* @author Karl Tauber
*/
public class FlatTextSelectAllOnFocusTest
extends FlatSingleComponentTest
{
public static void main( String[] args ) {
EventQueue.invokeLater( () -> {
launch( FlatTextSelectAllOnFocusTest::new, args );
} );
}
@Override
protected JComponent createSingleComponent() {
initComponents();
try {
MaskFormatter formatter = new MaskFormatter( "###-####-###" );
formatter.setPlaceholderCharacter( '_' );
DefaultFormatterFactory factory = new DefaultFormatterFactory( formatter );
formattedTextField1.setFormatterFactory( factory );
formattedTextField2.setFormatterFactory( factory );
formattedTextField3.setFormatterFactory( factory );
formattedTextField4.setFormatterFactory( factory );
formattedTextField5.setFormatterFactory( factory );
formattedTextField6.setFormatterFactory( factory );
formattedTextField1.setValue( "123-4567-890" );
formattedTextField2.setValue( "123-4567-890" );
formattedTextField3.setValue( "123-4567-890" );
formattedTextField4.setValue( "123-4567-890" );
formattedTextField5.setValue( "123-4567-890" );
formattedTextField6.setValue( "123-4567-890" );
} catch( ParseException ex ) {
ex.printStackTrace();
}
textField2.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_NEVER );
textField3.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
textField4.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
textField5.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
textField5.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
textField6.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
textField6.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
textField7.select( 5, 7 );
formattedTextField2.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_NEVER );
formattedTextField3.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
formattedTextField4.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
formattedTextField5.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
formattedTextField5.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
formattedTextField6.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
formattedTextField6.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
comboBox2.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_NEVER );
comboBox3.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
comboBox4.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
comboBox5.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
comboBox5.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
comboBox6.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
comboBox6.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
((JTextField)comboBox7.getEditor().getEditorComponent()).select( 5, 7 );
spinner2.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_NEVER );
spinner3.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
spinner4.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
spinner5.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
spinner5.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
spinner6.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
spinner6.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
// textArea1.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
// textPane1.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
// editorPane1.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ALWAYS );
//
// textArea1.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
// textPane1.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
// editorPane1.putClientProperty( SELECT_ALL_ON_FOCUS_POLICY, SELECT_ALL_ON_FOCUS_POLICY_ONCE );
//
// textArea1.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
// textPane1.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
// editorPane1.putClientProperty( SELECT_ALL_ON_MOUSE_CLICK, true );
//
// textArea1.select( 5, 7 );
// textPane1.select( 5, 7 );
// editorPane1.select( 5, 7 );
return panel;
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
panel = new FlatTestPanel();
label1 = new JLabel();
label2 = new JLabel();
label3 = new JLabel();
label4 = new JLabel();
label5 = new JLabel();
label6 = new JLabel();
label7 = new JLabel();
textFieldLabel = new JLabel();
textField1 = new JTextField();
textField2 = new JTextField();
textField3 = new JTextField();
textField4 = new JTextField();
textField5 = new JTextField();
textField6 = new JTextField();
textField7 = new JTextField();
formattedTextFieldLabel = new JLabel();
formattedTextField1 = new JFormattedTextField();
formattedTextField2 = new JFormattedTextField();
formattedTextField3 = new JFormattedTextField();
formattedTextField4 = new JFormattedTextField();
formattedTextField5 = new JFormattedTextField();
formattedTextField6 = new JFormattedTextField();
comboBoxLabel = new JLabel();
comboBox1 = new JComboBox<>();
comboBox2 = new JComboBox<>();
comboBox3 = new JComboBox<>();
comboBox4 = new JComboBox<>();
comboBox5 = new JComboBox<>();
comboBox6 = new JComboBox<>();
comboBox7 = new JComboBox<>();
spinnerLabel = new JLabel();
spinner1 = new JSpinner();
spinner2 = new JSpinner();
spinner3 = new JSpinner();
spinner4 = new JSpinner();
spinner5 = new JSpinner();
spinner6 = new JSpinner();
scrollPane1 = new JScrollPane();
textArea1 = new JTextArea();
scrollPane2 = new JScrollPane();
textPane1 = new JTextPane();
scrollPane3 = new JScrollPane();
editorPane1 = new JEditorPane();
//======== panel ========
{
panel.setLayout(new MigLayout(
"ltr,insets dialog,hidemode 3",
// columns
"[]" +
"[100,sizegroup 1,fill]" +
"[sizegroup 1,fill]" +
"[sizegroup 1,fill]" +
"[sizegroup 1,fill]" +
"[sizegroup 1,fill]" +
"[fill]" +
"[fill]",
// rows
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[fill]" +
"[30]"));
//---- label1 ----
label1.setText("default");
panel.add(label1, "cell 1 0");
//---- label2 ----
label2.setText("never");
panel.add(label2, "cell 2 0");
//---- label3 ----
label3.setText("once");
panel.add(label3, "cell 3 0");
//---- label4 ----
label4.setText("always");
panel.add(label4, "cell 4 0");
//---- label5 ----
label5.setText("once on click");
panel.add(label5, "cell 5 0");
//---- label6 ----
label6.setText("always on click");
panel.add(label6, "cell 6 0");
//---- label7 ----
label7.setText("custom selection");
panel.add(label7, "cell 7 0");
//---- textFieldLabel ----
textFieldLabel.setText("JTextField:");
textFieldLabel.setDisplayedMnemonic('T');
textFieldLabel.setLabelFor(textField1);
panel.add(textFieldLabel, "cell 0 1");
//---- textField1 ----
textField1.setText("1234567890");
panel.add(textField1, "cell 1 1");
//---- textField2 ----
textField2.setText("1234567890");
panel.add(textField2, "cell 2 1");
//---- textField3 ----
textField3.setText("1234567890");
panel.add(textField3, "cell 3 1");
//---- textField4 ----
textField4.setText("1234567890");
panel.add(textField4, "cell 4 1");
//---- textField5 ----
textField5.setText("1234567890");
panel.add(textField5, "cell 5 1");
//---- textField6 ----
textField6.setText("1234567890");
panel.add(textField6, "cell 6 1");
//---- textField7 ----
textField7.setText("1234567890");
panel.add(textField7, "cell 7 1");
//---- formattedTextFieldLabel ----
formattedTextFieldLabel.setText("JFormattedTextField:");
formattedTextFieldLabel.setDisplayedMnemonic('F');
formattedTextFieldLabel.setLabelFor(formattedTextField1);
panel.add(formattedTextFieldLabel, "cell 0 2");
panel.add(formattedTextField1, "cell 1 2");
panel.add(formattedTextField2, "cell 2 2");
panel.add(formattedTextField3, "cell 3 2");
panel.add(formattedTextField4, "cell 4 2");
panel.add(formattedTextField5, "cell 5 2");
panel.add(formattedTextField6, "cell 6 2");
//---- comboBoxLabel ----
comboBoxLabel.setText("JComboBox:");
comboBoxLabel.setDisplayedMnemonic('C');
comboBoxLabel.setLabelFor(comboBox1);
panel.add(comboBoxLabel, "cell 0 3");
//---- comboBox1 ----
comboBox1.setEditable(true);
comboBox1.setModel(new DefaultComboBoxModel<>(new String[] {
"1234567890"
}));
panel.add(comboBox1, "cell 1 3");
//---- comboBox2 ----
comboBox2.setEditable(true);
comboBox2.setModel(new DefaultComboBoxModel<>(new String[] {
"1234567890"
}));
panel.add(comboBox2, "cell 2 3");
//---- comboBox3 ----
comboBox3.setEditable(true);
comboBox3.setModel(new DefaultComboBoxModel<>(new String[] {
"1234567890"
}));
panel.add(comboBox3, "cell 3 3");
//---- comboBox4 ----
comboBox4.setEditable(true);
comboBox4.setModel(new DefaultComboBoxModel<>(new String[] {
"1234567890"
}));
panel.add(comboBox4, "cell 4 3");
//---- comboBox5 ----
comboBox5.setEditable(true);
comboBox5.setModel(new DefaultComboBoxModel<>(new String[] {
"1234567890"
}));
panel.add(comboBox5, "cell 5 3");
//---- comboBox6 ----
comboBox6.setEditable(true);
comboBox6.setModel(new DefaultComboBoxModel<>(new String[] {
"1234567890"
}));
panel.add(comboBox6, "cell 6 3");
//---- comboBox7 ----
comboBox7.setEditable(true);
comboBox7.setModel(new DefaultComboBoxModel<>(new String[] {
"1234567890"
}));
panel.add(comboBox7, "cell 7 3");
//---- spinnerLabel ----
spinnerLabel.setText("JSpinner:");
spinnerLabel.setDisplayedMnemonic('S');
spinnerLabel.setLabelFor(spinner1);
panel.add(spinnerLabel, "cell 0 4");
//---- spinner1 ----
spinner1.setModel(new SpinnerNumberModel(1234, null, null, 100));
panel.add(spinner1, "cell 1 4");
//---- spinner2 ----
spinner2.setModel(new SpinnerNumberModel(1234, null, null, 100));
panel.add(spinner2, "cell 2 4");
//---- spinner3 ----
spinner3.setModel(new SpinnerNumberModel(1234, null, null, 100));
panel.add(spinner3, "cell 3 4");
//---- spinner4 ----
spinner4.setModel(new SpinnerNumberModel(1234, null, null, 100));
panel.add(spinner4, "cell 4 4");
//---- spinner5 ----
spinner5.setModel(new SpinnerNumberModel(1234, null, null, 100));
panel.add(spinner5, "cell 5 4");
//---- spinner6 ----
spinner6.setModel(new SpinnerNumberModel(1234, null, null, 100));
panel.add(spinner6, "cell 6 4");
//======== scrollPane1 ========
{
//---- textArea1 ----
textArea1.setRows(3);
textArea1.setText("1234567890\nabc");
scrollPane1.setViewportView(textArea1);
}
panel.add(scrollPane1, "cell 1 5");
//======== scrollPane2 ========
{
//---- textPane1 ----
textPane1.setText("1234567890\nabc");
scrollPane2.setViewportView(textPane1);
}
panel.add(scrollPane2, "cell 2 5");
//======== scrollPane3 ========
{
//---- editorPane1 ----
editorPane1.setText("1234567890\nabc");
scrollPane3.setViewportView(editorPane1);
}
panel.add(scrollPane3, "cell 3 5 2 1");
}
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private FlatTestPanel panel;
private JLabel label1;
private JLabel label2;
private JLabel label3;
private JLabel label4;
private JLabel label5;
private JLabel label6;
private JLabel label7;
private JLabel textFieldLabel;
private JTextField textField1;
private JTextField textField2;
private JTextField textField3;
private JTextField textField4;
private JTextField textField5;
private JTextField textField6;
private JTextField textField7;
private JLabel formattedTextFieldLabel;
private JFormattedTextField formattedTextField1;
private JFormattedTextField formattedTextField2;
private JFormattedTextField formattedTextField3;
private JFormattedTextField formattedTextField4;
private JFormattedTextField formattedTextField5;
private JFormattedTextField formattedTextField6;
private JLabel comboBoxLabel;
private JComboBox<String> comboBox1;
private JComboBox<String> comboBox2;
private JComboBox<String> comboBox3;
private JComboBox<String> comboBox4;
private JComboBox<String> comboBox5;
private JComboBox<String> comboBox6;
private JComboBox<String> comboBox7;
private JLabel spinnerLabel;
private JSpinner spinner1;
private JSpinner spinner2;
private JSpinner spinner3;
private JSpinner spinner4;
private JSpinner spinner5;
private JSpinner spinner6;
private JScrollPane scrollPane1;
private JTextArea textArea1;
private JScrollPane scrollPane2;
private JTextPane textPane1;
private JScrollPane scrollPane3;
private JEditorPane editorPane1;
// JFormDesigner - End of variables declaration //GEN-END:variables
}

View File

@@ -0,0 +1,327 @@
JFDML JFormDesigner: "8.3" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
root: new FormRoot {
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[][100,sizegroup 1,fill][sizegroup 1,fill][sizegroup 1,fill][sizegroup 1,fill][sizegroup 1,fill][fill][fill]"
"$rowConstraints": "[][][][][][fill][30]"
} ) {
name: "panel"
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label1"
"text": "default"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label2"
"text": "never"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label3"
"text": "once"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label4"
"text": "always"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"text": "once on click"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6"
"text": "always on click"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 0"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label7"
"text": "custom selection"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 0"
} )
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 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField1"
"text": "1234567890"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField2"
"text": "1234567890"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField3"
"text": "1234567890"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField4"
"text": "1234567890"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField5"
"text": "1234567890"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField6"
"text": "1234567890"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 1"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField7"
"text": "1234567890"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 1"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "formattedTextFieldLabel"
"text": "JFormattedTextField:"
"displayedMnemonic": 70
"labelFor": new FormReference( "formattedTextField1" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField1"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField2"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField3"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 2"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField4"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 2"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField5"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 2"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField6"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 2"
} )
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 3"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox1"
"editable": true
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "1234567890"
addElement( "1234567890" )
}
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox2"
"editable": true
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "1234567890"
addElement( "1234567890" )
}
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox3"
"editable": true
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "1234567890"
addElement( "1234567890" )
}
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 3"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox4"
"editable": true
"model": new javax.swing.DefaultComboBoxModel {
selectedItem: "1234567890"
addElement( "1234567890" )
}
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 3"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox5"
"editable": true
"model": &DefaultComboBoxModel0 new javax.swing.DefaultComboBoxModel {
selectedItem: "1234567890"
addElement( "1234567890" )
}
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 3"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox6"
"editable": true
"model": #DefaultComboBoxModel0
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 3"
} )
add( new FormComponent( "javax.swing.JComboBox" ) {
name: "comboBox7"
"editable": true
"model": #DefaultComboBoxModel0
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 7 3"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "spinnerLabel"
"text": "JSpinner:"
"displayedMnemonic": 83
"labelFor": new FormReference( "spinner1" )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner1"
"model": new javax.swing.SpinnerNumberModel {
stepSize: 100
value: 1234
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner2"
"model": new javax.swing.SpinnerNumberModel {
stepSize: 100
value: 1234
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 4"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner3"
"model": new javax.swing.SpinnerNumberModel {
stepSize: 100
value: 1234
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 4"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner4"
"model": new javax.swing.SpinnerNumberModel {
stepSize: 100
value: 1234
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 4"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner5"
"model": &SpinnerNumberModel0 new javax.swing.SpinnerNumberModel {
stepSize: 100
value: 1234
}
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 5 4"
} )
add( new FormComponent( "javax.swing.JSpinner" ) {
name: "spinner6"
"model": #SpinnerNumberModel0
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 6 4"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane1"
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "textArea1"
"rows": 3
"text": "1234567890\nabc"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane2"
add( new FormComponent( "javax.swing.JTextPane" ) {
name: "textPane1"
"text": "1234567890\nabc"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 5"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane3"
add( new FormComponent( "javax.swing.JEditorPane" ) {
name: "editorPane1"
"text": "1234567890\nabc"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 5 2 1"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 995, 285 )
} )
}
}