How do you set the size and location of a JButton in an applet?
-
I have tried setSize(), setBounds(), setMinimumSize(), setMaximumSize(), setPreferredSize(), and none of them work. The button takes up the entire applet window. Also, my applet shows up fine when I use appletviewer but when I put it in a webpage it doesn't show up. Any ideas? All input is appreciated.
-
I have tried setSize(), setBounds(), setMinimumSize(), setMaximumSize(), setPreferredSize(), and none of them work. The button takes up the entire applet window. Also, my applet shows up fine when I use appletviewer but when I put it in a webpage it doesn't show up. Any ideas? All input is appreciated.
It's been awhile since my java days -- but my first guess for you is to pick the correct layout manager. The layout manager takes precedence over your sizing.... Is there still an XYLayout?
-
It's been awhile since my java days -- but my first guess for you is to pick the correct layout manager. The layout manager takes precedence over your sizing.... Is there still an XYLayout?
-
I have tried setSize(), setBounds(), setMinimumSize(), setMaximumSize(), setPreferredSize(), and none of them work. The button takes up the entire applet window. Also, my applet shows up fine when I use appletviewer but when I put it in a webpage it doesn't show up. Any ideas? All input is appreciated.
Objects in a window are sized dynamically by the layout manager. If you don't specify a particular layout manager the default one is FlowLayout. The layout manager asks the component for it's preffered size, then usually sets it's size to that (if it finds enough space). If you really need to take control over an component's size they you probably need to subclass the component and override the getMinimumSize and getPreferredSize methods.