FormattedTextField implemented

This commit is contained in:
Karl Tauber
2019-08-21 14:37:58 +02:00
parent d0a7ded92b
commit faed3fabc6
7 changed files with 120 additions and 16 deletions

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2019 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
*
* http://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 javax.swing.JComponent;
import javax.swing.plaf.ComponentUI;
/**
* Provides the Flat LaF UI delegate for {@link javax.swing.JFormattedTextField}.
*
* @author Karl Tauber
*/
public class FlatFormattedTextFieldUI
extends FlatTextFieldUI
{
public static ComponentUI createUI( JComponent c ) {
return new FlatFormattedTextFieldUI();
}
@Override
protected String getPropertyPrefix() {
return "FormattedTextField";
}
}

View File

@@ -19,6 +19,7 @@
@background=3c3f41
@foreground=bbbbbb
@disabledText=777777
@textComponentBackground=45494A
#---- globals ----
@@ -88,8 +89,3 @@ Component.focusColor=3d6185
#---- Label ----
Label.disabledForeground=@disabledText
#---- TextField ----
TextField.background=45494A

View File

@@ -18,6 +18,7 @@
ButtonUI=com.formdev.flatlaf.ui.FlatButtonUI
CheckBoxUI=com.formdev.flatlaf.ui.FlatCheckBoxUI
FormattedTextFieldUI=com.formdev.flatlaf.ui.FlatFormattedTextFieldUI
LabelUI=com.formdev.flatlaf.ui.FlatLabelUI
RadioButtonUI=com.formdev.flatlaf.ui.FlatRadioButtonUI
TextFieldUI=com.formdev.flatlaf.ui.FlatTextFieldUI
@@ -41,6 +42,13 @@ Component.focusWidth=2
Component.arc=5
#---- FormattedTextField ----
FormattedTextField.border=com.formdev.flatlaf.ui.FlatBorder
FormattedTextField.background=@textComponentBackground
FormattedTextField.margin=2,6,2,6
#---- RadioButton ----
RadioButton.border=com.formdev.flatlaf.ui.FlatMarginBorder
@@ -50,4 +58,5 @@ RadioButton.icon=com.formdev.flatlaf.ui.FlatRadioButtonIcon
#---- TextField ----
TextField.border=com.formdev.flatlaf.ui.FlatBorder
TextField.background=@textComponentBackground
TextField.margin=2,6,2,6

View File

@@ -19,6 +19,7 @@
@background=f2f2f2
@foreground=000000
@disabledText=999999
@textComponentBackground=ffffff
#---- globals ----
@@ -88,8 +89,3 @@ Component.focusColor=97c3f3
#---- Label ----
Label.disabledForeground=@disabledText
#---- TextField ----
TextField.background=ffffff

View File

@@ -71,6 +71,11 @@ public class FlatComponentsTest
JTextField textField2 = new JTextField();
JTextField textField3 = new JTextField();
JTextField textField4 = new JTextField();
JLabel formattedTextFieldLabel = new JLabel();
JFormattedTextField formattedTextField1 = new JFormattedTextField();
JFormattedTextField formattedTextField2 = new JFormattedTextField();
JFormattedTextField formattedTextField3 = new JFormattedTextField();
JFormattedTextField formattedTextField4 = new JFormattedTextField();
//======== this ========
setLayout(new MigLayout(
@@ -87,6 +92,8 @@ public class FlatComponentsTest
"[]" +
"[]" +
"[]" +
"[]" +
"[]" +
"[]"));
//---- labelLabel ----
@@ -206,6 +213,30 @@ public class FlatComponentsTest
textField4.setEnabled(false);
textField4.setEditable(false);
add(textField4, "cell 4 4,growx");
//---- formattedTextFieldLabel ----
formattedTextFieldLabel.setText("JFormattedTextField:");
add(formattedTextFieldLabel, "cell 0 5");
//---- formattedTextField1 ----
formattedTextField1.setText("editable");
add(formattedTextField1, "cell 1 5,growx");
//---- formattedTextField2 ----
formattedTextField2.setText("disabled");
formattedTextField2.setEnabled(false);
add(formattedTextField2, "cell 2 5,growx");
//---- formattedTextField3 ----
formattedTextField3.setText("not editable");
formattedTextField3.setEditable(false);
add(formattedTextField3, "cell 3 5,growx");
//---- formattedTextField4 ----
formattedTextField4.setText("not editable disabled");
formattedTextField4.setEnabled(false);
formattedTextField4.setEditable(false);
add(formattedTextField4, "cell 4 5,growx");
// JFormDesigner - End of component initialization //GEN-END:initComponents
}

View File

@@ -9,7 +9,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3,gap 5 5"
"$columnConstraints": "[][][][][][]"
"$rowConstraints": "[][][][][]"
"$rowConstraints": "[][][][][][][]"
} ) {
name: "this"
add( new FormComponent( "javax.swing.JLabel" ) {
@@ -178,6 +178,40 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 4,growx"
} )
add( new FormComponent( "javax.swing.JLabel" ) {
name: "formattedTextFieldLabel"
"text": "JFormattedTextField:"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 5"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField1"
"text": "editable"
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 5,growx"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField2"
"text": "disabled"
"enabled": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 5,growx"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField3"
"text": "not editable"
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 3 5,growx"
} )
add( new FormComponent( "javax.swing.JFormattedTextField" ) {
name: "formattedTextField4"
"text": "not editable disabled"
"enabled": false
"editable": false
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 4 5,growx"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 580, 300 )

View File

@@ -14,6 +14,11 @@
# limitations under the License.
#
#---- variables ----
@textComponentBackground=ffffff
#---- globals ----
*.background=ccffcc
@@ -70,8 +75,3 @@ Component.focusColor=97c3f3
Label.foreground=008800
Label.disabledForeground=000088
#---- TextField ----
TextField.background=ffffff