• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Storing Session Values in Swing (Possible?)

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 27286
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That worked. Thanks.

added the following code to my bean:



Instead of a new constructor, I add the following

 
reply
    Bookmark Topic Watch Topic
  • New Topic