简体   繁体   中英

How to adjust the size of an applet in html

I have a code that needs user input of 3 floating numbers and calculate the sum, multiplication, min, max and average. I have successfully made a display in the html. However the size is not what I wanted. In my computer it shows up like this after resizing the window: 在此处输入图片说明

However the html code shows up in my browser like: 在此处输入图片说明

The display size is different.

My code for displaying the panel is like below:

public void paint(Graphics g)
{
    super.paint(g);
    g.drawRect(15, 10, 400, 180);
    g.drawString(String.format("The numbers entered are: %.3f, %.3f, %.3f", number1, number2, number3), 25, 25);
    g.drawString( "The count is 3", 25, 50);
    g.drawString(String.format("The sum is: %.3f",sum), 25, 75);
    g.drawString(String.format("The product is: %.3f",product), 25, 100);
    g.drawString(String.format("The average is: %.3f",average), 25, 125);
    g.drawString(String.format("The largest absolute value is: %.3f",max), 25, 150);
    g.drawString(String.format("The smallest absolute value is: %.3f",min), 25, 175);
}

And my html code for writing applet container is below:

 <html>
 <body>
 <applet code = "calculator.class" width="400" height="100">
 </applet>
 </body>
 </html>

what is wrong?

I changed the size of applet container to

<applet code = "calculator.class" width="600" height="300">

And it worked well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM