15 Apr 2004 08:44
Re: Creating a groovy method in a java parent class for Thicky
I'm confused as to what you're asking - what you describe all looks
fine. Java and groovy methods are the same thing.
Firstly should your Page be-a Panel or just have-a panel? It might be
cleaner to just create any Swing component as part of the body() method
rather than extending from a JPanel as you'll end up with an extra,
pointless panel per page otherwise.
Maybe you just need border support in SwingBuilder?
There's always normal groovy code?
import javax.swing.border.*
...
body() {
panel(border:new TitledBorder("hey"))
}
etc
On 15 Apr 2004, at 07:34, Paul Hammant wrote:
> Folks,
>
> Using the latest Groovy from HEAD, we're taking advantage of the
> super() functionality that now works. In short I want to know how to
> create a method in a parent class that is fully enabled for closure
> operation...
>
> We have a Thicky page written in Groovy (simplified) ....
>
> class Page1 extends ThickyPanel {
> Page1(ThickyContext context, BuilderSupport builder) {
> super(builder)
> body() {
> // some widgets from builder and use of context.
> }
> }
> }
>
> ... extending a Java class ....
>
> public class ThickyPanel extends JPanel {
> public BuilderSupport swingBuilder;
> public ThickyPanel(BuilderSupport swingBuilder) {
> super(new BorderLayout());
> this.swingBuilder = swingBuilder;
> }
> public JPanel body(Closure closure) {
> JPanel component = (JPanel)swingBuilder.invokeMethod("panel",
> closure);
> this.add(component, BorderLayout.CENTER);
> return component;
> }
> }
>
> Basically, the body() method is a java method masquerading as a groovy
> method.It can be used with or without the brackets as normal. However
> I can't do something simple such as border: inside the brackets and
> I'd like to be able to. I appreciate that SwingBuilder would need to
> support that for JComponents that support it, but my central proplem
> is that I have a method 'body' that only looks like a groovy builder
> method.
>
> Thoughts?
>
> - Paul
>
> PS - Am always looking for people to signup and help with Thicky. So
> much to do to match/exceed the browser paradigm.....
> _______________________________________________
> groovy-user mailing list
> groovy-user@...
> http://lists.codehaus.org/mailman/listinfo/groovy-user
>
>
James
-------
http://radio.weblogs.com/0112098/
RSS Feed