package EJERCICIOS2PANELES;
import java.awt.*;
import java.awt.event.*;
public class PanelSolo {
public static void main(String[] args) {
Frame f = new Frame("Ejemplo");
Panel p0 = new Panel();
Panel p1 = new Panel();
Panel p2 = new Panel();
Panel p3 = new Panel();
Panel p4 = new Panel();
f.add(p0,"North");
f.add(p1,"West");
f.add(p2,"South");
f.add(p3,"Center");
f.add(p4,"East");
p0.setBackground(Color.blue);
p0.setSize(200, 250);
p1.setBackground(Color.green);
p2.setBackground(Color.yellow);
p3.setBackground(Color.white);
p4.setBackground(Color.red);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
f.pack(); //despliego la ventana
f.setVisible(true);
}
}
____________________________________________________________________
package EJERCICIOS2PANELES;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class ejercicio2 extends Panel{
ejercicio2(){
setBackground(Color.white);
}
public void paint(Graphics g){
g.drawRect(5,5,getWidth()-10,getHeight()-10);
}
public Dimension getPreferredSize(){
return new Dimension (120,90);
}
public static void main (String[]args){
Frame ventana = new Frame();
ejercicio2 panelnorte = new ejercicio2();
ejercicio2 paneloeste = new ejercicio2();
ejercicio2 panelcentro = new ejercicio2();
ejercicio2 paneleste = new ejercicio2();
ejercicio2 panelsur = new ejercicio2();
ventana.setVisible(true);
ventana.add(panelnorte, "North"); //Panel de arriba
ventana.add(paneloeste, "West"); //Panel izquierda
ventana.add(panelcentro, "Center"); //Panel central
ventana.add(paneleste, "East"); //Panel derecha
ventana.add(panelsur, "South"); //Panel sur
ventana.pack();
ventana.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}});
}}
import java.awt.*;
import java.awt.event.*;
public class PanelSolo {
public static void main(String[] args) {
Frame f = new Frame("Ejemplo");
Panel p0 = new Panel();
Panel p1 = new Panel();
Panel p2 = new Panel();
Panel p3 = new Panel();
Panel p4 = new Panel();
f.add(p0,"North");
f.add(p1,"West");
f.add(p2,"South");
f.add(p3,"Center");
f.add(p4,"East");
p0.setBackground(Color.blue);
p0.setSize(200, 250);
p1.setBackground(Color.green);
p2.setBackground(Color.yellow);
p3.setBackground(Color.white);
p4.setBackground(Color.red);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
f.pack(); //despliego la ventana
f.setVisible(true);
}
}
____________________________________________________________________
package EJERCICIOS2PANELES;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class ejercicio2 extends Panel{
ejercicio2(){
setBackground(Color.white);
}
public void paint(Graphics g){
g.drawRect(5,5,getWidth()-10,getHeight()-10);
}
public Dimension getPreferredSize(){
return new Dimension (120,90);
}
public static void main (String[]args){
Frame ventana = new Frame();
ejercicio2 panelnorte = new ejercicio2();
ejercicio2 paneloeste = new ejercicio2();
ejercicio2 panelcentro = new ejercicio2();
ejercicio2 paneleste = new ejercicio2();
ejercicio2 panelsur = new ejercicio2();
ventana.setVisible(true);
ventana.add(panelnorte, "North"); //Panel de arriba
ventana.add(paneloeste, "West"); //Panel izquierda
ventana.add(panelcentro, "Center"); //Panel central
ventana.add(paneleste, "East"); //Panel derecha
ventana.add(panelsur, "South"); //Panel sur
ventana.pack();
ventana.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}});
}}
No hay comentarios:
Publicar un comentario