[Schmitzm-commits] r1542 - trunk/schmitzm-core/src/test/java/de/schmitzm/swing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Mar 30 13:00:15 CEST 2011
Author: alfonx
Date: 2011-03-30 13:00:15 +0200 (Wed, 30 Mar 2011)
New Revision: 1542
Modified:
trunk/schmitzm-core/src/test/java/de/schmitzm/swing/FormattedTextFieldTest.java
Log:
Modified: trunk/schmitzm-core/src/test/java/de/schmitzm/swing/FormattedTextFieldTest.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/swing/FormattedTextFieldTest.java 2011-03-29 13:32:59 UTC (rev 1541)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/swing/FormattedTextFieldTest.java 2011-03-30 11:00:15 UTC (rev 1542)
@@ -1,23 +1,14 @@
package de.schmitzm.swing;
-import java.awt.BorderLayout;
-import java.awt.Dimension;
import java.awt.Font;
import java.text.Format;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFormattedTextField;
-import javax.swing.JFormattedTextField.AbstractFormatter;
import javax.swing.JLabel;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.PlainDocument;
import org.junit.Test;
@@ -26,44 +17,45 @@
import de.schmitzm.testing.TestingUtil;
public class FormattedTextFieldTest extends TestingClass {
- @Test
- public void testFormattedTextField() throws Throwable {
- final JLabel infoField = new JLabel(" ");
-
- Format format = new SimpleDateFormat("dd.MM.yyyy");
+ @Test
+ public void testFormattedTextField() throws Throwable {
+ final JLabel infoField = new JLabel(" ");
- JFormattedTextField field = new JFormattedTextField(format) {
- @Override
- public void commitEdit() throws ParseException {
- infoField.setText(" ");
- try {
- super.commitEdit();
- } catch (Exception err) {
- // if the given string can not be interpreted
- // try to complete the input
- String completedInput = LangUtil.completeEuropeanDateString( getText() );
- infoField.setText(completedInput);
- setText(completedInput);
- super.commitEdit();
- }
- }
- };
- field.setFont( new Font(Font.MONOSPACED,Font.PLAIN,12) );
- field.setText("dd.MM.yyyy");
- field.setColumns(10);
- field.setDocument( new LimitedDocument(10,LimitedDocument.STYLE_DECIMAL) );
- field.select(0, field.getText().length());
-// field.setFocusLostBehavior( JFormattedTextField.)
-// field.set
-// field.setPreferredSize( new Dimension(200,20) );
-
- JButton button = new JButton("Test");
-
- JPanel panel = new JPanel();
- panel.setLayout( new BoxLayout(panel,BoxLayout.Y_AXIS) );
- panel.add(infoField);
- panel.add(field);
- panel.add(button);
- TestingUtil.testGui(panel, -1);
- }
+ Format format = new SimpleDateFormat("dd.MM.yyyy");
+
+ JFormattedTextField field = new JFormattedTextField(format) {
+ @Override
+ public void commitEdit() throws ParseException {
+ infoField.setText(" ");
+ try {
+ super.commitEdit();
+ } catch (Exception err) {
+ // if the given string can not be interpreted
+ // try to complete the input
+ String completedInput = LangUtil
+ .completeEuropeanDateString(getText());
+ infoField.setText(completedInput);
+ setText(completedInput);
+ super.commitEdit();
+ }
+ }
+ };
+ field.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
+ field.setText("dd.MM.yyyy");
+ field.setColumns(10);
+ field.setDocument(new LimitedDocument(10, LimitedDocument.STYLE_DECIMAL));
+ field.select(0, field.getText().length());
+ // field.setFocusLostBehavior( JFormattedTextField.)
+ // field.set
+ // field.setPreferredSize( new Dimension(200,20) );
+
+ JButton button = new JButton("Test");
+
+ JPanel panel = new JPanel();
+ panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+ panel.add(infoField);
+ panel.add(field);
+ panel.add(button);
+ TestingUtil.testGui(panel, 0);
+ }
}
More information about the Schmitzm-commits
mailing list