How to get screen size in Applet

View previous topic View next topic Go down

Java How to get screen size in Applet

Post by BIT0112-Rokon on Sat Oct 23, 2010 11:00 am

Though my question is how to get screen size in applet but I know that an applet is embedded within a web browser, and thus by definition cannot be made screen size. If I want browser size, this can change based upon what the user does so I may need to try to have the applet communicate with JavaScript. But problem is that I dont know JavaScript yet.

If I put fixed values for width & height with applet parameter, it shows fine. but I need to be able to resize this according to the users size capabilities, so I need to find out the way of how to do that.

Is there anyone who can help me?

_________________________________________________________________


Code Explosion Blog | Code Explosion Wiki | The Rokonoid | নির্ঝরিণী
avatar
BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

View user profile http://blog.codexplo.org

Back to top Go down

Java Re: How to get screen size in Applet

Post by BIT0122-Amit on Sat Oct 23, 2010 11:21 pm

Erm, I do not understand what you are looking for.
Screen size of browser?
or Screensize of monitor?

can you look at this and tell me whether you are looking for something like this?

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Java Re: How to get screen size in Applet

Post by BIT0102-Mohaimin on Sun Oct 24, 2010 1:14 am

I didn't get your problem.

You want to resize the applet, like you want to resize the JFrame window?

If it is so, I think you can try setSize().
this function is defined by java.awt.Component. So should work in the same way in JFrame and Applet.
avatar
BIT0102-Mohaimin
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : B+
Posts : 415
Points : 715

View user profile

Back to top Go down

Java Re: How to get screen size in Applet

Post by BIT0112-Rokon on Sun Oct 24, 2010 6:46 am

setSize() method doesn't work in Applet.

And the Malum?

I know the way of getting screen size. It works for you swing application. But how can you get screen size in applet?
wow
it will work nice when if we run it in appletViewer. And you know appletViewer is java application not a browser. And we make applet for browser.

so when we embed our applet with a html page- we do something like -
Code:
<html>
<body>
<applet code=AppletClassName width=100 height=100>
          <param name=p1 value="some text">
          <param name=p2 value="some more text">
</applet>
</body>
<html>
here, width and height are fixed. but here I want the width and height dynamically resized according to user browser. if your screen size is 1200x800, your browser size should be the same. Right?

so basically I want to know the browser size. and I have to set size through applet parameter.

I think, you two now get my problem. isn't it?

_________________________________________________________________


Code Explosion Blog | Code Explosion Wiki | The Rokonoid | নির্ঝরিণী
avatar
BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

View user profile http://blog.codexplo.org

Back to top Go down

Java Re: How to get screen size in Applet

Post by BIT0122-Amit on Sun Oct 24, 2010 6:58 am

I think finally I understood what you were looking for.

Hmm. pretty interesting.

You mean, in this part, the size will actually differ based on user's screen size/browser's screen size.
Code:
<html>
<body>
<applet code=AppletClassName width=100 height=100>

But you are actually trying to make a HTML page dynamic which goes against the very definition of HTML being static, right? (At least, for HTML4. Don't know much about HTML5 )

I think you need to use JScript here. And you don't need to know JScript when you need to use a small snippet.

Edit:

Or if you are not willing to use JScript, here is another suggestion Neutral
Make an applet, find screensize, use switch case to execute another applet based on the screen size Neutral
Will need a lot more work though.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Java Re: How to get screen size in Applet

Post by BIT0112-Rokon on Sun Oct 24, 2010 7:27 am

But you are actually trying to make a HTML page dynamic which goes against the very definition of HTML being static, right? (At least, for HTML4. Don't know much about HTML5 )

where I said it?
I said
If I want browser size, this can change based upon what the user does so I may need to try to have the applet communicate with JavaScript. But problem is that I dont know JavaScript yet.

_________________________________________________________________


Code Explosion Blog | Code Explosion Wiki | The Rokonoid | নির্ঝরিণী
avatar
BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

View user profile http://blog.codexplo.org

Back to top Go down

Java Re: How to get screen size in Applet

Post by BIT0122-Amit on Sun Oct 24, 2010 7:30 am

but here I want the width and height dynamically resized according to user browser

that's where you said. You want the size of applet resized depending on the browser screen size.

Means you are not going to define any size, but rather the browser will tell the html page about the size and it will resize the applet to appropriate size.

Which is, dynamic. Period. Unless you are going to define dynamic is some other way.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Java Re: How to get screen size in Applet

Post by BIT0112-Rokon on Sun Oct 24, 2010 7:42 am

And so I told about communicating with JavaScript . But I don't know JavaScript. Here I asked for the solution, how could I do that. I know only one way that is JavaScript . If it is the only way, how can I implement it. Im sure, in JavaScript it will be something like 4 or five lines code.

anyway,
do you know the solution? if not, please leave the post ..

_________________________________________________________________


Code Explosion Blog | Code Explosion Wiki | The Rokonoid | নির্ঝরিণী
avatar
BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

View user profile http://blog.codexplo.org

Back to top Go down

Java Re: How to get screen size in Applet

Post by BIT0122-Amit on Sun Oct 24, 2010 3:32 pm

Make an applet, find screensize, use switch case to execute another applet based on the screen size Neutral
Will need a lot more work though.

you can take a look here:
http://www.sightspecific.com/~mosh/Tricks/ScreenRes/

do you know the solution? if not, please leave the post ..

Sounds like "Hey, do you know how to breed between a horse and a bird to make a Pegasus? If not, please leave the post".

Dude, at least you need someone to tell you that it is not possible.

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Java Re: How to get screen size in Applet

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum