jspinner

A JSpinner with min and max buttons

我们两清 提交于 2019-12-02 09:54:23
问题 I'm looking for a JSpinner-like component that would provide built-in buttons that would immediately set the spinner value to the minimum or the maximum of the jspinner model. Before implementing this myself, I thought that somebody might have done it before, though my google searches on the topic were not successful. Is there such a component out there, or should I code it myself ? Thanks for your help. 回答1: I can't think of any component that would do it out of the box. But basically, a

How to check manual edits on a JSpinner field using DefaultEditor approach

◇◆丶佛笑我妖孽 提交于 2019-12-02 09:52:04
I am adapting code from here: Value Change Listener to JTextField EDIT 2 The following code gives me an infinite loop of dialogs when I press the up spinner arrow: STRING: STRING: 10 VALS: 10 STRING: STRING: 10 VALS: 10 STRING: STRING: 10 VALS: 10 ..... Warning you will need to use taskmanager to kill it. public static void main(String[] args) { // TODO Auto-generated method stub JFrame F = new JFrame(); F.setVisible(true); JPanel p = new JPanel(); final JSpinner spin2 = new JSpinner(); spin2.setModel(new SpinnerNumberModel(10, 10, 100, 1)); JComponent comp = spin2.getEditor();

Can't put Double number in BigDecimal variable

北城以北 提交于 2019-12-02 08:35:22
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 the user and put it in the database via SQL query. insertStmt.setBigDecimal(position,BigDecimal

JSpinner exclusively for time

浪尽此生 提交于 2019-12-02 02:21:35
I am using a JSpinner to input time; however when I use the getValue method I obtain the time on January 1st 1970, as that is the default date start. How can I get the time, and time alone? I am not interested in the date NB: I have already made use of a dateEditor. Perhaps my JSpinnerDateModel is inappropriate? You could create a JSpinner instance and have it format a date as a time, and then just extract the time at the end: JSpinner jSpinner1 = new JSpinner(); Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date(0)); Date earliestDate = calendar.getTime(); calendar.add

JSpinner exclusively for time

a 夏天 提交于 2019-12-02 01:49:29
问题 I am using a JSpinner to input time; however when I use the getValue method I obtain the time on January 1st 1970, as that is the default date start. How can I get the time, and time alone? I am not interested in the date NB: I have already made use of a dateEditor. Perhaps my JSpinnerDateModel is inappropriate? 回答1: You could create a JSpinner instance and have it format a date as a time, and then just extract the time at the end: JSpinner jSpinner1 = new JSpinner(); Calendar calendar =

Problems using SimpleDateFormat

你离开我真会死。 提交于 2019-12-01 21:35:29
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.DateEditor(dateFrom, datePattern.toPattern())); JPanel dateFromPanel = new JPanel(new GridLayout());

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

你离开我真会死。 提交于 2019-12-01 17:23:16
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.GridLayout; import java.util.*; import javax.swing.*; public class T extends JPanel { public T() { super(new GridLayout(2, 2)); init(); } private void init() { Calendar start = GregorianCalendar.getInstance(); Calendar end = GregorianCalendar.getInstance();

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

青春壹個敷衍的年華 提交于 2019-12-01 16:44:58
问题 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.GridLayout; import java.util.*; import javax.swing.*; public class T extends JPanel { public T() { super(new GridLayout(2, 2)); init(); } private void init() {

JSpinner giving old values

北城以北 提交于 2019-12-01 12:50:49
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.SimpleDateFormat; import java.util.Calendar; import javax.swing.JFormattedTextField; import javax.swing.JFrame;

Make JSpinner Select Text When Focused

99封情书 提交于 2019-12-01 03:40:59
I would like to change the behavior of a JSpinner so that when you click on the text, it selects it. This makes it easier to replace the field with the value that you want. Unfortunately, I can't get the behavior to work and instead, it just inserts the cursor in the text without selecting what is already there. I have tried adding a focus Listener to both the JSpinner itself and the text area itself, via ((DefaultEditor) this.getEditor()).getTextField() , yet neither of these seem to have the intended effect. My code (for the JSpinner itself) is as follows: spinner.addFocusListener(new