Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2006

Tip: Looking for answers? Try searching our database.

TextField Increment/Decrement Buttons

Thread view: 
Martijn Mulder - 28 Jan 2006 15:43 GMT
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 you
IchBin - 28 Jan 2006 15:52 GMT
> 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
[quoted text clipped - 3 lines]
>
> Thank you

The only thing I can think of is in combination with a JSpinner

Signature

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-)

Martijn Mulder - 28 Jan 2006 16:52 GMT
No JSpinner in my Java Developers ALMANAC :-(

>> 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
[quoted text clipped - 4 lines]
>> Thank you
> The only thing I can think of is in combination with a JSpinner
IchBin - 28 Jan 2006 19:13 GMT
> No JSpinner in my Java Developers ALMANAC :-(
>
[quoted text clipped - 6 lines]
>>> Thank you
>> The only thing I can think of is in combination with a JSpinner

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.

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;
    }

Signature

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-)

IchBin - 28 Jan 2006 19:22 GMT
>> No JSpinner in my Java Developers ALMANAC :-(
>>
[quoted text clipped - 45 lines]
>         return spinnerCompareSize;
>     }

Just in case..

import javax.swing.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-)
Martijn Mulder - 29 Jan 2006 08:37 GMT
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 :-)

>> No JSpinner in my Java Developers ALMANAC :-(
>>
[quoted text clipped - 44 lines]
>         return spinnerCompareSize;
>     }
IchBin - 29 Jan 2006 13:32 GMT
> 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
[quoted text clipped - 48 lines]
>>         return spinnerCompareSize;
>>     }

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

Signature

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-)

Monique Y. Mudama - 30 Jan 2006 02:00 GMT
>> 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 :-)
>
> Please stop top posting your responses in these NG's.

Please practice better trimming before critiquing others' netiquette.
You included 73 lines that were in no way required for post
comprehension.  That's even more annoying than top posting.

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.