473,396 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

dynamically setting screen width in an applet

Hello,

Newbie question: Does anyone know how to dynamically set the screen
width in an applet? I have an applet that creates a horizontal bar
menu on a webpage, and I would like the width to be 100%.
Unfortunately, this doesn't work with Explorer. so, in my html page,
I wrote a function like this:

<SCRIPT LANGUAGE="JavaScript">
int function getScreenWidth()
{
var width = window.screen.width;
return width;
}
</SCRIPT>

and then called the function when running the applet:
<applet Code=Menu.class Width="getScreenWidth()" Height=30>

but this doesn't seem to work. Can anyone tell me how to fix this?
The script is between the <head></head> tags.

Thanks in advance!
Laura
Jul 17 '05 #1
5 8291
On 30 Jul 2003 10:16:27 -0700, sa******@aecl.ca (Laura) two-finger typed:
Hello,

Newbie question: Does anyone know how to dynamically set the screen
width in an applet? I have an applet that creates a horizontal bar
menu on a webpage, and I would like the width to be 100%.
Unfortunately, this doesn't work with Explorer.
What doesn't work ?

Have you tried <APPLET CODE=... WIDTH="100%" HEIGHT=... > ?
That should work fine, just not in appletviewer (no surrounding page to be
a percentage of).
so, in my html page,
I wrote a function like this:

<SCRIPT LANGUAGE="JavaScript">
int function getScreenWidth()
{
var width = window.screen.width;
return width;
}
</SCRIPT>

and then called the function when running the applet:
<applet Code=Menu.class Width="getScreenWidth()" Height=30>
There is no indication to the browser that you are using javascript inside
a javascript supporting parameter, because the WIDTH parameter works like
any width parameter in HTML, and does not interpret Javascript functions
like onLoad or onMouseOver would.

And I hope you mean not 'screen' width, but the width of the HTML page,
because you can't load an Applet geometrically outside the HTML page.
Not everybody runs their browser fullscreen.

The Applet could create a new window outside the page, though, but I don't
think that is what you are looking for.

but this doesn't seem to work. Can anyone tell me how to fix this?
The script is between the <head></head> tags.

Thanks in advance!
Laura


Cheers.
Jul 17 '05 #2
Yeah, the % doesn't seem to work for me. As soon as I change this to
pixels, everything is ok, but when I use percents, it's blank on the
screen... I wonder why. I was thinking of maybe passing width as a
param? Do you think this would work?

thanks again!
Laura
Neomorph <ne******@nospam.demon.co.uk> wrote in message news:<1k********************************@4ax.com>. ..
On 30 Jul 2003 10:16:27 -0700, sa******@aecl.ca (Laura) two-finger typed:
Hello,

Newbie question: Does anyone know how to dynamically set the screen
width in an applet? I have an applet that creates a horizontal bar
menu on a webpage, and I would like the width to be 100%.
Unfortunately, this doesn't work with Explorer.


What doesn't work ?

Have you tried <APPLET CODE=... WIDTH="100%" HEIGHT=... > ?
That should work fine, just not in appletviewer (no surrounding page to
be
a percentage of).
so, in my html page,
I wrote a function like this:

<SCRIPT LANGUAGE="JavaScript">
int function getScreenWidth()
{
var width = window.screen.width;
return width;
}
</SCRIPT>

and then called the function when running the applet:
<applet Code=Menu.class Width="getScreenWidth()" Height=30>


There is no indication to the browser that you are using javascript
inside
a javascript supporting parameter, because the WIDTH parameter works like
any width parameter in HTML, and does not interpret Javascript functions
like onLoad or onMouseOver would.

And I hope you mean not 'screen' width, but the width of the HTML page,
because you can't load an Applet geometrically outside the HTML page.
Not everybody runs their browser fullscreen.

The Applet could create a new window outside the page, though, but I
don't
think that is what you are looking for.

but this doesn't seem to work. Can anyone tell me how to fix this?
The script is between the <head></head> tags.

Thanks in advance!
Laura


Cheers.

Jul 17 '05 #3
On 31 Jul 2003 11:23:32 -0700, sa******@aecl.ca (Laura) two-finger typed:
Yeah, the % doesn't seem to work for me. As soon as I change this to
pixels, everything is ok, but when I use percents, it's blank on the
screen... I wonder why. I was thinking of maybe passing width as a
param? Do you think this would work?
Are you using a table around the applet ?

If you do, make sure the table has a width=100% as well.

If you let the cell/column of the table that contains the applet minimize
on the content, then giving the applet a percentage will 'shortcircuit' the
sizing calculation and you end up with a zero width column.

thanks again!
Laura
Neomorph <ne******@nospam.demon.co.uk> wrote in message news:<1k********************************@4ax.com>. ..
On 30 Jul 2003 10:16:27 -0700, sa******@aecl.ca (Laura) two-finger typed:
>Hello,
>
>Newbie question: Does anyone know how to dynamically set the screen
>width in an applet? I have an applet that creates a horizontal bar
>menu on a webpage, and I would like the width to be 100%.
>Unfortunately, this doesn't work with Explorer.


What doesn't work ?

Have you tried <APPLET CODE=... WIDTH="100%" HEIGHT=... > ?


<cut rest>

