El error es el siguiente:
No enclosing instance of type Ventana is accessible. Must qualify the allocation with an enclosing instance of type Ventana (e.g. x.new A() where x is an instance of Ventana). |
import java.awt.Color; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; public class Ventana { class ventanita extends JFrame{ ventanita(){ JFrame ventana = new JFrame("TITULO"); this.setSize(Toolkit.getDefaultToolkit().getScreenSize()); this.setResizable(false); panel panel = new panel(); this.add(panel); this.setVisible(true); } } class panel extends JPanel{ panel(){ JPanel panel = new JPanel(); this.setBackground(Color.black); botoncierre b1 = new botoncierre(); this.add(b1); } } class botoncierre extends JButton{ JButton close = new JButton(); botoncierre(){ cierre cerrar = new cierre(); this.addActionListener(cerrar); } } class cierre implements ActionListener{ public void actionPerformed(ActionEvent e){ System.exit(0); } } public static void main(String[]args){ ventanita demo = new ventanita(); } } |
Muchas gracias