Java SplitPaneDemo 不起作用?
我正在尝试从 java 官方网站启动并运行此代码,但我得到
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at sun.awt.Win32GraphicsConfig.getBounds(Native Method)
at sun.awt.Win32GraphicsConfig.getBounds(Unknown Source)
at java.awt.Window.init(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at javax.swing.JFrame.<init>(Unknown Source)
另外,在以下行中,该方法甚至不存在。我正在使用 getContentPane()
代替。
JSplitPane top = splitPaneDemo.getSplitPane();
I am trying to get this up code up and running from java official site but I am getting
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
at sun.awt.Win32GraphicsConfig.getBounds(Native Method)
at sun.awt.Win32GraphicsConfig.getBounds(Unknown Source)
at java.awt.Window.init(Unknown Source)
at java.awt.Window.<init>(Unknown Source)
at java.awt.Frame.<init>(Unknown Source)
at javax.swing.JFrame.<init>(Unknown Source)
Also, at the following line, the method doesn't even exist. I am using getContentPane()
instead.
JSplitPane top = splitPaneDemo.getSplitPane();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该演示运行得很好。这是您的修改不起作用:)
这个确实起作用:
您可以将其全部粘贴到名为
SplitPaneDemo2.java
的文件中,然后编译并运行它。原始来源:
The demo works just fine. It's your modification(s) that don't work :)
This does work:
You can stick it all in a file named
SplitPaneDemo2.java
and compile and run it.Original source:
getContentPane ()
是以前的方法。今天,您只需在框架上添加一个面板,即可放置东西。getContentPane ()
was a former approach. Today you just add a panel to the frame, where you put your stuff.