Feb 11, 2012

[Netbeans] center a JFrame window

1. JFrame properties (right click on JFrame --> properties)
2. code tab  -->  Form size policy --> Generate resize code
3. be sure "Generate center" is checked.
4. close


without GUI,

    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new BabyZoo();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Display the window.
        frame.pack();
frame.setLocationRelativeTo(null);   //center the window
        frame.setVisible(true);
    }

2 comments:

  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 8 online training JavaEE Training in Chennai Java EE Training in Chennai

    ReplyDelete
  2. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post I would like to read this
    Data Science Training in Chennai
    Data Science course in anna nagar
    Data Science course in chennai
    Data science course in Bangalore
    Data Science course in marathahalli
    Data science course in bangalore

    ReplyDelete