/* * [LZNumberEditor.java] * * Summary: Left zero NumberEditor for a JSpinner. * * Copyright: (c) 2011-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2011-02-26 initial version, for DateSpinner */ package com.mindprod.spinner; import javax.swing.JFormattedTextField; import javax.swing.JSpinner; /** * Left zero NumberEditor for a JSpinner. *

* Works with Integer or Long unsigned values in the JSpinnerModel. *

* Based on Thomas Fritsch's version posted in comp.lang.java.gui. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2011-02-26 initial version, for DateSpinner * @since 2011-02-26 */ public final class LZNumberEditor extends JSpinner.NumberEditor { /** * constructor * * @param spinner JSpinner this editor is attached to. * @param width how many hex chars wide the field is */ public LZNumberEditor( JSpinner spinner, int width ) { super( spinner ); JFormattedTextField ftf = getTextField(); ftf.setEditable( true ); ftf.setFormatterFactory( new LZNumberFormatterFactory( width ) ); } }