How do I replace "this" in Java with something that works.
        Posted  
        
            by 
                Luke Alderton
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Luke Alderton
        
        
        
        Published on 2011-01-05T22:46:42Z
        Indexed on 
            2011/01/05
            22:53 UTC
        
        
        Read the original article
        Hit count: 222
        
I'm looking to get the showGUI() method work, the compiler says "this" is not a static variable and cannot be referenced from a static context, what would I use to replace "this"? I've tried test.main (test being the package it's in). The reason I'm using the static method showGUI() is because I need the method to be called from another static method, as well as the startup() method. Below are my two main classes.
public class Main extends SingleFrameApplication {
    @Override protected void startup() {
        showGUI();
    }
    @Override protected void configureWindow(java.awt.Window root) {
    }
    public static Main getApplication() {
        return Application.getInstance(Main.class);
    }
    public static void main(String[] args) {
       launch(Main.class, args);
    }
    public static void showGUI() {
        show(new GUI(this));
    }
}
public class GUI extends FrameView {
    public GUI(SingleFrameApplication app) {
        super(app);
        initComponents();
    }
    private void initComponents() {
        //all the GUI stuff is somehow defined here
    }
}
© Stack Overflow or respective owner