• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing values between two JPanel forms in Java Swing.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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]
 
Chiranthaka Jayakody
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.




 
reply
    Bookmark Topic Watch Topic
  • New Topic