Re: TextField Increment/Decrement Buttons
- From: IchBin <weconsul@xxxxxxx>
- Date: Sun, 29 Jan 2006 08:32:52 -0500
Martijn Mulder wrote:
This is very nice. Thank you! JSpinner is just what I was looking for and with your example and with the specs from internet I'll find out how to use it. JSpinner rules :-)
"IchBin" <weconsul@xxxxxxx> schreef in bericht news:D_KdnbQSY_D5X0beUSdV9g@xxxxxxxxxxMartijn Mulder wrote:I did not know that you *only* look at the "Almanac" to see what objects\classes java supported. Yes you will not find the JSpinner in the Almanac. I built mine working from the JDK API Specs.No JSpinner in my Java Developers ALMANAC :-(
"IchBin" <weconsul@xxxxxxx> schreef in bericht news:-tOdnSFRy6y_DkbeUSdV9g@xxxxxxxxxxMartijn Mulder wrote:I cannot find the javax.swing component that does the following. A fairly common control on the right side of a TextField, consisting of two small arrows, one up and one down, that lets you increment or decrement the value in the TextField by clicking on one of them. I know they must be there but I cannot find out how they are called in java.
Thank youThe only thing I can think of is in combination with a JSpinner
--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"' -William E. Taylor, Regular Guy (1952-)
You should get into a habit of referencing it, life will be much easer. You will have to look at the API Specs for Spinner\SpinnerNumberModel(s) to changed a few things but here is some code to get you going..
private JSpinner spinnerCompareSize; private SpinnerNumberModel spinnerModelCompareSize;
public JSpinner buildSpinner(String toolTip)
{
Dimension spinnerDimension = new Dimension(35, 25);
spinnerCompareSize = new JSpinner();
spinnerCompareSize.setToolTipText(toolTip);
spinnerCompareSize.putClientProperty("is3DEnabled", Boolean.TRUE);
spinnerCompareSize.setMinimumSize(spinnerDimension);
spinnerCompareSize.setPreferredSize(spinnerDimension);
spinnerCompareSize.setMaximumSize(spinnerDimension);
spinnerModelCompareSize = new SpinnerNumberModel(12, 0, 100, 1);
//
// Disable keyboard edits in the spinner
JFormattedTextField tf =
((JSpinner.DefaultEditor) spinnerCompareSize.getEditor()).getTextField();
tf.setEditable(false);
spinnerCompareSize.setModel(spinnerModelCompareSize);
spinnerCompareSize.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent evt) {
JSpinner spinner = (JSpinner)evt.getSource();
quoteCompareSize = (Integer)((JSpinner)evt.getSource()).getValue();
}
});
return spinnerCompareSize;
}
--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Please stop top posting your responses in these NG's.
You can also look at the 'Big Index' on how to use the JSpinner http://java.sun.com/docs/books/tutorial/reallybigindex.html
particularly: http://java.sun.com/docs/books/tutorial/uiswing/components/spinner.html
--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"' -William E. Taylor, Regular Guy (1952-) .
- Follow-Ups:
- Re: TextField Increment/Decrement Buttons
- From: Monique Y. Mudama
- Re: TextField Increment/Decrement Buttons
- References:
- TextField Increment/Decrement Buttons
- From: Martijn Mulder
- Re: TextField Increment/Decrement Buttons
- From: IchBin
- Re: TextField Increment/Decrement Buttons
- From: Martijn Mulder
- Re: TextField Increment/Decrement Buttons
- From: IchBin
- Re: TextField Increment/Decrement Buttons
- From: Martijn Mulder
- TextField Increment/Decrement Buttons
- Prev by Date: Re: adding new textfield after window already drawn--partially working
- Next by Date: Re: Animation not shown; suspect getGraphics() failing
- Previous by thread: Re: TextField Increment/Decrement Buttons
- Next by thread: Re: TextField Increment/Decrement Buttons
- Index(es):