473,406 Members | 2,281 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,406 software developers and data experts.

How to get current Resolution of Window in JAVA

Hi

I want to know how to get current size or resolution of window or frame.I mean
I made a program in which i Created a frame for 800*600 window but what changes i required to run the same program in 1024*728 or any other resolution
to obtain the full frame or window
Feb 11 '07 #1
2 2918
All the GUI classes extend Component, so you can use the getWidth() and getHeight() methods to find the current dimensions of a frame or window.
Feb 11 '07 #2
rengaraj
168 100+
All the GUI classes extend Component, so you can use the getWidth() and getHeight() methods to find the current dimensions of a frame or window.
Java 1.4 or newer
If you are using Java 1.4 or newer, you can use the simple method setLocationRelativeTo(null) on the dialog box, frame, or window to center it.

Java 1.3 or older
//Create a new JFrame
JFrame frame = new JFrame("Demo");
frame.setSize(400, 600);

//Calculate the frame location
int x = (screenSize.width - frame.getWidth()) / 2;
int y = (screenSize.height - frame.getHeight()) / 2;

//Set the new frame location
frame.setLocation(x, y);
Feb 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Joop Kaashoek | last post by:
Just confirming, it looks like an Internet Explorer browser window can not be manipulated by JavaScript to hide its menu bar etc, is this correct?
2
by: mamin | last post by:
Hi, I need to send a file to a client and then close current window. My code looks as follows: Response.ContentType="application/bmp"; Response.AppendHeader("","attachment; filename=\"" +...
31
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I modify the current browser window?...
1
by: star111792 | last post by:
hi, can anyone plz tell me that which built-in classes of java are used to get current time? what are the methods used? how 2 times can be compared to get the mean time? also i want to ask...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.