我试图把我的JFrame窗口为椭圆的形状,而是它抛出以下错误:设置在爪哇(形的JFrame)窗口形状
java.lang.IllegalArgumentException: wrong number of arguments
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)
at Splash.setShape(Splash.java:48)
at Splash.<init>(Splash.java:25)
at BackOffice.init(BackOffice.java:40)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
的问题是,我我发送2个参数,方法只接受2个参数,所以我不能看到我从哪里得到这个错误?该行的错误点是在这里说mSetWindowShape.invoke(this, shape);
该行的相关方法:
private void setShape() {
Class<?> awtUtilitiesClass;
try {
awtUtilitiesClass = Class.forName("com.sun.awt.AWTUtilities");
Method mSetWindowShape = awtUtilitiesClass.getMethod("setWindowShape", Window.class, Shape.class);
Shape shape = (Shape) new Ellipse2D.Double(0, 0, getWidth(), getHeight());
mSetWindowShape.invoke(this, shape);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
编辑:我摘下一个放慢参数,并得到了同样的错误(错误的参数个数)。然后我输入3个参数(窗口,形状,0)并得到'参数类型不匹配'。然后我尝试了一个布尔值和一个字符串作为第三个参数,但那些也给出了“参数类型不匹配”。我不明白这一点,因为在教程中它只显示2个参数。现在显然有三个?
哇头疼。感谢一堆! – Ozzy 2011-12-22 21:59:23