This is a simple guitar fret calculator I want to create. I have the program logic working fine and am now trying to make it into a swing interface.
All i need for now is for it to have 2 user input boxes (scale length & number of frets). And then to print the result into another box (bigger box though has to fit about 25 lines)
I am a complete swing noob and have got to the stage where I have 3 boxes but how do go about using the input from the first 2 boxes to print to the 3rd box?
So far its just 3 boxes, first 2 accept data but are doing nothing with it
I need to be able to input data (an int) into the first 2 boxes and somehow submit that data so that it can be used in my program logic (or formula) ?? .. and then print the result in the 3rd box..
Why not. Easiest approach might be to use a button. On button click even you can do the calculation. Another approach would be to use key listeners on input fields, for. e.g when the enter key is pressed do the calculation.
Hoping someone can point me in the right direction with this..
Main problem I am getting:
That only the last line of the loop is displayed in the fretScale TextArea. Also i have commented out line 68 just to get the program running but this line is giving a compiler error. Is there an easier was to store the input values to use in this way?
It seems that to you need multiple rows to display the output. So JTable might be an option, or may be JTextArea with line break. However JTable would give it a better look.
Swastik Dey wrote:It seems that to you need multiple rows to display the output. So JTable might be an option, or may be JTextArea with line break. However JTable would give it a better look.
Will try JTable
Thanks
edit; i did try JTextArea and then with a line break in the for loop, but this did not help, still only the last iteration (interation 22) was printed. It must be something to do with the JTextArea as when i run a System.out.println in the for loop it prints 22 iterations in the console
You might have used jtextArea.setText, right? So in this case it will always overwrite the previous value. You have to first retrieve the previous value and then call setText again.
Take a look this project. Its not finished calc I made while learning basics of java and swing. Its Eclipse project so just import into your ide and feel free to tweaking. calcsimple
Post by:autobot
them good ole boys were drinking whiskey and rye singin' this'll be the day that I die. Drink tiny ad.
a bit of art, as a gift, that will fit in a stocking