Coño, apenas empiezo con java en entorno gráfico, y tengo la siguiente clase y no se que os pasa.
class createNewWindows extends Frame{
public createNewWindows(String pTitle, Integer pX, Integer pY, Integer pwidth, Integer pHeight){
super(pTitle);
this.setBounds(pX, pY, pwidth, pHeight);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setVisible(true);
}
}
alex@shellroot:~/Escritorio$ javac PoC.java
PoC.java:23: cannot find symbol
symbol : variable EXIT_ON_CLOSE
location: class createNewWindows
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
^
1 error
Alguna sugerencia?
Frame es de AWT, el de Swing es JFrame y en el es que puedes llamar el metodo
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
para especificar el modo en que se comportara la acción de cerrar.
Desde Frame tendrías que agregar un WindowListener para poder cerrar en "x"
Un saludo.
Ok, ok, ok, también estuve mirando eso de WindowListener. Así que entonces me tocará con ese. mmm lo intentaré.
:-*
Lo solucioné así,
class createNewWindows extends Frame{
public createNewWindows(String pTitle, Integer pX, Integer pY, Integer pwidth, Integer pHeight){
super(pTitle);
this.setBounds(pX, pY, pwidth, pHeight);
this.setLocationRelativeTo(null);
this.setBackground(Color.black);
this.setForeground(Color.white);
this.addWindowListener(new WindowListener(){
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){}
public void windowClosing(WindowEvent e){e.getWindow().dispose();}
});
this.setVisible(true);
}
}
Mejor asi si no vas a usar implementar ninguna accion en maximizar y minimizar.
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent event){
dispose();
System.exit(0);
}
});
un saludo.
no es necesario poner un listener vasta con
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
Si te fijas bien, eso fue lo que hice en el primer post
Aprovecho para preguntar, como hago que un Label tenga Arial de 30px?
Cita de: Shell Root en 4 Noviembre 2010, 21:32 PM
Si te fijas bien, eso fue lo que hice en el primer post
Aprovecho para preguntar, como hago que un Label tenga Arial de 30px?
label1.setFont(new java.awt.Font("Arial", 0, 30));
Así