Skip to main content
se añadieron 59 caracteres en el cuerpo; título editado
Origen Enlace
sstan
  • 16.9k
  • 2
  • 24
  • 48

Error Netbeans al colocar titulo, ejercicio javasetear el título en el constructor de un JFrame

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);
  } 
  }

Error al colocar titulo, ejercicio java

Estoy realizando un ejercicio en java, donde me muestre nombres en diferente colores en un cuadro texto. Sin embargo, en netBeans no me lo ejecuta dandome 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.

 /*
  * 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(){
    **setTitle("Dos Elipses");**
}
}
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);
  } 
  }

Error Netbeans al setear el título en el constructor de un JFrame

Estoy realizando un ejercicio en java, donde me muestra nombres en diferentes colores en un cuadro texto. Sin embargo, en Netbeans no me lo ejecuta dándome el siguiente mensaje, en 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(){
    setTitle("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);
  } 
  }
etiquetas editadas
Enlace
sstan
  • 16.9k
  • 2
  • 24
  • 48

/*

  • 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(){ setTitle("Dos Elipses"); } } 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); } }

 /*
  * 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(){
    **setTitle("Dos Elipses");**
}
}
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);
  } 
  }

/*

  • 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(){ setTitle("Dos Elipses"); } } 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); } }

 /*
  * 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(){
    **setTitle("Dos Elipses");**
}
}
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);
  } 
  }
Origen Enlace
Loading