TextComponents: double-click-and-drag now extends selection by whole words

This commit is contained in:
Karl Tauber
2021-10-21 13:24:07 +02:00
parent f8b9f4c1fa
commit e36f942129
8 changed files with 254 additions and 5 deletions

View File

@@ -137,6 +137,15 @@ public class FlatTextComponentsTest
JLabel label4 = new JLabel();
JComboBox<String> comboBox6 = new JComboBox<>();
JSpinner spinner5 = new JSpinner();
JLabel label5 = new JLabel();
JTextField textField4 = new JTextField();
JLabel label6 = new JLabel();
JScrollPane scrollPane2 = new JScrollPane();
JTextArea textArea2 = new JTextArea();
JScrollPane scrollPane4 = new JScrollPane();
JTextPane textPane4 = new JTextPane();
JScrollPane scrollPane6 = new JScrollPane();
JEditorPane editorPane5 = new JEditorPane();
JPopupMenu popupMenu1 = new JPopupMenu();
JMenuItem cutMenuItem = new JMenuItem();
JMenuItem copyMenuItem = new JMenuItem();
@@ -168,7 +177,9 @@ public class FlatTextComponentsTest
"[::14]" +
"[::14]" +
"[]" +
"[]"));
"[]para" +
"[]" +
"[90,fill]"));
//---- textFieldLabel ----
textFieldLabel.setText("JTextField:");
@@ -519,6 +530,54 @@ public class FlatTextComponentsTest
spinner5.setName("spinner5");
add(spinner5, "cell 1 15,growx,hmax 14");
//---- label5 ----
label5.setText("Double-click-and-drag:");
label5.setName("label5");
add(label5, "cell 0 16");
//---- textField4 ----
textField4.setText("123 456 789 abc def");
textField4.setName("textField4");
add(textField4, "cell 1 16 2 1,growx");
//---- label6 ----
label6.setText("<html>JTextArea<br>JTextPane<br>JEditorPane</html>");
label6.setName("label6");
add(label6, "cell 0 17,align right top,grow 0 0");
//======== scrollPane2 ========
{
scrollPane2.setName("scrollPane2");
//---- textArea2 ----
textArea2.setText("1 123 456 789 abc def\n2 123 456 789 abc def\n3 123 456 789 abc def\n4 123 456 789 abc def\n5 123 456 789 abc def\n6 123 456 789 abc def\n7 123 456 789 abc def\n8 123 456 789 abc def");
textArea2.setName("textArea2");
scrollPane2.setViewportView(textArea2);
}
add(scrollPane2, "cell 1 17 4 1,growx");
//======== scrollPane4 ========
{
scrollPane4.setName("scrollPane4");
//---- textPane4 ----
textPane4.setText("1 123 456 789 abc def\n2 123 456 789 abc def\n3 123 456 789 abc def\n4 123 456 789 abc def\n5 123 456 789 abc def\n6 123 456 789 abc def\n7 123 456 789 abc def\n8 123 456 789 abc def");
textPane4.setName("textPane4");
scrollPane4.setViewportView(textPane4);
}
add(scrollPane4, "cell 1 17 4 1,growx");
//======== scrollPane6 ========
{
scrollPane6.setName("scrollPane6");
//---- editorPane5 ----
editorPane5.setText("1 123 456 789 abc def\n2 123 456 789 abc def\n3 123 456 789 abc def\n4 123 456 789 abc def\n5 123 456 789 abc def\n6 123 456 789 abc def\n7 123 456 789 abc def\n8 123 456 789 abc def");
editorPane5.setName("editorPane5");
scrollPane6.setViewportView(editorPane5);
}
add(scrollPane6, "cell 1 17 4 1,growx");
//======== popupMenu1 ========
{
popupMenu1.setName("popupMenu1");

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8"
JFDML JFormDesigner: "7.0.4.0.360" Java: "17" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -10,7 +10,7 @@ new FormModel {
add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
"$columnConstraints": "[][][::100][100,fill][fill]"
"$rowConstraints": "[][][][50,fill][50,fill][50,fill][][]para[40][40][][][::14][::14][][]"
"$rowConstraints": "[][][][50,fill][50,fill][50,fill][][]para[40][40][][][::14][::14][][]para[][90,fill]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
@@ -416,9 +416,54 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 15,growx,hmax 14"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label5"
"text": "Double-click-and-drag:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 16"
} )
add( new FormComponent( "javax.swing.JTextField" ) {
name: "textField4"
"text": "123 456 789 abc def"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 16 2 1,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "label6"
"text": "<html>JTextArea<br>JTextPane<br>JEditorPane</html>"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 17,align right top,grow 0 0"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane2"
add( new FormComponent( "javax.swing.JTextArea" ) {
name: "textArea2"
"text": "1 123 456 789 abc def\n2 123 456 789 abc def\n3 123 456 789 abc def\n4 123 456 789 abc def\n5 123 456 789 abc def\n6 123 456 789 abc def\n7 123 456 789 abc def\n8 123 456 789 abc def"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 17 4 1,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane4"
add( new FormComponent( "javax.swing.JTextPane" ) {
name: "textPane4"
"text": "1 123 456 789 abc def\n2 123 456 789 abc def\n3 123 456 789 abc def\n4 123 456 789 abc def\n5 123 456 789 abc def\n6 123 456 789 abc def\n7 123 456 789 abc def\n8 123 456 789 abc def"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 17 4 1,growx"
} )
add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) {
name: "scrollPane6"
add( new FormComponent( "javax.swing.JEditorPane" ) {
name: "editorPane5"
"text": "1 123 456 789 abc def\n2 123 456 789 abc def\n3 123 456 789 abc def\n4 123 456 789 abc def\n5 123 456 789 abc def\n6 123 456 789 abc def\n7 123 456 789 abc def\n8 123 456 789 abc def"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 17 4 1,growx"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 530, 660 )
"size": new java.awt.Dimension( 640, 725 )
} )
add( new FormContainer( "javax.swing.JPopupMenu", new FormLayoutManager( class javax.swing.JPopupMenu ) ) {
name: "popupMenu1"
@@ -435,7 +480,7 @@ new FormModel {
"text": "Paste"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 705 )
"location": new java.awt.Point( 0, 745 )
"size": new java.awt.Dimension( 91, 87 )
} )
}