Ошибка при добавлении переменной в контейнер - No context actions available at this location
При попытке добавить переменную в контейнер, получаю сообщение:
No context actions available at this location.
А в заголовке не написано "Анкета".
import javax.swing.*;
import java.awt.*;
public class Main {
public static void main(String[] args){
ContactForm form = new ContactForm();
form.setVisible(true);
}
}
public class ContactForm extends JFrame {
public ContactForm(){
super("Анкета");
super.setBounds(400, 400, 500, 250);
super.setDefaultCloseOperation(EXIT_ON_CLOSE);
Container container = super.getContentPane();
container.setLayout(new GridLayout(3, 2, 2, 2));
String name = JOptionPane.showInputDialog("Назовите ваше имя");
String input = JOptionPane.showInputDialog("Сколько вам лет");
int age = Integer.parseInt(input);
>вот здесь ошибка при попытке добавить переменную
container.add(name);
container.add(age);
System.exit(0);
}
}

