Skip to content
Browse files

Simple time editor.

  • Loading branch information...
1 parent 5b71876 commit d88bfcc131e4a0634aef4bf72b3bc6f394775d5d @Chrriis committed Feb 1, 2012
View
130 DJSwingSuite-Demo/src/chrriis/dj/swingsuite/demo/DemoExampleDefinitionLoader.java
@@ -1,64 +1,66 @@
-/*
- * Christopher Deckers (chrriis@nextencia.net)
- * http://www.nextencia.net
- *
- * See the file "readme.txt" for information on usage and redistribution of
- * this file, and for a DISCLAIMER OF ALL WARRANTIES.
- */
-package chrriis.dj.swingsuite.demo;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import chrriis.dj.swingsuite.demo.examples.basiccomponents.ComboButtonExample;
-import chrriis.dj.swingsuite.demo.examples.basiccomponents.DragSelectTreeExample;
-import chrriis.dj.swingsuite.demo.examples.basiccomponents.ExtendedLabelExample;
-import chrriis.dj.swingsuite.demo.examples.basiccomponents.LinkExample;
-import chrriis.dj.swingsuite.demo.examples.basiccomponents.TitledSeparatorExample;
-import chrriis.dj.swingsuite.demo.examples.basiccomponents.TriStateCheckBoxExample;
-import chrriis.dj.swingsuite.demo.examples.basiccomponents.WidePopupComboBoxExample;
-import chrriis.dj.swingsuite.demo.examples.entryfields.TextAndNumberFieldsExample;
-import chrriis.dj.swingsuite.demo.examples.entryfields.ValidatorsFormattersAndMasksExample;
-import chrriis.dj.swingsuite.demo.examples.introduction.SwingSuite;
-import chrriis.dj.swingsuite.demo.examples.utilities.AutoScrollExample;
-import chrriis.dj.swingsuite.demo.examples.utilities.LayeredIconExample;
-import chrriis.dj.swingsuite.demo.examples.utilities.RichDragAndDrop;
-import chrriis.dj.swingsuite.demo.examples.utilities.SelectAllOnFocusExample;
-import chrriis.dj.swingsuite.demo.examples.utilities.TableColumnAutoFitExample;
-import chrriis.dj.swingsuite.demo.examples.utilities.WildcardsConversionExample;
-
-/**
- * @author Christopher Deckers
- */
-public class DemoExampleDefinitionLoader {
-
- public static List<ExampleGroup> getExampleGroupList() {
- List<ExampleGroup> exampleGroupList = new ArrayList<ExampleGroup>();
- exampleGroupList.add(new ExampleGroup("Introduction", new Example[] {
- new Example("Swing Suite", SwingSuite.class, "The motivations behind this project.", false),
- }));
- exampleGroupList.add(new ExampleGroup("Basic Components", new Example[] {
- new Example("Combo button", ComboButtonExample.class, "Combo buttons are generally found in tool bars, often to offer a list of choices and optionally a default action.", true),
- new Example("Tri-state check box", TriStateCheckBoxExample.class, "Tri-state check boxes, with advanced capabilities like rolling cycle definition.", true),
- new Example("Link", LinkExample.class, "Users are generally familiar with links: they are simple, intuitive and generally provide some information through tool tips.", true),
- new Example("Extended label", ExtendedLabelExample.class, "A label that allows text selection and is multiline.", true),
- new Example("Wide popup combo box", WidePopupComboBoxExample.class, "Wide popup combo boxes are a solution to the problem of having content that is too long. Such content generally messes up the user interface layout.", true),
- new Example("Drag-select tree", DragSelectTreeExample.class, "A tree where the user can click in the empty area, and drag the mouse over some nodes to select them. Modifiers (control and shift) can add or exclude to the current selection.", true),
- new Example("Titled separator", TitledSeparatorExample.class, "Titled separators are generally more elegant than titled borders and do not require nesting panels.", true),
- }));
- exampleGroupList.add(new ExampleGroup("Entry Fields", new Example[] {
- new Example("Text and Numbers", TextAndNumberFieldsExample.class, "This is a simple example that shows text and number fields.", true),
- new Example("Validators, Formatters, Masks", ValidatorsFormattersAndMasksExample.class, "How to use validators, formatters and masks to control inputs and improve usability.", true),
- }));
- exampleGroupList.add(new ExampleGroup("Utilities", new Example[] {
- new Example("Rich drag and drop", RichDragAndDrop.class, "The rich drag and drop manager allows to create an overlay image when performing a drag and drop operation (available with Java 6+ on systems supporting window alpha transparency).", true),
- new Example("Layered icon", LayeredIconExample.class, "A layered icon is an icon that aggregates icons, which can be at any location within their parent icon. Layered icons even support animated images in their composition.", true),
- new Example("Auto scroll", AutoScrollExample.class, "Enable the auto-scroll feature to simplify scrolling: a click with the middle mouse button then moving the mouse directs scrolling (as seen in web browsers).", true),
- new Example("Table column auto fit", TableColumnAutoFitExample.class, "Auto fit one or all the columns of a table.", true),
- new Example("Select all on focus", SelectAllOnFocusExample.class, "Make a text component select its entire text when it receives the focus. This utility takes care of proper selection in certain cases such as inaccurate click (mouse moves during the click).", true),
- new Example("Wildcards conversion", WildcardsConversionExample.class, "Convert a simple text with wildcards ('*' and '?', generally entered by the user) to a regular expression that can be used to filter/search.", true),
- }));
- return exampleGroupList;
- }
-
-}
+/*
+ * Christopher Deckers (chrriis@nextencia.net)
+ * http://www.nextencia.net
+ *
+ * See the file "readme.txt" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+package chrriis.dj.swingsuite.demo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import chrriis.dj.swingsuite.demo.examples.basiccomponents.ComboButtonExample;
+import chrriis.dj.swingsuite.demo.examples.basiccomponents.DragSelectTreeExample;
+import chrriis.dj.swingsuite.demo.examples.basiccomponents.ExtendedLabelExample;
+import chrriis.dj.swingsuite.demo.examples.basiccomponents.LinkExample;
+import chrriis.dj.swingsuite.demo.examples.basiccomponents.TimeEditorExample;
+import chrriis.dj.swingsuite.demo.examples.basiccomponents.TitledSeparatorExample;
+import chrriis.dj.swingsuite.demo.examples.basiccomponents.TriStateCheckBoxExample;
+import chrriis.dj.swingsuite.demo.examples.basiccomponents.WidePopupComboBoxExample;
+import chrriis.dj.swingsuite.demo.examples.entryfields.TextAndNumberFieldsExample;
+import chrriis.dj.swingsuite.demo.examples.entryfields.ValidatorsFormattersAndMasksExample;
+import chrriis.dj.swingsuite.demo.examples.introduction.SwingSuite;
+import chrriis.dj.swingsuite.demo.examples.utilities.AutoScrollExample;
+import chrriis.dj.swingsuite.demo.examples.utilities.LayeredIconExample;
+import chrriis.dj.swingsuite.demo.examples.utilities.RichDragAndDrop;
+import chrriis.dj.swingsuite.demo.examples.utilities.SelectAllOnFocusExample;
+import chrriis.dj.swingsuite.demo.examples.utilities.TableColumnAutoFitExample;
+import chrriis.dj.swingsuite.demo.examples.utilities.WildcardsConversionExample;
+
+/**
+ * @author Christopher Deckers
+ */
+public class DemoExampleDefinitionLoader {
+
+ public static List<ExampleGroup> getExampleGroupList() {
+ List<ExampleGroup> exampleGroupList = new ArrayList<ExampleGroup>();
+ exampleGroupList.add(new ExampleGroup("Introduction", new Example[] {
+ new Example("Swing Suite", SwingSuite.class, "The motivations behind this project.", false),
+ }));
+ exampleGroupList.add(new ExampleGroup("Basic Components", new Example[] {
+ new Example("Combo button", ComboButtonExample.class, "Combo buttons are generally found in tool bars, often to offer a list of choices and optionally a default action.", true),
+ new Example("Tri-state check box", TriStateCheckBoxExample.class, "Tri-state check boxes, with advanced capabilities like rolling cycle definition.", true),
+ new Example("Link", LinkExample.class, "Users are generally familiar with links: they are simple, intuitive and generally provide some information through tool tips.", true),
+ new Example("Extended label", ExtendedLabelExample.class, "A label that allows text selection and is multiline.", true),
+ new Example("Wide popup combo box", WidePopupComboBoxExample.class, "Wide popup combo boxes are a solution to the problem of having content that is too long. Such content generally messes up the user interface layout.", true),
+ new Example("Drag-select tree", DragSelectTreeExample.class, "A tree where the user can click in the empty area, and drag the mouse over some nodes to select them. Modifiers (control and shift) can add or exclude to the current selection.", true),
+ new Example("Titled separator", TitledSeparatorExample.class, "Titled separators are generally more elegant than titled borders and do not require nesting panels.", true),
+ new Example("Time Editor", TimeEditorExample.class, "Time Editor with different precisions.", true),
+ }));
+ exampleGroupList.add(new ExampleGroup("Entry Fields", new Example[] {
+ new Example("Text and Numbers", TextAndNumberFieldsExample.class, "This is a simple example that shows text and number fields.", true),
+ new Example("Validators, Formatters, Masks", ValidatorsFormattersAndMasksExample.class, "How to use validators, formatters and masks to control inputs and improve usability.", true),
+ }));
+ exampleGroupList.add(new ExampleGroup("Utilities", new Example[] {
+ new Example("Rich drag and drop", RichDragAndDrop.class, "The rich drag and drop manager allows to create an overlay image when performing a drag and drop operation (available with Java 6+ on systems supporting window alpha transparency).", true),
+ new Example("Layered icon", LayeredIconExample.class, "A layered icon is an icon that aggregates icons, which can be at any location within their parent icon. Layered icons even support animated images in their composition.", true),
+ new Example("Auto scroll", AutoScrollExample.class, "Enable the auto-scroll feature to simplify scrolling: a click with the middle mouse button then moving the mouse directs scrolling (as seen in web browsers).", true),
+ new Example("Table column auto fit", TableColumnAutoFitExample.class, "Auto fit one or all the columns of a table.", true),
+ new Example("Select all on focus", SelectAllOnFocusExample.class, "Make a text component select its entire text when it receives the focus. This utility takes care of proper selection in certain cases such as inaccurate click (mouse moves during the click).", true),
+ new Example("Wildcards conversion", WildcardsConversionExample.class, "Convert a simple text with wildcards ('*' and '?', generally entered by the user) to a regular expression that can be used to filter/search.", true),
+ }));
+ return exampleGroupList;
+ }
+
+}
View
66 ...Suite-Demo/src/chrriis/dj/swingsuite/demo/examples/basiccomponents/TimeEditorExample.java
@@ -0,0 +1,66 @@
+/*
+ * Christopher Deckers (chrriis@nextencia.net)
+ * http://www.nextencia.net
+ *
+ * See the file "readme.txt" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+package chrriis.dj.swingsuite.demo.examples.basiccomponents;
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.ImageIcon;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
+import javax.swing.JToolBar;
+import javax.swing.SwingUtilities;
+
+import chrriis.dj.swingsuite.JComboButton;
+import chrriis.dj.swingsuite.JTimeEditor;
+import chrriis.dj.swingsuite.SwingSuiteUtilities;
+
+/**
+ * @author Christopher Deckers
+ */
+public class TimeEditorExample extends JPanel {
+
+ public TimeEditorExample() {
+ super(new BorderLayout(0, 0));
+ JPanel centerPane = new JPanel(new GridBagLayout());
+ Insets insets = new Insets(2, 0, 2, 0);
+ int y = 0;
+ centerPane.add(new JLabel("Time Editor (minutes): "), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0));
+ centerPane.add(new JTimeEditor(JTimeEditor.MINUTE_PRECISION), new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0));
+ centerPane.add(new JLabel("Time Editor (seconds): "), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0));
+ centerPane.add(new JTimeEditor(JTimeEditor.SECOND_PRECISION), new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0));
+ centerPane.add(new JLabel("Time Editor (milliseconds): "), new GridBagConstraints(0, y, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0));
+ centerPane.add(new JTimeEditor(JTimeEditor.MILLISECOND_PRECISION), new GridBagConstraints(1, y++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0));
+ // Rest of the initialisation
+ add(centerPane, BorderLayout.CENTER);
+ }
+
+ /* Standard main method to try that test as a standalone application. */
+ public static void main(String[] args) {
+ SwingSuiteUtilities.setPreferredLookAndFeel();
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ JFrame frame = new JFrame("DJ Swing Suite Test");
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.getContentPane().add(new TimeEditorExample(), BorderLayout.CENTER);
+ frame.setSize(800, 600);
+ frame.setLocationByPlatform(true);
+ frame.setVisible(true);
+ }
+ });
+ }
+
+}
View
61 DJSwingSuite/Release/changelog.txt
@@ -1,31 +1,32 @@
-The DJ project - Swing Suite
-http://djproject.sourceforge.net
-Christopher Deckers (chrriis@nextencia.net)
-Licence terms: LGPL (see licence.txt)
-
----------------------------------- Change log ----------------------------------
-
-* Version 0.9.2 (xxxxxxxxxxxx):
-
-- Wide popup combo boxes allow maximum size to be used instead.
-- JLink fires on mouse release (within the bounds) rather than click.
-- JTriStateCheckBox issue fixed under Windows Vista/Seven.
-- setSelectAllOnFocus now allows dragging to adjust selection.
-- Rich drag and drop using image overlay (on systems supporting it, Java 6+).
-- Combo button do not break on theme update.
-
-
-* Version 0.9.1 (May 10, 2009):
-
-- Text entry fields are implemented with validators, formatters and masks.
-- Number entry fields are implemented using the text entry fields.
-- Combo buttons are implemented.
-- Links are implemented.
-- Tri-state check boxes are added.
-- Wide popup combo boxes are added.
-- Selectable tree is added.
-- Titled separators are implemented.
-- Extended label is added.
-- Layered icon is added.
-- Auto-scroll feature is added.
+The DJ project - Swing Suite
+http://djproject.sourceforge.net
+Christopher Deckers (chrriis@nextencia.net)
+Licence terms: LGPL (see licence.txt)
+
+---------------------------------- Change log ----------------------------------
+
+* Version 0.9.2 (xxxxxxxxxxxx):
+
+- Simple time editor.
+- Wide popup combo boxes allow maximum size to be used instead.
+- JLink fires on mouse release (within the bounds) rather than click.
+- JTriStateCheckBox issue fixed under Windows Vista/Seven.
+- setSelectAllOnFocus now allows dragging to adjust selection.
+- Rich drag and drop using image overlay (on systems supporting it, Java 6+).
+- Combo button do not break on theme update.
+
+
+* Version 0.9.1 (May 10, 2009):
+
+- Text entry fields are implemented with validators, formatters and masks.
+- Number entry fields are implemented using the text entry fields.
+- Combo buttons are implemented.
+- Links are implemented.
+- Tri-state check boxes are added.
+- Wide popup combo boxes are added.
+- Selectable tree is added.
+- Titled separators are implemented.
+- Extended label is added.
+- Layered icon is added.
+- Auto-scroll feature is added.
- Table column auto fit is added.
View
212 DJSwingSuite/src/chrriis/dj/swingsuite/JTimeEditor.java
@@ -0,0 +1,212 @@
+/*
+ * Christopher Deckers (chrriis@nextencia.net)
+ * http://www.nextencia.net
+ *
+ * See the file "readme.txt" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+package chrriis.dj.swingsuite;
+
+import java.awt.BorderLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+import java.util.Arrays;
+import java.util.Calendar;
+
+import javax.swing.BorderFactory;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JSpinner;
+import javax.swing.JTextField;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+/**
+ * A simple time editor.
+ * @author Christopher Deckers
+ */
+public class JTimeEditor extends JPanel {
+
+ public static final int MINUTE_PRECISION = 1;
+ public static final int SECOND_PRECISION = 2;
+ public static final int MILLISECOND_PRECISION = 3;
+
+ public JTimeEditor(int precision) {
+ this(null, precision);
+ }
+
+ private TimeEntryField hourEntryField;
+ private TimeEntryField minuteEntryField;
+ private TimeEntryField secondEntryField;
+ private TimeEntryField millisecondEntryField;
+
+ public JTimeEditor(Calendar calendar, int precision) {
+ super(new BorderLayout());
+ JPanel editorPane = new JPanel(new GridBagLayout());
+ // Hours
+ hourEntryField = createTimeEntryField(2, "00", 24);
+ // setBorder(hourEntryField.getBorder());
+ hourEntryField.setBorder(BorderFactory.createEmptyBorder());
+ editorPane.setBackground(hourEntryField.getBackground());
+ int x = 0;
+ editorPane.add(hourEntryField, new GridBagConstraints(x++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 1));
+ // Minutes
+ editorPane.add(new JLabel(":"), new GridBagConstraints(x++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 1));
+ minuteEntryField = createTimeEntryField(2, "00", 60);
+ minuteEntryField.setBorder(BorderFactory.createEmptyBorder());
+ editorPane.add(minuteEntryField, new GridBagConstraints(x++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 1));
+ if(precision > MINUTE_PRECISION) {
+ // Seconds
+ editorPane.add(new JLabel(":"), new GridBagConstraints(x++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 1));
+ secondEntryField = createTimeEntryField(2, "00", 60);
+ secondEntryField.setBorder(BorderFactory.createEmptyBorder());
+ editorPane.add(secondEntryField, new GridBagConstraints(x++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 1));
+ if(precision > SECOND_PRECISION) {
+ // Milliseconds
+ editorPane.add(new JLabel("."), new GridBagConstraints(x++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 1));
+ millisecondEntryField = createTimeEntryField(3, "000", 1000);
+ millisecondEntryField.setBorder(BorderFactory.createEmptyBorder());
+ editorPane.add(millisecondEntryField, new GridBagConstraints(x++, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 1, 1));
+ }
+ }
+ // Spinner
+ final JSpinner spinner = new JSpinner();
+ spinner.setEditor(editorPane);
+ spinner.getModel().addChangeListener(new ChangeListener() {
+ private int startValue = (Integer)spinner.getModel().getValue();
+ public void stateChanged(ChangeEvent e) {
+ int newValue = (Integer)spinner.getModel().getValue();
+ if(focusedField == null) {
+ focusedField = hourEntryField;
+ }
+ if(newValue > startValue) {
+ focusedField.adjust(1);
+ } else if(newValue < startValue) {
+ focusedField.adjust(-1);
+ }
+ startValue = newValue;
+ }
+ });
+ add(spinner, BorderLayout.CENTER);
+ setTime(calendar);
+ }
+
+ private Calendar calendar;
+
+ /**
+ * Set the time, using the appropriate fields from this calendar.
+ */
+ public void setTime(Calendar calendar) {
+ if(calendar == null) {
+ calendar = Calendar.getInstance();
+ }
+ this.calendar = (Calendar)calendar.clone();
+ hourEntryField.setTimeValue(calendar.get(Calendar.HOUR_OF_DAY));
+ minuteEntryField.setTimeValue(calendar.get(Calendar.MINUTE));
+ if(secondEntryField != null) {
+ secondEntryField.setTimeValue(calendar.get(Calendar.SECOND));
+ if(millisecondEntryField != null) {
+ millisecondEntryField.setTimeValue(calendar.get(Calendar.MILLISECOND));
+ }
+ }
+ }
+
+ /**
+ * Get the time, using the calendar that was used last to populate the field with setting the relevant fields.
+ * @return the time.
+ */
+ public Calendar getTime() {
+ calendar.set(Calendar.HOUR_OF_DAY, hourEntryField.getTimeValue());
+ calendar.set(Calendar.MINUTE, minuteEntryField.getTimeValue());
+ if(secondEntryField != null) {
+ calendar.set(Calendar.SECOND, secondEntryField.getTimeValue());
+ if(millisecondEntryField != null) {
+ calendar.set(Calendar.MILLISECOND, millisecondEntryField.getTimeValue());
+ }
+ }
+ return (Calendar)calendar.clone();
+ }
+
+ private TimeEntryField focusedField;
+
+ private static class TimeEntryField extends JTextEntryField {
+
+ private int maxBound;
+
+ public TimeEntryField(final int fieldLength, String defaultString, final int maxBound) {
+ super(defaultString, fieldLength);
+ this.maxBound = maxBound;
+ setHorizontalAlignment(JTextField.RIGHT);
+ setValidator(new TextEntryValidator() {
+ @Override
+ public boolean isTextAllowed(JTextEntryField textEntryField, String text) {
+ if(text.length() > fieldLength) {
+ return false;
+ }
+ if(text.length() == 0) {
+ return true;
+ }
+ int hour;
+ try {
+ hour = Integer.parseInt(text);
+ } catch(NumberFormatException e) {
+ return false;
+ }
+ return hour >= 0 && hour < maxBound;
+ }
+ });
+ }
+
+ public void adjust(int count) {
+ int value;
+ try {
+ value = Integer.parseInt(getText());
+ } catch(NumberFormatException e) {
+ value = 0;
+ }
+ value += count;
+ setTimeValue(value);
+ selectAll();
+ }
+
+ public int getTimeValue() {
+ try {
+ return Integer.parseInt(getText());
+ } catch(NumberFormatException e) {
+ return 0;
+ }
+ }
+
+ public void setTimeValue(int value) {
+ value = ((value % maxBound) + maxBound) % maxBound;
+ int columns = getColumns();
+ String sValue = String.valueOf(value);
+ char[] chars = new char[columns - sValue.length()];
+ Arrays.fill(chars, '0');
+ setText(new String(chars) + sValue);
+ }
+
+ }
+
+ private TimeEntryField createTimeEntryField(final int fieldLength, String defaultString, final int maxBound) {
+ final TimeEntryField timeEntryField = new TimeEntryField(fieldLength, defaultString, maxBound);
+ if(focusedField == null) {
+ focusedField = timeEntryField;
+ }
+ timeEntryField.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ focusedField = timeEntryField;
+ }
+ @Override
+ public void focusLost(FocusEvent e) {
+ timeEntryField.setTimeValue(timeEntryField.getTimeValue());
+ }
+ });
+ return timeEntryField;
+ }
+
+}

0 comments on commit d88bfcc

Please sign in to comment.
Something went wrong with that request. Please try again.