jspinner

Accept measuring units in JSpinner as input

佐手、 提交于 2020-06-28 02:42:32
问题 I have a numeric JSpinner which accepts values in a specific measuring unit. Now, I'd like to have a special JSpinner behavior: If a user enters a numeric value and appends a specific measuring unit string (e.g. "inch", "pica") then the entered numeric value must be converted into another value (depending on the unit string). This conversion must occur when user leaves the spinner field (focus lost) or if a "commitEdit" occurs in any way. I've tried several variants: Custom document filter,

How can I disable the textfield area of JSpinner

空扰寡人 提交于 2020-01-17 12:26:32
问题 I'm currently having a problem in netbeans where my JSpinner is allowing you to type in the textfield while I only want the arrows to be used. Is there a way to disable the input of text via properties or some other way? Thanks 回答1: Disable the JSpinner's JTextField's using the following: ((JSpinner.DefaultEditor) yourSpinner.getEditor()).getTextField().setEditable(false); 回答2: You can try it like this JSpinner.DefaultEditor editor = ( JSpinner.DefaultEditor ) component.getEditor(); editor

How can I disable the textfield area of JSpinner

≯℡__Kan透↙ 提交于 2020-01-17 12:24:25
问题 I'm currently having a problem in netbeans where my JSpinner is allowing you to type in the textfield while I only want the arrows to be used. Is there a way to disable the input of text via properties or some other way? Thanks 回答1: Disable the JSpinner's JTextField's using the following: ((JSpinner.DefaultEditor) yourSpinner.getEditor()).getTextField().setEditable(false); 回答2: You can try it like this JSpinner.DefaultEditor editor = ( JSpinner.DefaultEditor ) component.getEditor(); editor

Some hints for hex Jspinner ? I s the approach correct

余生长醉 提交于 2020-01-13 20:21:02
问题 i want t make a JSpinner to spin hex values from 0x0000000 to 0xffffffff . Tried extending the abstractspinner model but failed . Is my approach correct and is there any other solution.some help would be really usefull 回答1: Here is one way which might help you import java.awt.BorderLayout; import java.text.ParseException; import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; import javax.swing.JFormattedTextField

Some hints for hex Jspinner ? I s the approach correct

感情迁移 提交于 2020-01-13 20:19:51
问题 i want t make a JSpinner to spin hex values from 0x0000000 to 0xffffffff . Tried extending the abstractspinner model but failed . Is my approach correct and is there any other solution.some help would be really usefull 回答1: Here is one way which might help you import java.awt.BorderLayout; import java.text.ParseException; import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; import javax.swing.JFormattedTextField

JSpinner and double with dot or comma as separator

你说的曾经没有我的故事 提交于 2020-01-13 10:50:08
问题 I would like to allow both "comma" and "dot" as separator in double. I could use replace method in string to get only one separator, but problem is that double value is value of JSpinner and I was not able to find any method to allow both separators. If I set locale for example to French only one separator is allowed. 回答1: Just use a custom formatter for the JFormattedTextField of the DefaultEditor of the JSpinner , like the code below: import java.text.ParseException; import javax.swing

jSpinner time picker model editing

耗尽温柔 提交于 2020-01-13 03:45:12
问题 I have jSpinner using for time picking. Problem 1: User can edited hour minutes and second seperator ":" and can write extra digits like "123" Problem 2: model get always current time. I want "00:00:00" When i write this in code instead "hh:mm:ss" user can't edit the values. My Code is; spinner1 = new javax.swing.JSpinner(); SpinnerDateModel spinnermodel = new SpinnerDateModel(); spinnermodel.setCalendarField(Calendar.MINUTE); spinner1 .setModel(spinnermodel); spinner1 .setEditor(new JSpinner

HOWTO Select JSpinner date field when JSpinner gets focus

戏子无情 提交于 2020-01-06 11:47:13
问题 I am trying to make a JSpinner (containing a minute/second timer) work for a bunch of set-in-their-ways folks who don't care beans about the mouse but want every keystroke to do exactly what they are used to. It works almost as I'd like it to but the last mile is the hardest. What this means in practice is that the spinner should look and behave when one of its text fields gains focus exactly as it looks and behaves after the user has pressed an arrow key from one of those fields. Spinner is

JSpinner time range + HH:MM format

為{幸葍}努か 提交于 2020-01-04 06:54:21
问题 I'm trying to set a JSpinner to run from hour 00:00 to 02:00. So I built this code: import javax.swing.JSpinner; import javax.swing.SpinnerDateModel; public class HourSpinner2 extends javax.swing.JFrame { javax.swing.JSpinner jSpinner2; public HourSpinner2() { jSpinner2 = new javax.swing.JSpinner(); add(jSpinner2); // Option 1 : set range jSpinner2.setModel(new SpinnerDateModel(new java.util.Date(1388498400000L), new java.util.Date(1388484000000L), new java.util.Date(1388505600000L), java

JSpinner time range + HH:MM format

…衆ロ難τιáo~ 提交于 2020-01-04 06:54:15
问题 I'm trying to set a JSpinner to run from hour 00:00 to 02:00. So I built this code: import javax.swing.JSpinner; import javax.swing.SpinnerDateModel; public class HourSpinner2 extends javax.swing.JFrame { javax.swing.JSpinner jSpinner2; public HourSpinner2() { jSpinner2 = new javax.swing.JSpinner(); add(jSpinner2); // Option 1 : set range jSpinner2.setModel(new SpinnerDateModel(new java.util.Date(1388498400000L), new java.util.Date(1388484000000L), new java.util.Date(1388505600000L), java