Cheers.
Jul 17 '05 #4
Yup, my applet is in a table, but I tried setting the width in teh
table, and also in the applet and it didn't work. I was wondering if
there was a different way to fix this?
thanks again, Laura
Neomorph <ne******@nospam.demon.co.uk> wrote in message news:<5q********************************@4ax.com>. ..
On 31 Jul 2003 11:23:32 -0700, sa******@aecl.ca (Laura) two-finger typed:
Yeah, the % doesn't seem to work for me. As soon as I change this to
pixels, everything is ok, but when I use percents, it's blank on the
screen... I wonder why. I was thinking of maybe passing width as a
param? Do you think this would work?


Are you using a table around the applet ?

If you do, make sure the table has a width=100% as well.

If you let the cell/column of the table that contains the applet minimize
on the content, then giving the applet a percentage will 'shortcircuit'
the
sizing calculation and you end up with a zero width column.

thanks again!
Laura
Neomorph <ne******@nospam.demon.co.uk> wrote in message

news:<1k********************************@4ax.com>. ..
On 30 Jul 2003 10:16:27 -0700, sa******@aecl.ca (Laura) two-finger typed:
>Hello,
>
>Newbie question: Does anyone know how to dynamically set the screen
>width in an applet? I have an applet that creates a horizontal bar
>menu on a webpage, and I would like the width to be 100%.
>Unfortunately, this doesn't work with Explorer.

What doesn't work ?

Have you tried <APPLET CODE=... WIDTH="100%" HEIGHT=... > ?


<cut rest>

Cheers.

Jul 17 '05 #5
On 5 Aug 2003 08:24:21 -0700, sa******@aecl.ca (Laura) two-finger typed:
Yup, my applet is in a table, but I tried setting the width in the
table, and also in the applet and it didn't work. I was wondering if
there was a different way to fix this?
thanks again, Laura
Make sure there is no setSize() in the Applet's init().
I use Visual Café 4.0 for Java development, and the visual editor has the
nasty habit of wanting to set the size in the init() of the Applet.

The % on the width or height of the Applet tag is with respect to the
container around it (the table cell in your case), not neccessarily with
the window of the browser.

Also, when you use too many relative sizes, is can happen that there is no
way to calculate the real size, because there is no size to relate to.

Example (I left out the pointy brackets so HTML news readers don't try to
interpret this as HTML):

TABLE WIDTH=90% !-- 90% of the window width - no problem here --
TR
TD
!-- Applet wants 100% of the cell (not the table!) --
APPLET ... WIDTH=100% HEIGHT=100
/APPET
/TD

TD
Hello World
/TD
<!-- Autoadjust size -->
<TR>
</TABLE>

Since Hello World uses actual real estate, and the first column could be
zero width without conflicting with the size of the object(s) inside (100%
of zero is zero, so it fits), the second column could practically take the
entire 90% of the window width.

If you would post your actial HTML (or a link to it), we could have a look
at it and tell you were the problem lies.
Neomorph <ne******@nospam.demon.co.uk> wrote in message news:<5q********************************@4ax.com>. ..
On 31 Jul 2003 11:23:32 -0700, sa******@aecl.ca (Laura) two-finger typed:
>Yeah, the % doesn't seem to work for me. As soon as I change this to
>pixels, everything is ok, but when I use percents, it's blank on the
>screen... I wonder why. I was thinking of maybe passing width as a
>param? Do you think this would work?


Are you using a table around the applet ?

If you do, make sure the table has a width=100% as well.


Cheers.
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Put 030516 in email subj to get thru | last post by:
I've always been bothered about having to statically declare the size of a Java applet window (container?) in the calling HTML. I've always wanted the moral equivalent of width=50% statement (of...
4
by: RelaxoRy | last post by:
I have 2 screen sizes I want to accomodate for. screen.width <= 800 and > 800. This is because If it's one or the other, I want a different set of menu graphics, and to set variables for my...
6
by: mgandra | last post by:
What is best way to find browser screen width using javascript that is compatible with all types of browsers.
2
by: Paresh Dhakan | last post by:
Hi ! I am facing a wierd problem in setting the width of a form to 20. Suppose I create two forms Form1 and Form2. Form1 is the container, meaning this.IsMdiContainer = true; Form2 is...
2
by: Ken Cooper | last post by:
Hi, Is it possible to determine users screen width in ASP.NET? I have tried Request.ServerVariables("HTTP_UA_PIXELS") but this returns nothing. I am being pointed in the direction of...
2
by: Jacques Leclerc | last post by:
What's the trick to dynamically setting the width of a textbox? In the code behind page Page_Load function I'm trying to dynamically set the width of a textbox. TextBox1.Width = "75px" I...
3
by: Safalra (Stephen Morley) | last post by:
(Note: I'm not trying to do anything stupid based on the user's screen size - I'm just curious.) At work today I was looking at the visitor statistics for a client website, and noticed that...
1
by: nasima khan | last post by:
Hi, i am nasima. I have got a code for setting the screen resolution of my page, but i am unable to understand. Can any one give a complete data explanation of the below code. Sub ChangeRes(X...
4
by: David C | last post by:
I am emailing a GridView and setting its Width property to 900 before rendering and it works great. However, when the rendering is done, I want to reset the Width back to 95% like it was. When I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.