Forums Register Login

Passing values between two JPanel forms in Java Swing.

+Pie Number of slices to send: Send
I have created 3 classes. 1st class is used to store variable. other classes are use to input data and to display data.


1st Class




This is class is designed using the Swing JPanel object and used to enter StudNo, StudName, Marks for 3 subjects. This also include 2 buttons as btnCalculate and btnCancel. This user interface was developed using Java swing class by auto generating. When the btnCalculate clicks the data within the textfields will be assign to the 1st classes variables. And at there the calculations will be done using 3 methods.


2nd Class




The other user interface that used to view the final results of the calculations i.e. Total marks, Average marks and the grade. When the btnCalculate clicks the result should pass to the 3rd class i.e. DisplayInfo JPanel
class. My Problem is when I click the btnCalculate button it does calculate the total marks, average marks and the grade. The 3rd class i.e. the DisplayInfo JPanel form will also displayed but the data did not pass the text
fields were empty.


3rd Class



[b] All I want is when the 2nd JPanel form i.e. DisplayDetails opens the data in the Student class to be inserted to the TextFields of the DisplayDetails form. I am stuck at that point. If you please give me some clue about that. Because Ypu have mentioned about the JPanel's update ( ) but I couldn't find that. I don't think that is an inbuilt one. Thank You![/b]
+Pie Number of slices to send: Send
I have solved my problem by using the static keyword. I changed all the variables in the Student class from non-static to static content and also I changed all
the getter () and setter () from non-static to static content.

Then the access of the variables and other methods are as the below.




I need a new interior decorator. This tiny ad just painted every room in my house purple.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 3038 times.
Similar Threads
Retriving jTextfield value from an other java file
Problems Resizing TextArea
GUI interaction
Displaying ArrayList data in a GUI's Text Fields - Part II
Problem with Email Program in TCP
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 22:39:19.