auto-resizing applets?  
Author Message
yawnmoth





PostPosted: 2006-8-23 12:02:00 Top

java-programmer, auto-resizing applets? Say I have the following applet:

import java.applet.*;
import java.awt.*;

public class Test extends Applet
{
public void start()
{
try
{
add(new Label(getParameter("echo")));
}
catch (Exception e)
{
e.printStackTrace();
}
}
}

Here's how I'm including it:

<applet width="500" height="500" code="Test.class">
<param name="echo" value="hello, world!" />
</applet>

The only problem with this method is that the width and height are
fixed. Is there a way for the width and height to be exactly as big as
they need to be to display the echo parameter, whatever it may be?

Also, would it be possible to change the font of the Label? Or maybe
make it so that you can highlight the Label's text just as you can
normal html?

 
Oliver Wong





PostPosted: 2006-8-29 2:30:00 Top

java-programmer >> auto-resizing applets?
"yawnmoth" <email***@***.com> wrote in message
news:email***@***.com...
> Say I have the following applet:
>
> import java.applet.*;
> import java.awt.*;
>
> public class Test extends Applet
> {
> public void start()
> {
> try
> {
> add(new Label(getParameter("echo")));
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
> }
> }
>
> Here's how I'm including it:
>
> <applet width="500" height="500" code="Test.class">
> <param name="echo" value="hello, world!" />
> </applet>
>
> The only problem with this method is that the width and height are
> fixed. Is there a way for the width and height to be exactly as big as
> they need to be to display the echo parameter, whatever it may be?

No easy way, AFAIK. You could try JavaScript on the HTML side.

>
> Also, would it be possible to change the font of the Label?

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Component.html#setFont(java.awt.Font)

> Or maybe
> make it so that you can highlight the Label's text just as you can
> normal html?

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Component.html#setFocusable(boolean)

- Oliver