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:
Campbell Ritchie
Ron McLeod
Paul Clapham
Tim Cooke
Devaka Cooray
Sheriffs:
Liutauras Vilda
paul wheaton
Rob Spoor
Saloon Keepers:
Tim Moores
Stephan van Hulst
Tim Holloway
Piet Souris
Mikalai Zaikin
Bartenders:
Carey Brown
Roland Mueller
Forum:
Swing / AWT / SWT
Display Frame on Center of Screen
satishind Reddy
Ranch Hand
Posts: 33
posted 23 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 23 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
Friends help you move. Good friends help you move bodies. This tiny ad will help:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
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...