Make JSpinner only read numbers but also detect backspace

you are right JFormattedTextField isn’t correctly implemented to JSpinner, you have implements DocumentFilter for filtering of un_wanted Chars typed from keyboad or pasted from ClipBoard, (thanks to @StanislavL) you have solve by yourself issues with selectAll() on focusGained() wrapped into invokeLater(), example import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; import javax.swing.SwingUtilities; import … Read more

How to rendering fraction in Swing JComponents

On reflection, Unicode fractions among the Latin-1 Supplement and Number Forms offer limited coverage, and fancy equations may be overkill. This example uses HTML in Swing Components. Addendum: The approach shown lends itself fairly well to rendering mixed numbers. For editing, key bindings to + and / could be added for calculator-style input in a … Read more