Home » questions » can someone please tell me how to resize buttons in web applets?

can someone please tell me how to resize buttons in web applets?

2006-07-31 12:43:17, Category: Programming & Design
i'v created a java application using the form editor in netbeans. when i test this applet within netbeans all the buottons are displayed the right size and color. however, when embedded into a html file the buttons become smaller so that the words on them cannot be read. I'v provided screenshots showing how the applet looks in netbeans and also in html file. http://www.geocities.com/shaliru/2webapplet.jpg

Answers

  1. sonfarx

    On 2006-07-31 16:49:52


    If you are not using layouts (setLayout(null)), you can use the Component method; setBounds: public void setBounds(int x, int y, int width, int height) Moves and resizes this component. The new location of the top-left corner is specified by x and y, and the new size is specified by width and height. using swing coul be something like this: Container cp = getContentPane(); cp.setLayout(null); JButton b = new JButton("Serch"); b.setBounds(70,50,40,25); // or somthing like that cp.add(b); ... Could be hard to put each component at the desire position and size. But you can use layouts. I suggest you to see the java API, there you can see what classes and methods you need for your applications: http://java.sun.com/j2se/1.5.0/docs/api/index.html