I'm trying to set the shape of my JFrame window to an ellipse, but instead it is throwing the following error:
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)
The problem is that I am sending 2 parameters and the method only accepts 2 parameters so I can't see where I am getting this error from? The line that the error points to is the line which says mSetWindowShape.invoke(this, shape);
here is the relevant method:
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();
}
}
EDIT: I took off one paramter and got the same error (wrong number of arguments). I then put in 3 parameters (window, shape, 0) and got 'argument type mismatch'. I then tried a boolean and a string as the third parameter but those gave the 'argument type mismatch' too. I don't understand this because in the tutorial it only shows 2 parameters. Now apparently there are three?