Не работает addAncestorListener() и super(). как заставить работать? - Java
Формулировка задачи:
Не могу подключить "javax.swing.JFrame;"
Пользуюсь Eclipse.
Прописываю javax.swing.JFrame;. Подчеркивает красной волной (как ошибку).
И все места, где я использовал "упоминал" javax.swing.JFrame подчеркивает как ошибку
.
Код такой
import javax.swing.*;
import java.awt.*;
public class chot extends JFrame {
OnClicFoBatton OCB = new OnClicFoBatton();
int a;
public static void main(String[] args) {
// создал окно
chot forma = new chot(); // для окна
forma.setVisible(true);
forma.setSize(200, 300);
forma.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//button.setVisible(true);
// создал кнопку
JButton plys1 = new JButton("+");
plys1.setVisible(true);
forma.add (plys1, BorderLayout.EAST); // показал кнопку на текстовом поле
// создал кнопку
JButton plys2 = new JButton("-");
plys2.setVisible(true);
forma.add (plys2, BorderLayout.WEST); // показал кнопку на текстовом поле
// текст
JLabel label = new JLabel ("0");
label.setVisible(true);
forma.add (label, BorderLayout.CENTER);
label.setText("Сам текст");
//plys1.addAncestorListener(a=5);
// super("счетчик очков");
} //public static void main(String[] args)
} // public class chot
что то форум глюканул...
Или я..
Короче не работает addAncestorListener() и super(). как заставить работать? (я их законопатил в самом низу кода. )
Решение задачи: «Не работает addAncestorListener() и super(). как заставить работать?»
textual
Листинг программы
Exception in thread "main" java.lang.Error: Unresolved compilation problems: Access restriction: The method setDefaultCloseOperation(int) from the type JFrame is not accessible due to restriction on required library /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar Access restriction: The type JFrame is not accessible due to restriction on required library /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar Access restriction: The field EXIT_ON_CLOSE from the type JFrame is not accessible due to restriction on required library /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/rt.jar at chot.main(chot.java:13)