Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jre 1.3 - Choice Box Problem  RSS feed

 
Praveen B
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have an AWT choice box in my applet (java.awt.Choice).
The code works properly for jre 1.1.6, but fails in jre 1.3
What I want to achieve is to fill the Choice box with values and leave it empty for the user to select a value.

I have the following statement in the code:
java.awt.Choice myChoice = new java.awt.Choice();
myChoice.add("1");
myChoice.add("2");
myChoice.add("3");
myChoice.select(-1);
In jre 1.1.6, the statement
myChoice.select(-1);
selects nothing in the choice box and leaves it empty.
In jre 1.3 considers "-1" as an invalid value for
myChoice.select(-1);
Any help on how I can achieve this will be greatly appreciated.
Regards,
Praveen.

PS: Please feel free to contact me at
praveen.balaji@iflexsolutions.com
 
Peter Phung
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not a great solution but you oculd just add
myChoice.add(" ");
to your code.
Pete
 
Praveen B
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Peter..
Thanks for the reply. That is exactly how I implemented it now.
Regards,
Praveen.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!