jspinner

How to specify a range of valid values in a Java GUI

一世执手 提交于 2019-12-11 16:47:26
问题 I am creating an IMDB application which displays and organizes movies found on you computer (by looking up the metadata via an IMDB API). In my search panel I want to give the user the option of looking for movies that were released in a specific range of years (e.g. between 1990 and 2005). Currently I use for this two JSpinners, one for the minimum year and one for the maximum year and use cross validation to check whether maxYear >= minYear && minYear <= maxYear However I don't think this

How to get Date from my JSpinner?

落花浮王杯 提交于 2019-12-11 12:06:41
问题 this is the code of the Spinner Hini = new javax.swing.JSpinner(); Date date = new Date(); SpinnerDateModel sm = new SpinnerDateModel(date, null, null, Calendar.MINUTE); JSpinner Hini = new JSpinner(sm); JSpinner.DateEditor de = new JSpinner.DateEditor(Hini, "hh:mm a"); de.getTextField().setEditable( true ); Hini.setEditor(de); And this is how i want it to get the values, but it always shows "00:00" `SimpleDateFormat formater = new SimpleDateFormat("HH/mm"); String spinnerValue = formater

Avoiding JSpinner to take letters

点点圈 提交于 2019-12-11 10:42:41
问题 I have a jSpinner with a SpinnerNumberModel like this: spinnerModelFix = new SpinnerNumberModel(0, 0, 65535, 1); JSpinner fixedValueSpinner = new JSpinner(spinnerModelFix); I just want to show Integers in the spinner, so that if the user insert letters they aren't shown. I thought I should extends SpinnerNumberModel and override the fireStateChanged() method... But I'm not sure what I need to do in that method. Can anyone give me some hint? 回答1: yes is possible and workaround is quite simple,

How to set value of JSpinner from string?

 ̄綄美尐妖づ 提交于 2019-12-11 10:40:03
问题 I currently am using a JSpinner to set a time value which is then updated to my database as a varchar e.g. 12:00:00 AM. However in another form I would like to retrieve this time that was added into my database into the JSpinner in my update form. The update form is for the user to update the time that they have selected before (e.g. 12:00:00 AM like stated above). Right now the default time value is the current time. I tried to use the .setValue() method but it is an illegal value as my

Set step for a DateEditor in a JSpinner

巧了我就是萌 提交于 2019-12-11 10:12:39
问题 How can a step be specified for JSpinner? (for example of 10 minutes instead of 1) There is a model that allow select step size for numbers SpinnerNumberModel(value, min, max, step); but how to set it for Dates? This code JSpinner timeSpinner = new JSpinner( new SpinnerDateModel() ); DateEditor timeEditor = new DateEditor(timeSpinner, "HH:mm:ss"); timeSpinner.setEditor(timeEditor); timeSpinner.setValue(new Date()); // will only show the current time (From this answer Is there any good and

JSpinner with long values

隐身守侯 提交于 2019-12-11 09:34:54
问题 I am in need of a JSpinner that can handle long, but JSpinner only handles double and int. I did see an answer that used double to simulate a long, but I need to be able to exactly represent each value of long. It is a program that works with each of the 64 bits, so double and int will not do. Is it possible to have a JSpinner use BigInteger as the data type, or would I be better off just making designing my own JSpinner using a JPanel holding a JTextField and two JButtons specifically to

Getting the value from JSpinner (SWING)

情到浓时终转凉″ 提交于 2019-12-11 03:29:15
问题 I need to get value from JSpinner. private JSpinner[] timeSpinner; private SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); Date time = new Date(); try { time = format.parse(timeSpinner[i].getValue().toString()); } catch (ParseException e) { e.printStackTrace(); } data[i] = time.toString(); System.out.println(data[i]); The error message: java.text.ParseException: Unparseable date: "Thu Jan 01 01:05:00 CET 1970" 回答1: The SimpleDateFormat you are creating has a different format from

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

走远了吗. 提交于 2019-12-10 13:27:48
问题 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 up/down buttons and change the value. How do I disable the up/down buttons? 回答1: If the spinner uses a JSpinner.DefaultEditor or its subclass, then the following code works (keyboard navigation disabled, spinner buttons do not work, yet it is

How to convert double to object?

不想你离开。 提交于 2019-12-07 07:49:34
问题 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 LoadData(); data.setFz(open.giveAwayData()); spinner_1.setValue(data.getFz()); // Fz is double 回答1: Try casting it to Double (with capital): spinner_1.setValue((Double) data.getFz()); 回答2: Use Double.valueOf(data.getFz()) . An explanation of the differences between primitives

how to set jSpinner default value?

為{幸葍}努か 提交于 2019-12-06 14:24:34
问题 I'm using a jSpinner to set the time with format "HH:MM" and it works fine. My problem is I want to set my jSpinner to "00:00" when the window is activated, and once jSpinner is clicked I want the value to be changed to the "HH:MM" format. And I can't do it myself, the jSpinner value doesn't change it is still "00:00". Please help me. Thank you in advance. 回答1: Assuming that your are using a SpinnerDateModel , then the value that the JSpinner is managing is java.util.Date . You need to create