Problem with java.awt.Choice

C

chester_fried

I'm having an issue with a choice element where I need to set it to
have a minimum size but when I try to use setMinimumSize(Dimension) my
code compiles fine but gives me the following error:

java.lang.NoSuchMethodError:
java.awt.Choice.setMinimumSize(Ljava/awt/Dimension;)V

I've even tried casting the choice to a component, which shouldn't be
necessary, but I get the same error with Component instead of Choice in
the error message.

Could someone tell me if this is something that isn't possible(setting
the minimum size of a choice) or if I've found a bug of some sort.

Thanx if advance.
 
O

Oliver Wong

I'm having an issue with a choice element where I need to set it to
have a minimum size but when I try to use setMinimumSize(Dimension) my
code compiles fine but gives me the following error:

java.lang.NoSuchMethodError:
java.awt.Choice.setMinimumSize(Ljava/awt/Dimension;)V

I've even tried casting the choice to a component, which shouldn't be
necessary, but I get the same error with Component instead of Choice in
the error message.

Could someone tell me if this is something that isn't possible(setting
the minimum size of a choice) or if I've found a bug of some sort.

Thanx if advance.

Is your Java compiler (e.g. javac.exe) and your JVM (e.g. java.exe) of
the same version? setMinimumSize was added to Component in 1.5, so maybe
your compiler is 1.5, while your JVM is 1.4 for example.

- Oliver
 
P

pit.grinja

At least in Java 1.42, the error is the expected behaviour: Component
doesn´t have a setMinimumSize(Dimension d) method, see
http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Component.html#setSize(int, int).
It has the methods setSize(Dimension d) and getMinimumSize() so that
somebody can ask the component to resize but without being able to
dictate its minimum size. If I where a "Component" I would let others
decide about my "minimum size" as well.
BTW, what do you mean by "your code compiles fine". When you get an
error, your code does NOT "compile fine".
 
C

chester_fried

I found it thanx for the help. The compiler and JVM were different
versions switched to 1.5 JVM and it works now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top