在 Jython 中创建基于 Swing 的 GUI
今天,我一直在尝试使用 jython 来使用 swing 创建 GUI。我不是专业程序员,因此我决定尝试使用 Netbeans IDE 来设计界面,然后调整输出以便在 jython 中使用,因为我在 Python 方面的经验比 Java 丰富。在完成代码后,我设法消除了所有语法错误,但仍然留下一个错误,内容如下:
Traceback (most recent call last):
File "<path of file>", line 362, in <module>
run = InitGUI()
File "<path of file>", line 358, in __init__
frame.show()
at javax.swing.GroupLayout.checkParent(Unknown Source)
at javax.swing.GroupLayout.invalidateLayout(Unknown Source)
at java.awt.Container.invalidate(Unknown Source)
at java.awt.Component.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at javax.swing.JRootPane.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at java.awt.Window.addNotify(Unknown Source)
at java.awt.Frame.addNotify(Unknown Source)
at java.awt.Window.show(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: GroupLayout can only be used with one Container at a time
现在,我不知道是什么导致了这个问题,也不知道如何/在哪里解决它。
完整的源代码位于此处。
如果有人可以看一下,我将非常感激,
谢谢
Today, I've been dabbling in using jython to create a GUI using swing. I'm no expert programmer, so I decided to have a go at using the Netbeans IDE to design the interface and then adapt the output for use in jython as I have more experience in python than Java. After working through the code I managed to rid all the syntax errors but am still left with an error that reads:
Traceback (most recent call last):
File "<path of file>", line 362, in <module>
run = InitGUI()
File "<path of file>", line 358, in __init__
frame.show()
at javax.swing.GroupLayout.checkParent(Unknown Source)
at javax.swing.GroupLayout.invalidateLayout(Unknown Source)
at java.awt.Container.invalidate(Unknown Source)
at java.awt.Component.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at javax.swing.JComponent.addNotify(Unknown Source)
at javax.swing.JRootPane.addNotify(Unknown Source)
at java.awt.Container.addNotify(Unknown Source)
at java.awt.Window.addNotify(Unknown Source)
at java.awt.Frame.addNotify(Unknown Source)
at java.awt.Window.show(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: GroupLayout can only be used with one Container at a time
Now, I have no idea what has caused this, or how/where to look to go about solving it.
Full source code is here.
I would really appreciate it if anyone could take a look,
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在
JFrame
上设置我以前从未见过的布局..(通常设置JFrame
的子组件的布局)。您可以尝试一下:
另请参阅此讨论。
You're setting the Layout on the
JFrame
which I have never seen before.. (normally one sets the layout of the child components of theJFrame
).Can you try:
See also this discussion.