How do you add a GUI to your scripts?

Hey, I’m sorry if this question has been asked a numerous amount of times. I haven’t been able to find the (correct) answer myself.

I have tried adding a GUI to my fishing script via the IntelliJ swing GUI designer but it won’t really show up. I’ve got the following code:


import javax.swing.*;

public class FishGui {
    private JComboBox cmbFishType;
    private JPanel FishGui;
    private JButton btnStart;

    public static void main(String[] args) {
        JFrame frame = new JFrame("FishGui");
        frame.setContentPane(new FishGui().FishGui);

so I call it in my main’s onStart method like so:

    public void onStart()
        FishGui fishGui = new FishGui();

But the form won’t show up. I’m not sure if I described the correct parts here but is there a “good” or default way this should be done? Thanks in advance for your time.

By creating an instance of FishGui, you’re calling the constructor - not the main method. You should move that code into a constructor, scripts don’t use main methods