Hi again

What is the name of the component in programs where there is:

a 2 character text field and on the side there are up and down arrows to increase or decrease the value in the text field. There is usually one in the "Print" dialog in MSWord, with which you can increase the number of copies to be printed.

Sorry, can't explain it any better than this.

Can you tell me the name of a java equivalent, or how to implement or the API or something.

Thanks.

JComboBox in API and in tutorials (just in case :) )

No, it isn't that. its one of those things where there are numbers and pressing the arrow up on the side, increases the value by one inside.

I see now what you mean, it is the section that I marked with red. Well you will have to make your own custom component that will consist of TextField and two buttons with action to add or take one of present number on the user click

Oh.....

Hmm, how should I go about that?
So there is no java equivalent?

It will help if you can shed some light into what you trying to do...
As not to waste time on other things

I'l rather cut my losses on the incrementing value field thing.

But, what I need to ask is how I would go about creating something dynamic.

I have 3 text fields, I want the values you put into the text fields to be automatically added together and displayed in another text field for the total.
Any suggestions?

Are these text fields part of Frame or JFrame? Or you collect your data from sequentially following input dialogues ( JOptionPane.showInputDialog)?

I collect my data from JTextFields.

Im using a JFrame.

Use ActionListener for the input text fields, this example should be helpful

Thanks, will read through that. Another problem, which i have checked the internet for, is a global variable.

I have a couple of class files which are their own JFrames; I have a variable called "bank" which i want accessible and changeable by all of the classes. is there a way to do this, i have a feeling there is, but can't think of anyway to.

EDIT: Besides creating a separate class which can be called and its variables used.

Put all the variables that you wish to share in separate class, make setter and getter methods. When moving from frame to frame just pass instance of them this class as argument (same approach as passing values to method for processing)

Yeah, thanks.

I have already started doing this. I just thought that there was perhaps a keyword or statement for this or something.

Thanks for the help!

I create an object of the type globalVariables, this has the variables needed in it.

When I create the object in one of my methods (in another class) i get an error saying that it can't find the variables in question??

Ok, i've managed to get it working by referencing it with globalVariable.variable_in_question

For some reason i had to set the variables in globalVariables to static. Anyone care to explain this?

That is fine, I did not know it does exist. Good you brought up this to attention, I will try to keep it in my mind

Personally, I've never used it for anything myself, but yeah it's in there. I usually find a simple text box, combo box, or slider more useful. I think repeatedly clicking an arrow to increment something is more tedious than helpful in most situations.

Thanks alot, 5 is the max number anyway, thats why I chose it originally.

Thanks very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.