Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Applet width and height

3 views
Skip to first unread message

Kirill Richine

unread,
Jan 12, 1997, 3:00:00 AM1/12/97
to

Hi!

I was wondering if the applet is aware of its width and height
specified in the corresponding html page in the tag

<APPLET code="SomeClass.class" width = 150 height = 50>

I suppose I could just duplicate them using special params, e.g.

<PARAM name="width" value = "150">
...

but is there a more straightforward way?

Thank you.
k&

Wayne Holder

unread,
Jan 12, 1997, 3:00:00 AM1/12/97
to

In article <5bbgk9$9...@scapa.cs.ualberta.ca>, kir...@cs.ualberta.ca (Kirill
Richine) wrote:

int width = size().width;
int height = size().height;

Spend a few bucks and invest in the new book, The Java Class Libaries; An
Annotated Reference by Chan and Lee.

Wayne

--
Give me Limbaugh or give me . . . well not death, but life would be
pretty boring without my daily dose.

Curtis Keisler

unread,
Jan 12, 1997, 3:00:00 AM1/12/97
to

Kirill Richine wrote:
>
> Hi!
>
> I was wondering if the applet is aware of its width and height
> specified in the corresponding html page in the tag
>
> <APPLET code="SomeClass.class" width = 150 height = 50>
>
> I suppose I could just duplicate them using special params, e.g.
>
> <PARAM name="width" value = "150">
> ...

Applet extends Panel
Panel extends Container
Container extends Component
Component has the method size() which returns Dimension which is what
you were looking for ... its all about geneology <g> ... just study the
tree ...!!!!

Later,
Curt

Curtis Keisler

unread,
Jan 12, 1997, 3:00:00 AM1/12/97
to

Wayne Holder wrote:
> Spend a few bucks and invest in the new book, The Java Class Libaries; An
> Annotated Reference by Chan and Lee.

About 50+ to be exact but in my opinion worth it! However, the
information needed to solve this problem is in the html docs ( I prefer
the pdfs.) which are um ... FREE <G> .

Later,
Curt

dog

unread,
Jan 13, 1997, 3:00:00 AM1/13/97
to

Kirill Richine <kir...@cs.ualberta.ca> wrote :

> I was wondering if the applet is aware of its width and height
> specified in the corresponding html page in the tag
>
> <APPLET code="SomeClass.class" width = 150 height = 50>
>
> I suppose I could just duplicate them using special params, e.g.
>
> <PARAM name="width" value = "150">
> ...
>
> but is there a more straightforward way?

yes: Applet is a subclass of Panel (a Component). thus, you can call
getSize() (jdk1.1beta) or size() (jdk1.02) on it (returns a Dimension).

dog
| d...@dog.net.uk
| http://dog.net.uk
| cheeky as buggery


Ian Taylor

unread,
Jan 14, 1997, 3:00:00 AM1/14/97
to

How do I get an environment varaible from within java 1.1 ?
System.getenv() is now obsolete and I get the error :-

java.lang.Error: getenv no longer supported, use properties and -D instead: GRID_HOME
at java.lang.System.getenv(System.java)
at grid.ocl.Env.home(Env.java:162)
at grid.ocl.Env.properties(Env.java:239)

if I try to use it. The above message isn't very helpful. I presume it means use
a -D option when you use the System.getProperty() method but I've tried all
permutations I could think of and it didn't work. Does anybody know how to
do this ?

thanks

email : I.Ta...@astro.cf.ac.uk

Ian


David Brown

unread,
Jan 14, 1997, 3:00:00 AM1/14/97
to

What it means is that you can define properties by passing -D options
to the java interpreter on the command-line:

shell-prompt> java -Dfoo=bar -DmyProp=myVal my.java.Main [args-to-java-main]

Starting the interpreter like this means that you'll get "bar" and "myVal"
when you call System.getProperty("foo") and System.getProperty("myProp"),
respectively. Note the distinction between options to the interpreter and
options to the java program itself, (here, "my.java.Main"), the one that
defines public static void main(String[] argv): anything on the command-line
that occurs before the classname is passed as an option to the interpreter,
anything after the classname goes into argv.

This is of course a bit clumsy for a user to type in. The syntax is meant
to be used in a wrapper shell/batch script. You can use such a script to
define the whole environment in the shell that starts the interpreter as
java properties, and get the same basic behavior as getenv(). Also, you
can explictly load properties from a flat text file (actually from any
InputStream), with a bunch of lines of the form key=value. Lines in such
a stream that start with '#' are considered comments. Check out the
documentation for java.util.Properties and java.lang.System.setProperties().

Hope this helps,

-Dave Brown

Alan Weiner

unread,
Jan 15, 1997, 3:00:00 AM1/15/97
to

int width=Integer.valueOf(getParameterI("width")).intValue();
int height=Integer.valueOf(getParameterI("height")).intValue();

On 12 Jan 1997 20:12:57 GMT, kir...@cs.ualberta.ca (Kirill Richine)
wrote:

>Hi!
>


>I was wondering if the applet is aware of its width and height
>specified in the corresponding html page in the tag
>
><APPLET code="SomeClass.class" width = 150 height = 50>
>
>I suppose I could just duplicate them using special params, e.g.
>
><PARAM name="width" value = "150">
>...
>
>but is there a more straightforward way?
>

>Thank you.
>k&


Alex McManus

unread,
Jan 16, 1997, 3:00:00 AM1/16/97
to


Ian Taylor <I.Ta...@astro.cf.ac.uk> wrote in article
<E3zyq...@cf.ac.uk>...


>
> How do I get an environment varaible from within java 1.1 ?
> System.getenv() is now obsolete and I get the error :-
>
> java.lang.Error: getenv no longer supported, use properties and -D
instead: GRID_HOME
> at java.lang.System.getenv(System.java)
> at grid.ocl.Env.home(Env.java:162)
> at grid.ocl.Env.properties(Env.java:239)
>

I believe the -D refers to the java command line - this enables you to see
properties when you start the java app.

e.g. start the program with...
java -Dmy.dir=c:\Alex MyApp
...and...
System.getProperty( "my.dir" )
...will return...
"c:\Alex"

In other words, you have to set the properties explicitly from the command
line, perhaps through a shell script/batch file.

Alex McManus (a...@aber.ac.uk).

Chris Trueman

unread,
Jan 22, 1997, 3:00:00 AM1/22/97
to

On 12 Jan 1997 20:12:57 GMT, kir...@cs.ualberta.ca (Kirill Richine)
wrote:

Why not use size().width and size().height

0 new messages