Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
Ron McLeod
Junilu Lacar
Liutauras Vilda
Sheriffs:
Paul Clapham
Jeanne Boyarsky
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Piet Souris
Carey Brown
Bartenders:
Jesse Duncan
Frits Walraven
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Display Frame on Center of Screen
satishind Reddy
Ranch Hand
Posts: 33
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Anybody,
How to display Frame on Center of screen.
Thanks in advance
Regards
Satish
deekasha gunwant
Ranch Hand
Posts: 396
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Satishhind,
here is a small example.
import javax.swing.*; import java.awt.*; class CenteredFrame extends JFrame { public static void main(String s[]) { CenteredFrame fr = new CenteredFrame(); Dimension dim = fr.getToolkit().getScreenSize(); int screenWidth = dim.width; int screenHeight = dim.height; int frameWidth = screenWidth/3; int frameHeight = screenHeight/3; fr.setSize(frameWidth,frameHeight); fr.setLocation((screenWidth-frameWidth)/2,(screenHeight-frameHeight)/2); fr.getContentPane().add(new JLabel("centered frame",JLabel.CENTER)); fr.setVisible(true); } }
regards
deekasha
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
window alignment
what is this for: setLocationRelativeTo()
how to make a frame unexpandable?
frame calling another frame
Position of new frame
More...