我試圖把我的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