How do I replace "this" in Java with something that works.
- by Luke Alderton
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
}
}