Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to maintain hardcoded values within a swing application outside the program code

Can someone give me the design of how to maintain all the hardcoded values sepratly.

I'm currently using some design patterns, are these fine? And is there any thing more I can do for better design of my applicaiton code.

The design patters I use are (My application is having multiple screens similar wizard):

  1. Using a ResourceBundle for all the strings, which are visible to user (for internationalizaiton)
  2. Using the properties file to save all the values of a particular screen to make accessible for other screens (These values are for internal purpose of program, not visible to user). I'm continuously loading these properties in program at various places to get the updated values like, while going to second screen (Panel) from first screen, to get the values of first screen in second screen.
  3. I'm Thinking to externalize the logging messages using Resource bundles.

Is there any better design approaches? to seperate from program code, A. the "messges visible to user", B. log messages, C. Usability values (screen sizes, Fonts, etc), values user has input in the screens, directory/file paths...

like image 525
merlachandra Avatar asked Aug 16 '26 07:08

merlachandra


1 Answers

I would check out the Java Preferences API, which allows you to store system-wide defaults, per-user defaults and make use of hard-coded defaults in the absence of configured values.

like image 158
Brian Agnew Avatar answered Aug 17 '26 21:08

Brian Agnew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!