auto-resizing applets?

Discussion in 'Java' started by yawnmoth, Aug 23, 2006.

  1. yawnmoth

    yawnmoth Guest

    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?
     
    yawnmoth, Aug 23, 2006
    #1
    1. Advertising

  2. yawnmoth

    Oliver Wong Guest

    "yawnmoth" <> wrote in message
    news:...
    > 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
     
    Oliver Wong, Aug 28, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ernie Sty
    Replies:
    3
    Views:
    457
    Ernie Sty
    Oct 6, 2004
  2. linkswanted
    Replies:
    1
    Views:
    991
  3. Kerberos
    Replies:
    3
    Views:
    245
    Kerberos
    Oct 25, 2004
  4. Pil (Trustworthy from Experience)

    Resizing a div by resizing its borders

    Pil (Trustworthy from Experience), Apr 18, 2009, in forum: Javascript
    Replies:
    9
    Views:
    370
    Proper
    Apr 21, 2009
  5. Proper
    Replies:
    0
    Views:
    211
    Proper
    Apr 18, 2009
Loading...

Share This Page