Sumeet Gavhale
Sumeet Gavhale

Reputation: 800

Session equivalent in Java Desktop Application

I would like to ask you, i am a PHP developer with some basic knowledge of java.

In PHP we use session to store variables so that it can be used across pages.

Is there a way to store the variables is session (or something similar) so that i could access it through the entire desktop application?

Upvotes: 2

Views: 1135

Answers (2)

W.Vroegh
W.Vroegh

Reputation: 1

if you use a button or label or image to go around the desktop application you could give the object a variable as parameter with use of a ActionEvent, sort of looks like:

   button_next.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
      //Put as many as you need in there
         new TheClassToGoTo(nameofvariable);
      }
   });

Upvotes: 0

user1389591
user1389591

Reputation:

The easy way: use static variables or Singleton classes.

The right way: please study "Object Oriented Programming" and "Design Patterns". You will be surprised with the big world that such knowledge can give to you!

Upvotes: 1

Related Questions