Thread: Center client with JFrame

Results 1 to 3 of 3
  1. #1 Center client with JFrame 
    Member

    Join Date
    Dec 2007
    Posts
    1,094
    Thanks given
    8
    Thanks received
    8
    Rep Power
    0
    I was looking at a tut on starting your client in the middle of your screen, well someone said make it for jframe, and I was bored and waiting for people to reply on my game frame help.

    Sorry if this has been posted, I'm just bored, and if people want.

    anyways here

    import this.

    Code:
    import java.awt.Toolkit;
    declare these in your GUI class.

    Code:
    	private static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    	private static int intClientWidth = 765;
    	private static int intClientHeight = 529;
    change int and width if necessary.

    add this under your frame packing method.

    Code:
    mainFrame.setBounds(screenSize.width / 2 - (intClientWidth + 8) / 2, screenSize.height / 2 - (intClientHeight + 28) / 2, intClientWidth + 8, intClientHeight + 28);
    remember to change mainFrame to your frame name.

    No flame, it's just a snippet on something I figured out while I was bored.
    Reply With Quote  
     

  2. #2  
    Donator


    Join Date
    May 2008
    Posts
    1,234
    Thanks given
    31
    Thanks received
    25
    Rep Power
    279
    Good i guess
    Reply With Quote  
     

  3. #3  
    Registered Member
    Riedell's Avatar
    Join Date
    Feb 2008
    Age
    31
    Posts
    403
    Thanks given
    4
    Thanks received
    2
    Rep Power
    152
    Check this out:
    http://www.rune-server.org/showthread.php?t=113660

    One line of code and posted this one that is a better snippet.
    ~Riedell
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •