[nbj2ee] Setting a main jframe

  • From: "AeneasTroy" < >
  • To:
  • Subject: [nbj2ee] Setting a main jframe
  • Date: Thu, 04 Oct 2012 16:07:18 -0400

You have to have a main class.

You have a few options:

1. You can instanceate a new JFrame from the main class:

package newx;

import javax.swing.*;

public class Newx {
    public static void main(String[] args) {
        JFrame myFrame = new JFrame();
        myFrame.setVisible(true);  
        myFrame.setBounds(0,0,500,500);
    }
}


2.  You can make a Jframe class and load it from the main class:

/*SEPARATE FILE myFrame.java*/

import javax.swing.*;

public class myFrame extends JFrame{
     public myFrame(String title){
           super(title);
           setDefaultCloseOperation(EXIT_ON_CLOSE);
           pack();
           setVisible(true);
           setBounds(0,0,500,500);     
     }
}

/*SEPARATE FILE main.java*/

public class Newx {
    public static void main(String[] args) {
        myFrame superUltraMegaFrame = new myFrame("SUPER ULTRA MEGA FRAME");
    }
}






[nbj2ee] Setting a main jframe

smacker 10/04/2012

[nbj2ee] Setting a main jframe

AeneasTroy 10/04/2012

[nbj2ee] Setting a main jframe

smacker 10/04/2012

[nbj2ee] Setting a main jframe

AeneasTroy 10/04/2012

[nbj2ee] Setting a main jframe

smacker 10/04/2012

[nbj2ee] Setting a main jframe

AeneasTroy 10/04/2012

[nbj2ee] Setting a main jframe

smacker 10/04/2012

[nbj2ee] Setting a main jframe

AeneasTroy 10/04/2012

[nbj2ee] Setting a main jframe

java@12345 10/10/2012

Project Features

About this Project

www was started in November 2009, is owned by jpirek, and has 21 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close