Run GUI from another class?

I built a GUI and now I am trying to run it from the controller class (main.java). I do not know how to do that. Executing it does not work (i.e. GUI gui = new GUI (), does not work).

It seems to me that there is something obvious here, I am absent here, but an extensive search on Google did not give me any results.

I am trying to run a GUI in the main thread and have a separate thread to make calls to process the code (a separate thread that I still have to do) if this has anything to do with the issue. (I don't know, I'm new to Java and programming!)

+4
source share
1 answer

If your GUI is a Swing application, and if it extends JFrame (something I try to avoid), sometimes you also need to add

GUI gui = new GUI(); gui.setVisible(true); 

But for more help you need to provide us with more detailed information. In addition, if you are creating Swing applications, there is a wonderful set of tutorials that you can find here: Swing tutorials. They can help you create and run the Swing GUI, and more importantly, understand what your code does.

+7
source

Source: https://habr.com/ru/post/1386363/


All Articles