Posts:
3,442
Registered:
18-Oct-2002
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
24 Sep 20, 16:58
in response to: RobM
|
|
|
Thanks David. I’ll add the new try catch method to the wiki’s code snippets page, as an example of keeping skins with new features working on old versions of jAlbum.
And thanks for your patience with us (me, anyway) amateur coders.
You're welcome Rob!
|
|
|
Posts:
8,039
Registered:
31-Jan-2006
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
24 Sep 20, 17:04
in response to: davidekholm
|
|
|
I'm afraid you've lost me, there. This is an example of what I'm seeing in the "new" Journal code: new StateMonitor() {
public void onChange() {
enable(showRegions.isSelected(), showUnknown, localLink);
}
}.add(showRegions).done();
Looks very familiar, with no use of any shorthand methods.
|
|
|
Posts:
8,039
Registered:
31-Jan-2006
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
24 Sep 20, 17:08
in response to: JeffTucker
|
|
|
Ah, finally found an example of the shorthand method. Nice and concise. Is there a 5-component limit, as there is with enable?
|
|
|
Posts:
3,442
Registered:
18-Oct-2002
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
24 Sep 20, 17:31
in response to: JeffTucker
|
|
|
Ah, finally found an example of the shorthand method. Nice and concise. Is there a 5-component limit, as there is with enable?
No, you can use as many components as you like. True, I didn't rewrite all usages of StateMonitor, just 2 of them. The enable method of StateMonitor shouldn't be limited to 5 components either. It has one method that takes an elipsis (...), meaning any number of components.
|
|
|
Posts:
8,039
Registered:
31-Jan-2006
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
24 Sep 20, 17:47
in response to: davidekholm
|
|
|
The enable method of StateMonitor shouldn't be limited to 5 components either.
Shouldn't be, or isn't? The API is somewhat confused on the subject, and I've always observed the 5-component rule.
https://jalbum.net/api/se/datadosen/component/StateMonitor.html#enable(boolean,javax.swing.JComponent)
ETA: A quick test with one of my own skins reveals that more than 5 components can be specified in a single enable. Seems to work properly back at least as far as jAlbum 17, which is the only version I'm concerned about (all of my skins require at least that version).
|
|
|
Posts:
3,815
Registered:
4-Aug-2006
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
24 Sep 20, 22:40
in response to: davidekholm
|
|
|
I have updated the Code Snippets to make finding this code easier in the future. It is currently the second entry, after the all important frog chorus Hopefully my description and abridged code is ok.
|
|
|
Posts:
3,442
Registered:
18-Oct-2002
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
25 Sep 20, 10:57
in response to: JeffTucker
|
|
|
The enable method of StateMonitor shouldn't be limited to 5 components either.
Shouldn't be, or isn't? The API is somewhat confused on the subject, and I've always observed the 5-component rule.
https://jalbum.net/api/se/datadosen/component/StateMonitor.html#enable(boolean,javax.swing.JComponent)
ETA: A quick test with one of my own skins reveals that more than 5 components can be specified in a single enable. Seems to work properly back at least as far as jAlbum 17, which is the only version I'm concerned about (all of my skins require at least that version).
Now I remember the catch. In plain Java you can use any number of components, but BeanShell probably doesn't understand the elipsis form. There you have to wrap the components in an array and pass the array for it to work beyond 5 components.
|
|
|
Posts:
3,442
Registered:
18-Oct-2002
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
25 Sep 20, 11:04
in response to: RobM
|
|
|
I have updated the Code Snippets to make finding this code easier in the future. It is currently the second entry, after the all important frog chorus Hopefully my description and abridged code is ok.
Yes, well documented!
You might want to add info about the convenience methods of ComponentUtilities too.
The StateMonitor is however more generic/flexible, but it's syntax is a bit verbose for my taste, so since v14, you can use Lambda expressions instead of subclassing StateMonitor. Your StateMonitor code sample then looks like this: StateMonitor.monitoring(themeImageHeight, themeImageWidth).onChange(src -> {
folderImageSize.setText(themeImageWidth.getValue().toString() + "x" + themeImageHeight.getValue().toString());
engine.setThemeImageDim(new Dimension((int)themeImageWidth.getValue(), (int)themeImageHeight.getValue()));
});
There is also a onUserChange callback in case you want to only respond to direct user actions. The "src" parameter in the example above points to the component that originated the change event.
|
|
|
Posts:
8,039
Registered:
31-Jan-2006
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
25 Sep 20, 12:58
in response to: RobM
|
|
|
I have updated the Code Snippets to make finding this code easier in the future.
You might want to add the needed import for setting the syntax language, since even NetBeans can't figure this one out on its own. The wildcard form is easiest: import static org.fife.ui.rsyntaxtextarea.SyntaxConstants.*;
|
|
|
Posts:
3,815
Registered:
4-Aug-2006
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
25 Sep 20, 15:16
in response to: JeffTucker
|
|
|
I have updated the Code Snippets to make finding this code easier in the future.
You might want to add the needed import for setting the syntax language, since even NetBeans can't figure this one out on its own. The wildcard form is easiest: import static org.fife.ui.rsyntaxtextarea.SyntaxConstants.*;
I can do that, when I add the other code David posted above. My intention is to update the example with a link to the Journal skin. Then the full Netbeans project will be available for reference, with all imports and library jar files needed.
|
|
|
Posts:
3,815
Registered:
4-Aug-2006
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
25 Sep 20, 21:08
in response to: RobM
|
|
|
I have now updated the class example and added a new section on the use of lambda & state monitors,
|
|
|
Posts:
3,442
Registered:
18-Oct-2002
|
|
|
Re: JSmartSyntaxTextArea fallback to JSmartTextArea
Posted:
26 Sep 20, 08:57
in response to: RobM
|
|
|
|
|
|
Legend
|
|
Forum admins
|
|
Helpful Answer
|
|
Correct Answer
|
|