Estoy realizando un ejercicio en java, donde me muestremuestra nombres en diferentediferentes colores en un cuadro texto. Sin embargo, en netBeansNetbeans no me lo ejecuta dandomedándome el siguiente mensaje, en mi setTitle("Dos Elipses");
Calling methods that can be overridden can be dangerous in the contructor because in the moment when the overridden method is called the object is not fully initialized.la sentencia setTitle("Dos Elipses");
:
Calling methods that can be overridden can be dangerous in the constructor because in the moment when the overridden method is called the object is not fully initialized.
Código:
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package j009;
/**
*
* @author
*/
import java.awt.*;
import java.awt.event.*;
class j009 extends Frame{
public j009(){
**setTitlesetTitle("Dos Elipses");**; // <------------ aquí está el error
}
}
public class J009 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Frame f = new j009();
f.addWindowListener(new WindowAdapter(){
public void windowCLosing(WindowEvent e){
System.exit(0);
}
});
f.setSize(400,300);
f.setVisible(true);
}
public void paint(Graphics g){
g.setColor(Color.red);
g.drawString("Hola",50,50);
g.setColor(Color.blue);
g.drawString("Hola", 100, 100);
g.setColor(Color.green);
g.drawString("Hola", 200, 150);
g.setColor(Color.yellow);
g.drawString("Hola", 300, 200);
}
}