jspinner

How to undo changes on JSpinner?

I need to validate the user input of a JSpinner, and if invalid, I need to undo (rollback) the value change. What is the best way to do it? ...

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 actionPerformed( java.awt.event.ActionEvent evt ) { // Do stuff... } ...

Zero-padding a spinner in Java

How do you add zero padding to a JSpinner? Since the spinner creates the JFormattedTextField itself, I can't just pass the format into the JFormattedTextField constructor. Isn't there a way to set the formatting on an existing JFormattedTextField? What I want: value = 37, editor = "0037" UPDATE: I have tried this as suggested: JSpin...

Custom JSpinner

I have created the following class that extends JSpinner to iterate over dd/mm/yyy values. public class DateSpinner extends JSpinner{ Calendar calendar = new GregorianCalendar(); public DateSpinner(){ super(); calendar.add(Calendar.DAY_OF_YEAR, 1); Date now = calendar.getTime(); calendar.add(Calendar.DAY_OF_...

JSpinner editor locale

I'm creating a JSpinner and setting a NumberEditor with a custom format. But no matter what I do the format uses "." instead of ",", not according to my locale (pt_BR). priceSpinner = new JSpinner(); priceSpinner.setEditor(new JSpinner.NumberEditor(priceSpinner, "0.00")); Is it possible to use "," instead of "." as a decimal separato...

JSpinner Date Editor in Buddhist Calendar

Is there a way to use JSpinner.DateEditor with a Buddhist Calendar? When I change my locale to "th", "TH" and recreate my calendars they are indeed Buddhist Calendars. However, the JSpinners are not updated. Here is some sample code: Locale locale = new Locale("th", "TH"); Locale.setDefault(locale); // Reinitializing calendars with n...

Java Swing - Problem in JSpinner

I am developing a Java Desktop Application and designing the GUI with the help of Netbeans Swing GUI builder. I want to use a JSpinner in my app. I have dragged and dropped it to a JPanel. Now, I want to set its two properties: First, It should display numbers in the range of 1 to 50. Neither less than 1 nor greater than 50. How can I...

Java JSpinner Looks Ugly

GUI i am trying to use JSpinner but as you can see from the attached image that it looks bad. i am on windows 7. i was wondering if anyone knows how to make it look good? just for clarity. bad means the edges dont line up and good means the spin control edges line up correctly. thank you. EDIT: maybe there is no cure for this? becau...

How to set jspinner as non editable?

I am creating time picker using the spinner.In that the text inside the spinner is editable.But i want to set the spinner as non editable.Because is there chance to give invalid value.Can any one help me.? ...

Java JSpinner Prevent Letter Insertion

A JSpinner is used to store a number in my application (with a SpinnerNumberModel). As expected, the spinner doesn't allow invalid characters (letters, symbols, etc.) to be stored. However, those characters do appear in the spinner component when I type them in. As soon as I switch the focus to another component, they disappear. Is the...

How do I know if increment/decrement on JSpinner is pressed?

I have a few JSpinners and they are numeric values starting at 10 and can be incremented until 99. In my program the user has 15 points to disperse evenly across 6 skills. Every JSpinner has an EventListener to detect if its pressed, but more specifically I need to know which button was pressed so I know which action to take. They dont...

StackOverFlowError and Values equalling crazy numbers.

I have this code: Integer it = (Integer)(strengthSpinner.getValue()); The value of the spinner there is equal to: SpinnerModel one = new SpinnerNumberModel(10, 10, 99, 1); Every time the source is returned as the JSpinner a pointsRemaining--; executes. If I get the value of the Spinner AFTER the value inside has been messed with ...

JSpinner SpinnerDateModel question

Hi, I'm trying to create a JSpinner to enable the user to pick a Date. I want there to be a lower date limit and an upper date limit. I also want the initial value to be the lower date limit. Unfortunately, My problem is that it won't let me use the lower limit as the initial value (the JSpinner simply becomes unresponsive). Here is my c...

Use JSpinner like JTable cell editor

Hi all, 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 i can change the value with up-down arrows(of keyboard). So, what i have to do t...

Setting Time Format for jspinner in swings

Hi All, I am working in a java swing application. In that application i have to take time input from user. I need to make a JSpinner for the time, only in the hh:mm am/pm format. i searched in properties but could not get this format. Please suggest me some way to display time in hh:mm am/pm format. I thank to all your valuable suggest...

Java KeyListener not firing on JSpinner

Hi, 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 user changes any text in the JSpinner instead of using the Calendar control or the JSpinn...

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 only spins when "yyyy" is added to the format. How can I get around this? import java.awt....

JSpinner Value change Events

How to make the update immediately when the jSpinner value was changed. ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { jLabel.setText(e.getSource()); } }; spinner1.addChangeListener(listener); The code above doesnt change the label text automatically, it required you to click again ...