groovy

Problem with access to instance methods from closures in SwingBuilder

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.0-JSR-6
  • Component/s: syntax
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    0

Description

An instance method is not found from inner node of SwingBuilder:

class StaticTest {
static void main(args) { new StaticTest() }

public StaticTest () {
def swing = new groovy.swing.SwingBuilder()
def myFrame = swing.frame(size:[100,50]) {
panel() {
button(text: "test", actionPerformed: { testMethod() })
}
}
myFrame.visible = true
}

private testMethod() { println "test" }
}

It gets visible if we:
1) remove panel(), and just place button in the form without panel
2) create a property in the class, assign 'this' to this property, and access the method via the property.

Activity

Hide
blackdrag blackdrag added a comment -

seems as the SwingBuilder violates the rule to ask the class at some point.

adding
throw new MissingMethodException((String)name,getClass(),new Object[0]);
to line 403 of Swingbuilder would fix the case above

Show
blackdrag blackdrag added a comment - seems as the SwingBuilder violates the rule to ask the class at some point. adding throw new MissingMethodException((String)name,getClass(),new Object[0]); to line 403 of Swingbuilder would fix the case above
Hide
blackdrag blackdrag added a comment -

fixed by john

Show
blackdrag blackdrag added a comment - fixed by john

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: