This question is answered.


Permlink Replies: 7 - Pages: 1 - Last Post: 12-Nov-2015 13:42 Last Post By: AndreWolff Threads: [ Previous | Next ]
AndreWolff

Posts: 1,766
Registered: 14-Dec-2007
How to initialize check-boxes?
Posted: 12-Nov-2015 09:16
 
  Click to reply to this thread Reply
In the new version of the Slide Show 4 skin I did introduce new check-boxes to indicate whether a custom link should be opened in a new window, with the next code in onload.bsh:
	JCheckBox PAnewP = new JCheckBox("    ");
	JCheckBox DTnewP = new JCheckBox("    ");
	JCheckBox GMnewP = new JCheckBox("    ");
	JCheckBox GEnewP = new JCheckBox("    ");
	JCheckBox MInewP = new JCheckBox("    ");
	JCheckBox HMnewP = new JCheckBox("    ");
	JCheckBox NAnewP = new JCheckBox("    ");
To be compatible with the previous versions, some check-boxes should be default set and others cleared, so I added to hints.jap:
skin.PAnewP=false
skin.DTnewP=true
skin.GMnewP=true
skin.GEnewP=true
skin.MInewP=true
skin.HMnewP=false
skin.NAnewP=false
But if I open an old project where this new settings are added, all check-boxes are cleared, see enclosed screen-dump WrongDefaults.png. The check=boxes of links 2,3,4,and 5 should be set.

What do I wrong?
What is the correct way to initialize these check-boxes?
davidekholm

Posts: 3,222
Registered: 18-Oct-2002
Re: How to initialize check-boxes?
Posted: 12-Nov-2015 11:29   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
There are two ways. You can produce a headless-settings.jap file containing the defaults or provide a SkinModel.class file with the defaults. The SkinModel can also enforce correct data types. Producing the headless-settings.jap file is probably the quickest way. Set the defaults you like using the UI then use Tools->Skin developer->"Prepare for online and console use". jAlbum now generates a "headless-settings.jap" file to the skin folder that should initialize the state correctly. The presence of this file also has the advantage of making your skin work even if it's being used in a console environment (i.e. a "headless" environment, where there is no screen or UI around)
AndreWolff

Posts: 1,766
Registered: 14-Dec-2007
Re: How to initialize check-boxes?
Posted: 12-Nov-2015 11:42   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Thanks, I will try it.

But what is in that case the purpose of file hints.jap?
davidekholm

Posts: 3,222
Registered: 18-Oct-2002
Re: How to initialize check-boxes?
Posted: 12-Nov-2015 12:54   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
Somewhat different techniques have been added over the years, so there is an overlap in functionality sometimes. Hints can be ignored (is a preference) and you can have hints applied to styles.
davidekholm

Posts: 3,222
Registered: 18-Oct-2002
Re: How to initialize check-boxes?
Posted: 12-Nov-2015 12:55   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
That said, it should be possible to use hints.jap to set defaults too. I can check into it later, but the workaround to use headless-settings.jap should work fine. If that doesn't work, please get back to me.
JeffTucker

Posts: 6,883
Registered: 31-Jan-2006
Re: How to initialize check-boxes?
Posted: 12-Nov-2015 13:13   in response to: davidekholm in response to: davidekholm
Correct
  Click to reply to this thread Reply
I use hints.jap only for choosing selected defaults for jAlbum settings, not for skin settings. The user can elect to ignore hints.jap, so I don't want the user to be ignoring the skin defaults, which I have selected for very good reasons.

The cleanest way to set skin defaults is with a SkinModel.class file, and while that will work with an interpreted (rather than compiled) skin UI, it's a little awkward in that context. Using a headless-settings.jap file is fine, but why not just set your defaults in the UI itself?
JCheckBox thisBox = new JCheckBox("Check here for something", false);
You also don't need the strings of spaces for the check box text. Just specify them as empty, then tab between them when doing the layout:
JCheckBox thisBox = new JCheckBox("", false);
JCheckBox anotherBox = new JCheckBox("", true);
....
add(new JLabel("something");
add("tab", thisBox);
add("tab", anotherBox);
AndreWolff

Posts: 1,766
Registered: 14-Dec-2007
Re: How to initialize check-boxes?
Posted: 12-Nov-2015 13:26   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
If that doesn't work, please get back to me.
If I start a new project, the check-marks are set as I had coded in hints.jap or headless-settings.

But I see also fields with my personal name and folders, which are not in hints.jap or headless-settings.
I did click in the past on File / Save as default. So I think that loads the defaults for a new proiject.

But my problem is also not solved with file headless-settings.jap because in an existing project which was saved before I added the new check-marks, I see still only cleared check-marks for my New window check-marks.

I have now a hints.jap file and a headless-settings.jap file which is I think too much.
Which file should I remove?

Edited by: AndreWolff on 12-Nov-2015 13:40
AndreWolff

Posts: 1,766
Registered: 14-Dec-2007
Re: How to initialize check-boxes?
Posted: 12-Nov-2015 13:40   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
jGromit wrote:
Using a headless-settings.jap file is fine, but why not just set your defaults in the UI itself?
Excellent jGromit, this is doing the job I had in mind, the check-box settings are now correct in old projects.
You also don't need the strings of spaces for the check box text. Just specify them as empty, then tab between them when doing the layout
I did enter the extra spaces for the layout, but I will try your method as well.

jGromit, thanks again for your help!
I am still not too old to learn from you!
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums