Jump to content
  • Advertisement
Sign in to follow this  
cNoob

[java] positioning chat room

This topic is 4826 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

Advertisement
Quote:
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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!