天道酬勤,学无止境

jspinner

Setting Time Format for jspinner in swings

问题 我正在使用 java swing 应用程序。 在那个应用程序中,我必须花时间从用户那里输入。 我需要暂时制作一个 JSpinner,仅采用 hh:mm am/pm 格式。 我在属性中搜索但无法获得这种格式。 请建议我以 hh:mm am/pm 格式显示时间。 我感谢您提出的所有宝贵建议。 回答1 SpinnerDateModel model = new SpinnerDateModel(); model.setCalendarField(Calendar.MINUTE); spinner= new JSpinner(); spinner.setModel(model); spinner.setEditor(new JSpinner.DateEditor(spinner, "h:mm a")); 回答2 感谢您回答纪尧姆。 做了一个小改动后,你的答案对我有用,即 spinner.setEditor(new JSpinner.DateEditor(spinner, "h:mm a")); 这给了我一个合适的格式。

2022-04-26 11:11:10    分类:技术分享    java   swing   time   jspinner

如何在 JSpinner 中获取所选项目的值?(how can I get the value of a the selected item in a JSpinner?)

问题 我正在制作一个使用最大编号为 30 的 JSpinner 的应用程序,我应该从这个 JSpinner 中选择一个值并将一个字符串粘贴到 JTextField 中,结果将出现在 Textarea 中,当我编译时我有很多关于该方法的问题jSpinner1State,任何人都可以帮助我,因为我不知道我的问题在哪里。 这是我的方法 JSpinner 的代码: jSpinner1.addChangeListener(this); private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) { // TODO add your handling code here: Object sp=jSpinner1.getValue(); int i =Integer.parseInt(sp.toString() ); String targetIP=jTextField1.getText(); try{ jSpinner1StateChanged(evt); String cmd = "tracert -h "+i+ "" +targetIP; Process p = Runtime.getRuntime().exec(cmd); InputStream in = p.getInputStream()

2022-04-02 06:40:40    分类:技术分享    java   swing   jspinner   changelistener

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

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 is very user-friendly. What I would like is a JSlider with two knobs, one for min and one for max. Is

2022-03-23 20:43:39    分类:问答    java   swing   jslider   jspinner   ui-design

How to make a time format in Jspinner?

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.

2022-03-22 09:41:41    分类:问答    java   swing   jspinner

How change format time from jSpinner?

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.updateTask(t1); } catch (SQLException ex) { Logger.getLogger(jTTask.class.getName()).log(Level.SEVERE, null, ex)

2022-03-22 03:21:26    分类:问答    java   swing   jspinner

Java JSpinner.DateEditor working with TimeZone March clock change

I have a problem with the standard JSpinner.DateEditor (as probably does everyone else). When it works with the Java.util.Date class, it only gets a default format from the Locale set on the spinner. It appears to be TimeZone ignorant. When we have a Date that is on the March Clock change day which in the UK has no 2 o'clock - the time jumps from 01:59:59.999 AM to 03:00 AM with day light savings applied. Therefore in the JSpinner.DateEditor I do not want the user to see anything for 02:00 to 02:59:59.999. When the hour is on 1 and they click up, I want to jump to 3 and vice versa. Is it

2022-03-22 03:02:29    分类:问答    java   swing   dst   jspinner