Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Non-static methods and static contexts

807600Nov 16 2007 — edited Nov 16 2007
I'm still quite new to Java, but a lot of the time I experience this error. For example, the compiler throws an error in the main() method in this program. Usually I get around it by changing all methods and variables to static but there must be another way?
package convertor;
import java.io.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;

public class Main {
    private JFrame mainwindow;
    private JButton gobutton;
    private JTextField input;

    public Main() {
    }
    
    public void drawgui() {
        
    }
    
    public static void main(String[] args) {
        drawgui();
    }
    
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 14 2007
Added on Nov 16 2007
13 comments
525 views