auto-resizing applets?

Y

yawnmoth

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?
 
O

Oliver Wong

yawnmoth said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,267
Latest member
WaylonCogb

Latest Threads

Top