Welcome to Dream.In.Code
Become a Java Expert!

Join 150,373 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,788 people online right now. Registration is fast and FREE... Join Now!




JFrame Centering?

 
Reply to this topicStart new topic

JFrame Centering?

Synth
5 Feb, 2008 - 06:31 PM
Post #1

New D.I.C Head
*

Joined: 29 Aug, 2007
Posts: 44


My Contributions
Is there any way to center a JFrame on a computer such as the center method in the borderlayout? I'm trying to have the jframe center automatically no matter which computer you use the program on.
User is offlineProfile CardPM
+Quote Post

dontKnowJava
RE: JFrame Centering?
5 Feb, 2008 - 06:54 PM
Post #2

D.I.C Head
**

Joined: 29 Sep, 2007
Posts: 213


My Contributions
CODE

Toolkit tk  = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        setLocation((d.width - width)/2, (d.height - height)/2);

User is offlineProfile CardPM
+Quote Post

Synth
RE: JFrame Centering?
5 Feb, 2008 - 08:05 PM
Post #3

New D.I.C Head
*

Joined: 29 Aug, 2007
Posts: 44


My Contributions
thanks dontknowjava it works great smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:35PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month