Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I resize the width of a java.awt.Choice control after adding strings

 
Angus Comber
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my code. Repaint doesn't do anything here. Any ideas?



and html

<html>
<body>
Enter a semi-colon delimited text string
<applet code = "ChoiceWidth.class" width="300" height = "60">
</body>
</html>

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try calling invalidate() to have the components layed out anew, or set the size of the Choice explicitly (setMinimumSize, setPreferredSize, setMaximumSize methods).
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, it might be a good idea to switch to Swing components instead of awt. Fortunately, almost all of of them have a one to one replacement
Panel -> JPanel
Choice -> JComboBox
List -> JList
Button -> JButton
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:Also, it might be a good idea to switch to Swing components instead of awt. Fortunately, almost all of of them have a one to one replacement
Panel -> JPanel
Choice -> JComboBox
List -> JList
Button -> JButton

Applet -> JApplet
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, please learn and follow the Java coding conventions: http://www.oracle.com/technetwork/java/codeconv-138413.html

Method names should begin with a lowercase letter, and your variable names are not in line with the conventions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic