Questions tagged [jspinner]

JSpinner is a class in Java's Swing package. It is a single-line input field that lets the user select a number or an object value from an ordered sequence.

From javadoc:

Spinners typically provide a pair of tiny arrow buttons for stepping through the elements of the sequence. The keyboard up/down arrow keys also cycle through the elements. The user may also be allowed to type a (legal) value directly into the spinner. Although combo boxes provide similar functionality, spinners are sometimes preferred because they don't require a drop down list that can obscure important data.

A JSpinner's sequence value is defined by its SpinnerModel. The model can be specified as a constructor argument and changed with the model property. SpinnerModel classes for some common types are provided: SpinnerListModel, SpinnerNumberModel, and SpinnerDateModel.

357 questions
6
votes
2 answers

How do I disable keyboard and mouse entry for a JSpinner?

When I try to make a JSpinner un-editable by keyboard or mouse like this: ((DefaultEditor) mySpinner.getEditor()).getTextField().setEditable(false); mySpinner.setEnabled(false); It disables any keyboard entry and pasting, but I can still click the…
Brian
  • 2,375
  • 4
  • 24
  • 35
6
votes
3 answers

JSpinner.DateEditor must include year even though start and end is the same year

I have a JSpinner using a SpinnerDateModel which has a start at Jan 1, 2010 00:00:00.000 the end date is Jan 1, 2010 00:12:34.217. I would like my JSpinner.DateEditor to use the format HH:mm:ss.SSS but the spinner doesn't spin with this format. It…
initialZero
  • 6,197
  • 9
  • 29
  • 38
6
votes
1 answer

JSpinner and double with dot or comma as separator

I would like to allow both "comma" and "dot" as separator in double. I could use replace method in string to get only one separator, but problem is that double value is value of JSpinner and I was not able to find any method to allow both…
Ľubomír
  • 1,075
  • 1
  • 12
  • 20
6
votes
1 answer

how to center text of a JSpinner

My question is self explanatory: how to center the text of a JSpinner? the methode setHorizontalAligment is not there. I also tried setAlignmentX, still nothing... Any help would be appreciated c:
user3342795
  • 105
  • 3
  • 6
6
votes
1 answer

JSpinner in JOptionPane?

I need to put a JSpinner in a JOptionPane. Here is what I've tried: import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; public static void main(String[] args) { …
David
  • 15,652
  • 26
  • 115
  • 156
5
votes
1 answer

Odd SpinnerNumberModel behavior in Java

I'm trying to setup a JSpinner using a SpinnerNumberModel with value = 0.0005, min = 0.0, max = 1.0, and step size = 0.0005. However, when I create a spinner with these parameters I observe very strange behavior. Rather than starting at 0.0005 and…
David Thielke
  • 197
  • 1
  • 8
5
votes
1 answer

Is it possible to change the background of a jspinner using the nimbus laf?

I'm fairly confident that I have done my research before coming to you for help, but it's possible I have overlooked something. I'm writing a java UI using the Nimbus l-a-f. I wish to change the background colour of a JSpinner on state-change, ie,…
Daryl
  • 203
  • 1
  • 2
  • 8
5
votes
3 answers

Java KeyListener not firing on JSpinner

have tried a few different approaches to this but with no success so far. Just wondered if I'm missing anything. I have a JSpinner which is a component of a DateSelector widget alongside a Calendar. I am trying to fire a validation method if the…
Frank
  • 1,110
  • 2
  • 16
  • 21
5
votes
3 answers

Getting ENTER to work with a JSpinner the way it does with a JTextField

First, to make my job explaining a bit easier, here's some of my code: JSpinner spin = new JSpinner(); JFormattedTextField text = getTextField(spin); text.addActionListener(new java.awt.event.ActionListener() { public void…
Daddy Warbox
  • 4,500
  • 9
  • 41
  • 56
4
votes
2 answers

Java: how do I make JSpinner show value with some offset

In my application some values internally have their range from 0. But user should see this range starting from 1. I thought it would be appropriate to move this offseting stuff into presentation. In this case it is JSpinner component. So that I…
Boris Mikhaylov
  • 329
  • 1
  • 12
4
votes
2 answers

Use JSpinner like JTable cell editor

i'm using a JSpinner like a table cell editor, i have one annoying problem: The cell remains in NON-editable mode until i click into it, for NON-editable i mean that i can't write into it(it has not focus so it doesn't accept inputs keyboard) but…
blow
  • 12,811
  • 24
  • 75
  • 112
4
votes
3 answers

How to convert double to object?

I am writing part of my program which read data from a txt file. I have problem when I want to set value of JSpinner by setValue(object). My data is double so I need to convert it to object, but how? LoadData open = new…
Xalion
  • 623
  • 9
  • 27
4
votes
2 answers

Multiple JSpinners Initialized differently

I have 2 JSpinners in my application , I set the model , editor , number format for both of them. However when I run the application the second one doesn't show the fractional part initially. This Looks like focusing issue. So first one…
mussdroid
  • 732
  • 1
  • 9
  • 22
4
votes
2 answers

jSpinner time picker model editing

I have jSpinner using for time picking. Problem 1: User can edited hour minutes and second seperator ":" and can write extra digits like "123" Problem 2: model get always current time. I want "00:00:00" When i write this in code instead "hh:mm:ss"…
Black White
  • 700
  • 3
  • 11
  • 31
4
votes
1 answer

JSpinner with custom UI

I am developing swing-base application with custom design. One of the task - customize spinner control. I want to achieve something like this : My main problem is that spinner controls overlap it's border : Code that creates spinner: public…
Valerii Rusakov
  • 1,091
  • 2
  • 11
  • 22
1
2
3
23 24