• Post Reply Bookmark Topic Watch Topic
  • New Topic

Storing Session Values in Swing (Possible?)

 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working on a standalone Swing application that has a sqlite backend. I'm very familiar with J2EE and storing session values and was wondering if that type of setup is available in Swing.

I'd like to create a bean and store/retrieve values through getter and setters in a session like way. This will allow me to use the values throughout my application.

I've spend two days searching the web and havent been able to land on a solid answer.

Thanks
 
Paul Clapham
Sheriff
Posts: 21876
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see why not. Create an object (a bean, as you say) to store those "session variables" in, store them in the object and work with them. I don't see what the problem is.
 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do I pass the object as an argument?

If I use a new constructor, that of course would load new memory for the object and would not allow me to access the previously stored values..

I guess this is a 101 type questions since its been a while. Sry
 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to clarify,

I can easily pass all the strings as arguments to the next jFrame method and get the values that way. However, it just seems ugly. I would rather store values in an object and retrieve them when needed throughout my app.

 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just declare a class and either make it singleton or all static stuff - then, you can use getters/setters to access the value throughout the app. That becomes my session for the swing app.
 
Ron Ingram
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked. Thanks.

added the following code to my bean:



Instead of a new constructor, I add the following

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!