Static main() vs. main()

Newbie question, but why do I get the error under main() but the program runs in console under static main() ?
Is it because its just designed to run that way?

Static functions can be called when no instance of an object exists. (ie you haven't made any app myapp = new app (); calls)
Normal functions can only be called through an instance of an object.
apple.biteMe (); // does not work
apple snack = new apple ();
snack.biteMe (); // worksWhen an application starts up, it needs to call main before the object that contains main has been created. (At least, I believe that is how it works - I have never made a study of the process of a Java app starting up.)

Similar Messages

  • Static private void main(String[]) works (?!)

    Did anyone knew that?
    try yourself!!
    public class Foo {
    static private void main (String[] bla) {
       //anything
    }there's even a bug!! And Sun choose not fix it:
    http://developer.java.sun.com/developer/bugParade/bugs/4252539.html
    I'd like to hear what you folks think about this...
    IMO: fuc* encapsulation!

    No, I haven't done the certification exam and I have no plans to. But the answer to that question isstatic public void main (String[] bla)and the fact that other versions happen to work doesn't matter either theoretically or practically. Bugs that appear in certain implementations of Java shouldn't matter.

  • What's the difference between Main ( ) and Main { } ?

    I have been searching around, but still no luck finding the difference between Main ( ) and Main { }. I found that java uses ( ), and javafx uses { }. But in javafx I can still use ( ). Is there different meaning?
    Thanks.

    I am not sure what you mean, but I will take a guess.
    Remember just one thing:
    1) You can easily instantiate a class to an object in JAVAFX using a JAVA or JAVAFX class, but in JAVA you can only instantiate JAVA objects.
    (Not completely true. If you really want a headache then you can instantiate JAVAFX classes in JAVA, but it is not easy.)
    Let me give you the following class that contains some variable:
    JAVA
    class MainJava {
         int     blaInt;
         long    blaLong;
         String  someString;
         String  anotherString = "(First Bicycle) Look mom no Hands... Look Mom no teeth.";
         public MainJava() {
             // Before this contructor runs all variables will first be initializes to their default values or whatever you put in them above
             // Construct things :)
         } // END CONSTRUCTOR for MainJava
    } // END CLASS MainJavaJAVAFX
    class MainJavaFx {
         var     blaInt : Integer;
         var     blaLong : java.lang.Long; // The most usefull number made difficult in JAVAFX :(
         var     someString : String;
         var     anotherString = "(First Bicycle) Look mom no Hands... Look Mom no teeth."; // Thats nice. No need for a type :) Heaven ... I'm in Heaven
         init {
             // Before this contructor runs all variables will first be initializes to their default values or whatever you put in them above
             // Construct things :)
         } // END CONSTRUCTOR for MainJava
    } // END CLASS MainJavaFxThese 2 classes are affectively the same.
    One written in Java and one in JAVAFX.
    You already seem to know JAVA so I am going to talk in JAVAFX code from now on.
    1) To instantiate a JAVA class in JAVAFX is the same as in JAVA.
      var myNewObj = new MainJava();2) To instantiate a JAVAFX class in JAVAFX you do the following.
      var myNewObj = MainJavaFx{}; // Weeeee .. easy hey :) I likeThink of init{} as the contractor of the class in JAVAFX, because there is no more constructors in JAVAFX like in JAVA.
    Also in JAVA you can pass parameters to the class constructor, whereas in JAVAFX that is not possible anymore.
    So sad, but what JAVAFX taketh away ... JAVAFX giveth so muchth moreth ... th...
    Now witness the power of ... JAVAFX ...
    In JAVAFX you can instantiate any "var" variables when you create the object from the class.
    Therefore you do not need to pass parameters to the init constructor, most of the time you do not even need init.
    So lets say you want to give the class variable other default values in the JAVAFX class then you can do it like this:
      var myNewObj = MainJavaFx{ 
                                                   blaLong : java.lang.System.currentTimeMillis()
                                                   blaInt : 1234
                                                   someString : "Going to the Hospital I see"
                                                   anotherString : "Thorry Mom."
                                          }; // Weeeee .. easy hey :) I likeNow isn't that nice.
    Keep in mind that the init{} and postinit{} code blocks will only run if they exist after the object is created and therefore the variables will already be changed to the values you have given them when you instantiated the class.
    Cool hey :)
    You can not do that to a JAVA object, but then again if you need to change the class variables of a JAVA object then just create a constructor that takes paramaters and update the class variables in the constructor.

  • How to create a vertical submenu in my main horizontal main menu?

    I create a main menu in my site and now i'm having some difficulties creating one vertical submenu in one of the separators. Can anyone help me please?
    Thanks.
    V.

    Hi,
    From the menu options window, you need to select "All Pages" for menu type. Please refer to the following screenshot :
    Please let me know if I am missing anything.
    Regards,
    Aish

  • Executing code modules (seperate jars) from main program (main.jar)

    Hi all
    Sorry if i am crossposting, but i dont think that is the case.
    I have a main program ( in a jar ) and some modules to be executed and run in the main program.
    Theese components are packed a module in a single jar, and all theese jars are located in the same folder as the main program.
    The main classes in the module jars implement a interface known to the main tool, so that i can use them.
    My problem are, how to load the modules?
    I know i can use JarFile to get the manifests, and thereby get the name of the main class in each jar (they get obfuscated before launch, so no hardcoding of names).
    But how do i instanciate the mainclasses in the modules from the main tool ?
    hope you can help out.
    -Anders

    You can't. I understand the module approach as many others have similar designs. The first problem is that you need to add all the JARs to your classpath so that these JARs are known during starttime. There is no other solution to this if you don't write your own classloader that fetches classes during runtime and work peacefully with the other classloaders of the VM (it's a pain in the ass!). So, your main application needs to know the JAR files. Then it's a small step to also register the modules that your main app should know. Our approach is to have a small database table that holds the fully referenced class names of the modules that are available and can be used via Class.forName(). With this solution, we just need to stop the main app, copy the new JAR, adjust the classpath to add the new JAR, and restart the main app. After adding the new module names to the config table, the main app automatically uses them. Instead of a database table you can use e.g. a properties file.

  • Why does main() need to be static?

    Hi all,
    I am trying to understand why
    public static void main(String[] args)needs to be static?
    I know that it needs to be available before the JVM creates an instance of the class containing the main method, but why is this the case? Is there some reason why the JVM cannot create an instance at that point?

    Hi all,
    i shall try to explai you this puzzle.
    for a class as follows:
    ========================================
    class abc{
    abc(){ ..... }
    public static void main(String[] a){
    ========================================
    when i compile it it runs perfectly but if i remove the static modifier from main it throws an exception.
    that is beacuse jvm lies outside the bounds of the class(opr default pacgage) and so if i want to call any method from there (or basically from outside the package) it has to be declared public.There should be no arguments here as this is the very idea of access protection.
    Now simce main returns nothing so it has to be void.The String array argument is place holders for command line arguments (thats for compatibility for users comming from c++)
    Now static why????
    in java when we call a classes constructor or when a class is instantiated all the prop[erties of that class are created with values or behaviour specific to that object and in general defined by the class.This you may agree with i suppose.Now if i need to call a method print of class abc then i need to first make an object of class abc (lets say ABC ) and call print as ABC.print("ddd"). This call shall execute the logic specifically defined in the behaviour of the particulay object ABC of class abc and this not necessarily  can be same as the default call behaviour.
    But suppose i have a method that always returns the sum of two integers no matter what object it resides in, I would make it statis because this method would not be a copy in all the objects created rather one master copy that all the objects would use.So now ABC.add() would return same as BCD.add(). But the thing is what do i need to do when i am calling this method for somewhere outside the package.(e/g jvm calling main)Since i don't have the object i cannot call the method.
    using static i can have an entry point into the jvm as static methods are executed using classname.methodname().
    Once the entry poinjt is loaded(main here) i can call the constructor ,make the object and proceed.
    hope this helps,
    waliv.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Newbie help with static main

    Im just getting into java and im having trouble with the main method.
    in particular, im trying to call another method, but when i compile i get the error:
    Lukatron.java [26:1] non-static method PowerMenu() cannot be referenced from a static context
    Is there a simple syntax error that i might have made, or should i provide more detail to work on?
    Thanks

    The method PowerMenu has not been declared static
    hence u cannot call it from a the main method.
    a static method(eg:- main method) can only access
    other static methods directly!
    If a static method has to call any non static method
    then it has to do it after creating an instance of the class that declares the non static method(eg:- PowerMenu).
    Try creating an instance of the class that declares the
    PowerMenu method and then call the method with the objects reference from the main method.
    eg:-
    ClassName obj = new ClassName();
    obj.PowerMenu();
    Regards,
    Partha

  • How can I assign image file name from Main() class

    I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
    Here is the Main class
    import org.me.lib.MyJNIWindowClass;
    public class Main {
    public Main() {
    public static void main(String[] args) {
    MyJNIWindowClass mw = new MyJNIWindowClass();
    mw.s = "clock.gif";
    And here is the library class
    package org.me.lib;
    public class MyJNIWindowClass {
    public String s;
    ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
    public MyJNIWindowClass() {
    JLabel jl = new JLabel(image);
    JFrame jf = new JFrame();
    jf.add(jl);
    jf.setVisible(true);
    jf.pack();
    I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
    Thank you.

    Your problem is one of timing. Consider this simple example.
    public class Example {
        public String s;
        private String message = "Hello, " + s;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example();
            ex.s = "world";
            System.out.println(ex.toString());
    }When this code is executed, the following happens in order:
    1. new Example() is executed, causing an object to constructed. In particular:
    2. field s is given value null (since no value is explicitly assigned.
    3. field message is given value "Hello, null"
    4. Back in method main, field s is now given value "world", but that
    doesn't change message.
    5. Finally, "Hello, null" is output.
    The following fixes the above example:
    public class Example {
        private String message;
        public Example(String name) {
            message = "Hello, " + name;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example("world");
            System.out.println(ex.toString());
    }

  • Execute jar file: "could not find the main class" program will terminate

    Hey,
    I am new to Java. I have started to make a small java program which supposed to help me at my studies to lean the Dominic Memory System. I have used the latest version of Netbeans 5.5.1 to build my program in. I have two problems which I cannot figure out how to solve, please help me.
    The first problem is that the java script I have made works when I compile it in Netbeans, but when I create a Jar file it does not work. I receive a pop up message in windows ?could not find the main class program will terminate? when I execute the jar file.
    The second problem I have is that I need to compare the strings generated by the "numbers" and "TIP" and if the numbers is not identical the numbers in the ?Center? JPanel should be highlighted as red.
    If anyone would like to clean up the code I would be pleased. I have copied quite a lot from anyone because of my one lack of knowledge.
    * GoListener.java
    * Created on 12. september 2007, 21:48
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package grandmaster;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Vector;
    import java.util.StringTokenizer;
    import java.awt.Color;
    * @author Computer
    public class GoListener implements ActionListener {
    private JTextField viewer;
    private JTextField TIP;
    private JTextField freq;
    private JTextField max_num;
    private Vector numbers;
    public GoListener(JTextField j,JTextField k, JTextField m, JTextField f, Vector n) {
    freq = f;
    max_num = m;
    viewer = j;
    numbers = n;
    TIP = k;
    public void actionPerformed(ActionEvent e){
    int time = Integer.valueOf(max_num.getText());
    int f = Integer.valueOf(freq.getText());
    if (e.getActionCommand() == "GO") {
    for (int i = 0; i< time;++i) {
    int number=0;
    number = (int)Math.floor(100*Math.random());
    while(number>51){
    number = (int)Math.floor(100*Math.random());
    if(number<=9){
    viewer.setText(" "+"0" + String.valueOf(number) + " ");
    } else{
    viewer.setText(" " + String.valueOf(number) + " ");
    viewer.paintImmediately(viewer.getBounds());
    numbers.add(number);
    try {
    Thread.sleep(f*1000);
    } catch (Exception exp) {
    viewer.setText(" XX ");
    viewer.paintImmediately(viewer.getBounds());
    if (e.getActionCommand() == "VIEW") {
    try {
    //int numb = Integer.valueOf( TIP.getText() ).intValue();
    StringTokenizer tokenizer = new StringTokenizer(TIP.getText(), " ");
    String[] split = null;
    int tokenCount = tokenizer.countTokens();
    if (tokenCount > 0) {
    split = new String[tokenCount];
    for (int current = 0; current < tokenCount; current++) {
    split[current] = tokenizer.nextToken();
    viewer.setText(" " + String.valueOf(numbers) + " ");
    // k=numbers(1);
    /*while(c<i){
    String.valueOf(k).equals(split[1]);
    c++;
    TIP.setText(" " + split[2] + " ");
    } catch (Exception exp) {
    try {
    //string testit = numb.toString();
    //String str = "" + numb;
    //viewer.setText(str);
    //viewer.setText(numbers.toString());
    numbers.clear();
    } catch (Exception exp) {
    * Main.java
    * Created on 12. september 2007, 21:07
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package grandmaster;
    import java.util.Vector;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.JButton;
    import java.awt.*;
    import grandmaster.GoListener;
    * @author Computer
    public class Main extends JFrame {
    private JTextField viewer;
    public JTextField TIP;
    // private TextInputPanel TIP;
    private Vector numbers;
    /** Creates a new instance of Main */
    public Main() {
    numbers = new Vector();
    JPanel p = new JPanel(new GridLayout(0,4));
    JButton go = new JButton();
    JButton view_num = new JButton();
    go.setText("Go!");
    go.setVisible(true);
    go.setActionCommand("GO");
    view_num.setText("VIEW");
    view_num.setVisible(true);
    view_num.setActionCommand("VIEW");
    JTextField max_num = new JTextField();
    max_num.setText("5");
    JTextField freq = new JTextField();
    freq.setText("1");
    viewer = new JTextField();
    viewer.setText("XX");
    TIP = new JTextField("");
    p.add(go);
    p.add(max_num);
    p.add(freq);
    p.add(view_num);
    getContentPane().add(p,BorderLayout.NORTH);
    getContentPane().add(viewer,BorderLayout.CENTER);
    getContentPane().add(TIP,BorderLayout.SOUTH);
    setSize(200,200);
    GoListener g = new GoListener(viewer,TIP,max_num, freq, numbers);
    go.addActionListener(g);
    view_num.addActionListener(g);
    * @param args the command line arguments
    public static void main(String[] args) {
    // TODO code application logic here
    Main window = new Main();
    window.setVisible(true);
    }

    NetBeans questions should be posted to the NB site. It has mailing lists and associated forums.
    This tutorial from the NB site addresses running programs outside of NB
    http://www.netbeans.org/kb/articles/javase-deploy.html
    When you compare objects, use ".equals()" and reserve == for comparing values.

  • How to append msg from second thread to main GUI thread?

    I am facing a problem which I cannot seem to solve.
    It involves Swing and threads. I have a main GUI running on swing. And it retrieves database information and displays it. On the same GUI I have a JTextArea box which I need another thread to update as and when that second thread recieves message via a multicast socket.
    I managed to create a runnable class of the second thread and successfully ran the second thread with the main thread in tandem. However when I use
    display.append(msgreceived);
    I get a nullPointerException. It works fine when i use System.out.println(msgreceived);.
    What should I have done instead?

    Here are part of the codes for my admin module.
    public class Admin extends JFrame implements ActionListener {
    //declares all the global variables
    private JTextArea display;
    public Admin() {
    super("BX Online - Admin Module");
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    AdminGUI();
    AdminGUI() {
    contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    JPanel newsbox = new JPanel();
    display = new JTextArea(2, 40);
    display.setEditable(false);
    newsbox.add(display);
    contentPane.add(newsbox);
    contentPane.add(tabpaneO);
    setBounds(70, 50, 300, 500);
    pack();
    setVisible(true);
    // all the methods activated by buttons goes here
    static public void main(String[] argv) {
    Admin a = new Admin();
    News b = new News("test");
    The following are part of the codes for my runnable class.
    public class News implements Runnable {
    protected boolean again = true;
    private String name, recieve; //the global variables
    private Thread t;
    public JTextArea display;
    public BXnews(String threadname) {
    name = threadname;
    t = new Thread(this, name);
    System.out.println("New Thread: " + t); //visual check to make sure thread is started.
    t.start();
    private void msg() {
    String recieve = ("testing");
    System.out.println(recieve);
    display.append(recieve);
    public void run() {
    while (again) //creates a loop so thread does not close
    {msg();}
    Well thats abt it. I'm not sure if you can compile this but basically the part I left out was the setup link for the News class which I don't see the need to add as what I primarily intend is for the message testing in News class to appear in Admin class thread in JTextArea "display".

  • How to make the main() thread wait?

    I would like to know how to make the main() thread wait for another thread?If I use wait() method in main() method it says "non-static method wait() cannot be referenced from a static context",since main()
    is static.

    Here is an example how you may wait for a Thread in the main -
    but be careful, this is no real OO:
    public class WaitMain {
    // this is the thread class - you may also create
    // a runnable - I use a inner class to
    // keep my example simple
         public static class ThreadWait extends Thread{
              public void doSomething(){
                   synchronized(syncObject){
                        System.out.println("Do Something");
                        syncObject.notify();
              public void run(){
                   // sleep 10 seconds - this is
                   // a placeholder to do something in the thread
                   try{
                        sleep(10000);
                        doSomething();
                        sleep(10000);
                   catch(InterruptedException exc){
    // this is the object we wait for -
    // it is just a synchronizer, nothing else
         private static Object syncObject = new Object();
         public static void main(String[] args) {
              System.out.println("This will start a thread and wait for \"doSomething\"");
              ThreadWait t= new ThreadWait();
              t.start();
              synchronized(syncObject){
                   try{
    // this will wait for the notify
                        syncObject.wait();
                        System.out.println("The doSomething is now over!");
                   catch(InterruptedException exc){
              // do your stuff

  • Main class should notify a thread! how?

    well as a test program I write an application that uses a infinite while loope containing:
    message = in.readLine()
    now I want the program to somehow tell my thread called "as1" that it has got a new string when in.readLine recives a text message
    thanks in advance
    .leonard

    Use code on these lines...
    public class NotificationTest
         private static Object notificationVehicle = new Object();
         public static final void main(String[] args)
              Thread notificationReceiver = new MyThread();
              notificationReceiver.start();
              while(true) {
                   // code that reads input stream goes here
                   synchronized(notificationVehicle) {
                        System.out.println("NotificationTest.main() ----- GENERATING NOTIFICATION");
                        notificationVehicle.notify();
         static class MyThread extends Thread
              public void run()
                   while(true) {
                        try {
                             synchronized(notificationVehicle) {
                                  notificationVehicle.wait();
                                  System.out.println(getClass().getName() + ".run() ----- CONSUMING NOTIFICATION");
                        } catch(InterruptedException interruptedException) {

  • How to control the main thread?

    public static void main(String args[]) {
    Thread t = Thread.currentThread();
    System.out.println("Current thread: " + t);
    In the above code, i want to know more about currentThread() method...
    if i execute, i get an error message,can anyone help me in this regard?

    When i execute the program, the program has an output
    as below:
    current thread:[main,5,main]
    But a window opens telling that there is some error
    in the program...
    Why does it happen so?What is the EXACT text of the error message?

  • Main Not found in Eclipse Editor

    Hello Guys!
    I am trying to run a simple java program in Eclipse for the first time, and it is giving me the error:
    " The active editor does not contain mail type".
    I am confused as where is the problem.
    Any sort of help will be highly appreciated.
    Thanx
    Harbir

    Check the signature of main. It is important that it is not any of:
    static public void Main(String [ ] args)
    public void main(String [ ] args)
    static void main(String [ ] args)
    void main(String [ ] args)
    static public void main()but
    static public void main(String [ ] args)(The void can be replaced by int also) If you have a method in a class named like this you
    should be able to follow ChristianMenne's instructions. If not ask in a eclipse newsgroup
    at http://www.eclipse.org

  • Need help getting Main method to work...

    Hello everyone, I have a problem, I have a GUI that I need to run (it compiles fine, but will not run.) I am very new to Java and programing in general so go easy on me. I think I am just missing something simple here. I am going to post the basic code and see if you all can help...the issue is in written in red to help you identify my problem...
    public class LagersGUI extends JFrame implements ActionListener,Serializable
    {color:#0000ff}private {color}JTextArea {color:#339966}textArea{color};
    {color:#0000ff}private {color}JButton {color:#339966}start,
    next,
    previous,
    last;{color}
    JLabel {color:#339966}imageLabel{color};
    {color:#0000ff}private static{color} LagersAddInfo {color:#339966}inv{color} = {color:#0000ff}new {color}LagersAddInfo();
    {color:#808080} /**
    * @param arg0
    * @throws HeadlessException
    */{color}
    {color:#0000ff}public {color}LagersGUI( String arg0 ) {color:#0000ff}throws {color}HeadlessException
    {color:#0000ff}super{color}( {color:#ff9900}"Inventory GUI" {color});
    {color:#339966}textArea{color} = {color:#0000ff}new {color}JTextArea( 800,800 );
    JScrollPane scrollPane = new JScrollPane( {color:#339966}textArea{color} );
    textArea.setEditable( {color:#0000ff}false {color});
    scrollPane.setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS );
    scrollPane.setPreferredSize( new Dimension( 600, 100 ) );
    JPanel cp = new JPanel();
    cp.setSize( 400, 100 );
    cp.setLayout( new BorderLayout() );
    cp.add( scrollPane,BorderLayout.{color:#339966}CENTER{color} );
    JPanel buttonPanel = new JPanel();
    JPanel buttonPanel1 = new JPanel();
    {color:#339966}start{color} = new JButton( {color:#ff9900}"Start"{color} );
    {color:#339966}start{color}.addActionListener( {color:#0000ff}this {color});
    {color:#339966} next{color} = new JButton( {color:#ff9900}"Next" {color});
    {color:#339966} next{color}.addActionListener( {color:#0000ff}this {color});
    {color:#339966}previous{color} = new JButton( {color:#ff9900}"Previous"{color} );
    {color:#339966} previous{color}.addActionListener( {color:#0000ff}this {color});
    {color:#339966} last{color} = new JButton({color:#ff9900} "Last"{color} );
    {color:#339966} last{color}.addActionListener( {color:#0000ff}this {color});
    buttonPanel.add( {color:#339966}start {color});
    buttonPanel.add( {color:#339966}next {color});
    buttonPanel.add( {color:#339966}previous {color});
    buttonPanel.add( {color:#339966}last {color});
    cp.add( buttonPanel,BorderLayout.{color:#339966}SOUTH {color});
    cp.add( buttonPanel1,BorderLayout.{color:#339966}NORTH {color});{color:#999999}///NewInventory_Test/logo.gif{color}
    java.net.URL u = {color:#0000ff}this{color}.getClass().getClassLoader().getResource({color:#ff9900}"\\NewInventory_Test\\logo.gif"{color});
    ImageIcon icon = {color:#0000ff}new {color}ImageIcon(u);
    {color:#339966}imageLabel{color} = new JLabel( {color:#ff9900}"Inventory View"{color}, icon, JLabel.{color:#339966}CENTER {color});
    cp.add({color:#339966} imageLabel{color},BorderLayout.{color:#339966}WEST{color} );
    {color:#0000ff}this{color}.setContentPane( cp );
    {color:#0000ff}this{color}.setContentPane( cp );
    {color:#0000ff}this{color}.setTitle( "Inventory Program IT 215" );
    {color:#0000ff}this{color}.setDefaultCloseOperation( JFrame.{color:#339966}EXIT_ON_CLOSE{color} );
    {color:#0000ff} this{color}.{color:#339966}textArea{color}.setText({color:#339966}inv{color}.getStart());
    {color:#0000ff} this{color}.setSize(200, 200);
    {color:#0000ff}this{color}.pack();
    {color:#0000ff}this{color}.setVisible( {color:#0000ff}true {color});
    @Override
    {color:#0000ff}public void{color} actionPerformed( ActionEvent e )
    // TODO Auto-generated method stub
    {color:#0000ff} if {color}( e.getActionCommand().equals({color:#ff9900} "Start"{color} ) )
    textArea.setText( {color:#339966}inv{color}.getStart() );
    {color:#0000ff}if {color}( e.getActionCommand().equals( {color:#ff9900}"Next" {color}) )
    textArea.setText({color:#339966}inv{color}.getNext());
    {color:#0000ff}if{color} ( e.getActionCommand().equals( {color:#ff9900}"Previous" {color}) )
    textArea.setText( {color:#339966}inv{color}.getPrevious() );
    {color:#0000ff} if{color} ( e.getActionCommand().equals( {color:#ff9900}"Last"{color} ) )
    textArea.setText({color:#339966}inv{color}.getLast());
    {color:#0000ff}public static {color}LagersAddInfo getInv()
    {color:#0000ff}return{color:#339966} {color}{color}{color:#339966}inv{color};
    {color:#0000ff}public static void{color} setInv( LagersAddInfo inv )
    LagersGUI.{color:#339966}inv {color}= inv;
    {color:#808080} /**
    * @param args
    */{color}
    {color:#0000ff}public static void {color}main( String[] args )
    LagersGUI {color:#ff0000}_inventory_ {color}= {color:#0000ff}new {color}LagersGUI( {color:#ff9900}"Inventory"{color} );{color:#ff0000}//** here's the part I'm having trouble with...inventory is an * unused variable. What other way could I get {color:#000000}main{color} */ method to work?{color}
    }

    This forum can format your code for you and make it easier to read. Simply click the CODE button and two tags will appear. Then paste your code in between the tags. Important, copy code form your source not first post.                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Maybe you are looking for