*
The moose likes Applets and the fly likes How can I resize the width of a java.awt.Choice control after adding strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "How can I resize the width of a java.awt.Choice control after adding strings" Watch "How can I resize the width of a java.awt.Choice control after adding strings" New topic
Author

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

Angus Comber
Ranch Hand

Joined: Jul 16, 2011
Posts: 90
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
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
Try calling invalidate() to have the components layed out anew, or set the size of the Choice explicitly (setMinimumSize, setPreferredSize, setMaximumSize methods).


Ping & DNS - my free Android networking tools app
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10172
    
    8

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


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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


luck, db
There are no new questions, but there may be new answers.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I resize the width of a java.awt.Choice control after adding strings
 
Similar Threads
Successful Applet Socket Connection
Help please.
Applet -Applet communication prb
Applets & Sockets .The Security Issue Of JAVA.
Problem laying out panels in an Applet