branch feature/3833 created (now 504bae5)
This is an automated email from the git hooks/post-receive script. New change to branch feature/3833 in repository jaxx. See http://git.nuiton.org/jaxx.git at 504bae5 [Simple Time Editor] When the user types 2 digits in the hour field, automatically fous the minute field (fixes #3833) This branch includes the following new commits: new 504bae5 [Simple Time Editor] When the user types 2 digits in the hour field, automatically fous the minute field (fixes #3833) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 504bae5de87cceb16e813a35ec486d507779f641 Author: Kevin Morin <morin@codelutin.com> Date: Wed Dec 23 19:17:22 2015 +0100 [Simple Time Editor] When the user types 2 digits in the hour field, automatically fous the minute field (fixes #3833) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/3833 in repository jaxx. See http://git.nuiton.org/jaxx.git commit 504bae5de87cceb16e813a35ec486d507779f641 Author: Kevin Morin <morin@codelutin.com> Date: Wed Dec 23 19:17:22 2015 +0100 [Simple Time Editor] When the user types 2 digits in the hour field, automatically fous the minute field (fixes #3833) --- .../runtime/swing/editor/SimpleTimeEditorHandler.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/SimpleTimeEditorHandler.java b/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/SimpleTimeEditorHandler.java index 65fe1d7..0e851a3 100644 --- a/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/SimpleTimeEditorHandler.java +++ b/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/SimpleTimeEditorHandler.java @@ -26,8 +26,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.beans.BeanUtil; +import javax.swing.JFormattedTextField; import javax.swing.JSpinner; import javax.swing.SpinnerDateModel; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.lang.reflect.Method; @@ -74,6 +77,22 @@ public class SimpleTimeEditorHandler { editor.getMinute().setEditor(new JSpinner.DateEditor(editor.getMinute(), "mm")); // editor.getHour().setEditor(new JSpinner.DateEditor(editor.getHour(), "HH")); + // listen to the typed text and automatically focus the minute when the user typed the hour + JSpinner.DefaultEditor hourEditor = (JSpinner.DefaultEditor) editor.getHour().getEditor(); + hourEditor.getTextField().addKeyListener(new KeyAdapter() { + + @Override + public void keyReleased(KeyEvent e) { + JFormattedTextField source = (JFormattedTextField) e.getSource(); + String text = source.getText(); + + // if the user typed 2 digits or if he typed an hour which cannot be the tens digit, + // then transfer the focus to the minute editor (cf #3833) + if (text.length() >= 2 || !text.equals("0") && !text.equals("1") && !text.equals("2")) { + source.transferFocus(); + } + } + }); // TuttiUIUtil.autoSelectOnFocus(minuteEditor.getTextField()); // JSpinner.NumberEditor hourEditor = (JSpinner.NumberEditor) editor.getHour().getEditor(); -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm