jspinner

JSpinner giving old values

…衆ロ難τιáo~ 提交于 2019-12-30 12:51:12
问题 I am using couple of JSpinners in my project who display the hour and minutes. When the JSpinner is incremented or decremented i have to save the value to the database. But the problem is that the JSpinners are giving me old values. eg- If the time displayed is 09:30 and i increment the time to 10:30 , I am getting 09:30 as the returned value. I am using following code UPDATED SSCCE package spinnerupdation; import java.awt.Container; import java.awt.FlowLayout; import java.text

How change format time from jSpinner?

梦想的初衷 提交于 2019-12-24 14:14:35
问题 I use a jSpinner to choose and save time. I want enter the start time for a task in the database. But the format that saves the database is this: Tue Apr 15 17:24:56 BST 2014 I want in HH:mm. This is the code I use to write the data in the database: public void UpdateTask() { try { Task t1 = new Task(); t1.setIdTask(jTIdTask.getText()); t1.setDate(jTDate.getText()); ----> t1.setHourBegin(jSpinner2.getValue().toString()); // This is what I need change TaskDao dao = new TaskDao(); dao

How to make a time format in Jspinner?

天涯浪子 提交于 2019-12-24 06:42:02
问题 How to make a time format like this hourhour:minuteminute:secondsecond,milisecondmilisecondmilisecond using only one Jspinner when I make this spinner using visual GUI of NET beans. 回答1: You need to use both, SpinnerDateModel and JSpinner.DateEditor with the correct date format pattern: public class JSpinnerDateFormat extends JFrame { public JSpinnerDateFormat() { super("JSpinner Date Format"); JSpinner spinner = new JSpinner(); spinner.setModel(new SpinnerDateModel()); spinner.setEditor(new

JSpinner: autoselect onFocus

南楼画角 提交于 2019-12-24 03:13:08
问题 I want to implement autoselect when a user tabs through the JTextFields and JSpinners in my forms. For this I am using this Listener: public class AutoSelect implements FocusListener { @Override public void focusGained(final FocusEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (e.getSource() instanceof JTextField) { try { JTextField t = (JTextField) e.getComponent(); t.selectAll(); } catch (ClassCastException ex) { // } }else if (e.getSource()

Finding the cursor text position in JTextField

蹲街弑〆低调 提交于 2019-12-23 07:58:08
问题 Is there a method to return the position of the character in the JTextField. What I mean by that is if I have a JTextField with some values in it. For example, the field contains value ABCDEFJ. The user decides to put the cursor right after the character 'C' to enter a new value. Is there a method to get position where he enters the new character. In this example, that would return a 3. 回答1: JTextField.getCaretPosition() JTextField.setCaretPosition(int pos) 回答2: Try getting use of

Use JSpinner like JTable cell editor

蓝咒 提交于 2019-12-21 05:40:59
问题 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 to focus my table cell as soon as i press a key when it is selected? Except for that problem my SpinnerEditor class works quite well. Thanks all. 回答1: Here's a complete

how can I get the value of a the selected item in a JSpinner?

这一生的挚爱 提交于 2019-12-21 02:46:06
问题 I'm making an application that uses a JSpinner with a max number 30,I should choose a value from this JSpinner and tape a String to the JTextField and the result will appear in the Textarea,when I compile I have many problems concerning the method jSpinner1State,can any one help me because I don't know where is my problem. This is my code of the method JSpinner: jSpinner1.addChangeListener(this); private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) { // TODO add your handling

Can't put Double number in BigDecimal variable

好久不见. 提交于 2019-12-20 06:39:57
问题 I'm using a Double variable which holds the Item price. That variable is stored in postgresql database under a column of money type. I use setBigDecimal(position,value) SQL function.In other part, i'm using a JSpinner as input. Double current = 0.0; Double min = (double) Integer.MIN_VALUE; Double max = (double) Integer.MAX_VALUE; Double step = 0.1; JSpinner priceSpinner = new JSpinner(new SpinnerNumberModel(current, min, max, step)); When the user clicks on a button, I get the value entred by

JSpinner editor locale

谁都会走 提交于 2019-12-20 06:20:21
问题 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 separator? 回答1: By specifying a custom format pattern you are telling the JRE to ignore your locale and use that specific format. If you are simply after a spinner for

Problems using SimpleDateFormat

纵然是瞬间 提交于 2019-12-20 02:22:07
问题 Apparently, I'm missing something fundamental. I'm having a problem with formatting the value of a jspinner. I've tried a couple different ways and keep receiving an error, didn't keep track of them, other than it has to do with how I'm trying to grab the value from jspinner. Here is the spinner code: //setup date format for both spinners SimpleDateFormat datePattern = new SimpleDateFormat("MM/dd/yyyy"); JSpinner dateFrom = new JSpinner(new SpinnerDateModel()); dateFrom.setEditor(new JSpinner