Can I add a Jython action listener to a java program?

I have a Java program which I'd like to call from a Jython program. I'd like to be able to have the two interface with one another and had hoped to call the Java program from Jython with an action listener as a parameter, but so far I have had no luck. Jython code: import sys sys.path.append("sgJython.jar") from java.awt.event import ActionListener from java.awt.event import ActionEvent from sg.gui import MainGui class MyListener(ActionListener): def ActionPerformed(e): print("gotit") ml = MyListener() MainGui(ml) Java code: package sg; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; class MainGui { public MainGui(ActionListener listener) { top = new JFrame(); top.setBounds(300, 300, 600, 300); JButton doneButton = new JButton("Done"); doneButton.addActionListener(listener); top.add(doneButton) } } Is there some other way of doing this? If not, is there a better way to go about integrating Java and Python into a single application, or is that not a good thing to do?

以上就是Can I add a Jython action listener to a java program?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准