Hello everyone! I'm still new to Java and im experimenting some to gain knowledge, but now I'm stucked. I have made a program that is supposed to show a list of celcius degrees that tells how much fahrenheit that is. However it doesnt do that, It shows fx:
"xx Celcius = xx Fahrenheit" in a popupwindow, but then I have to press OK to get the next value.
Can someone please help me? I want everything in the same first window, just a newline and then print the next celcius/fahrenheit.
I'm wondering why you don't understand that the showMessageDialog method opens a message dialog ...
1. You need to create a JFrame. 2. In this JFrame place a JScrollPane 3. Create Your list of degrees either in a 2dimensional array or a Vector of Vectors (meaning a Vector who's elements(lines) contain another vector with the line's elements). 4. create a JTable using the list of values and a list with the column names. 5. use the scrollpanes's setViewportView to put the table in the scrollpane. 6. set the JFrame to visible. Maybe you first want to set it's size on the screen.
How all of this is done? Well, there exists something called Java API wich explains pretty much everything.
If you don't want to use a table: Create a JList instead. Create Strings with the same content as in your message box and add them as Items.
Just one hint: I don't think you will get the correct results, since you only use Integer operations. This way a Celsius degree of 1 would be 36 Fahrenheit, but it should be 36.8
The best thing would be to make celsius and fahrenheit double values. Since celsius is the first value used in the formula, every following operation would be a floating point operation then and you woudl get the correct results.