How to add a template to a Java project? Java NUBE! help...

page: 1
0

log in

join

posted on Mar, 25 2013 @ 09:50 PM
link   
My friend has an intro to Java class, and this program is simply a bunch of prompt boxes that ask for your name and such. The teacher assigned an assignment to add code to the template? No matter where we put this code in the file we can't get anything to change.

How would you add this code to a Java project-we are using NetBeans:



/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package firstgui;
import javax.swing.*;
import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JOptionPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
*
* @author AndoniMacPro
*/
public class Firstgui {
public static void main(String[] args) {
JFrame frame = new JFrame();
//frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocation(200,300);
frame.setSize(500,175);
frame.setTitle("Welcome to Juan's Music");
frame.setVisible(true);
}


}



It says open templates, but when I do that I see many different file types and oh geeze... Help please!




posted on Mar, 25 2013 @ 09:51 PM
link   
I don't see a "template" when I go to tools/templates-just a ton of different file formats.



posted on Mar, 25 2013 @ 11:12 PM
link   
I don't understand your question; it works just fine when I run it:



Just add to the code that exists.



posted on Mar, 26 2013 @ 06:50 AM
link   
reply to post by SilentKoala
 


I don't know how it is working for you. You know more about this than me apparently.

Okay so I open NetBeans, then I create a new project->Java Application. I removed all of the code from the file that is there by default (is that wrong?), then I run it, but nothing happens.



posted on Mar, 26 2013 @ 07:23 PM
link   
Create a new Java project, then create a new class called Firstgui. Then copy and paste all that code into new class replacing what is there. Delete the line "package firstgui". Then run it.





new topics
 
0

log in

join