Jump to content
  • Advertisement
Sign in to follow this  

[java] positioning chat room

This topic is 4750 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey ive made a chat room and im just wondering how to position it on the screen

What container did you use ? Do you have a JFrame/Frame and wish to move it ? If so, use :
JFrame.setLocation([x], [y]);

substituting JFrame with your instance (obviously). If you want to center your frame, get the screen dimensions, subtract the frame dimensions, and divide by two. Ex : :

JFrame chatFrame = new JFrame();
// set it up ...
// now center it
int width = chatFrame.getWidth();
int height = chatFrame.getHeight();
Dimension desktop = Toolkit.getDefaultToolkit.getScreenSize();
// do the math ...
int s_width = (int) ( desktop.getWidth() / 2) - ( width / 2 );
int s_height = (int) ( desktop.getHeight() / 2 ) - ( height / 2);
// set the new position
chatFrame.setLocation(s_width, s_height);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!