Swing GUI error

Hi there, I'm trying to create java application using swing GUI. I've added JButton on the form, checked the "Custom Create" option in inspector, but the compiler throws an error.
Main.java
public class Main {
    public static void main(String[] args) {
        Form MyForm = new Form();
    }
}

Form.java
import javax.swing.*;
public class Form extends JFrame{
    private JButton button1;
    private void createUIComponent()
    {
        button1 = new JButton();
    }
}

Error:
forms: $PATH$/Form.form: Form contains components with Custom Create option but no createUIComponents() method
1 comment

Please make sure the name of the method ends with "Components", not "Component", as in your sample.

BTW, I see "Form extends JFrame" in your code. Actually an IDEA GUI form is aimed to be content panel (e.g. one of JFrame), not JFrame itself.

Regards,
Alexander.

0

Please sign in to leave a comment.