package interfaces;
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
public class BorderLayoutTest {
/**
* @param args
*/
public static void main(String[] args) {
Frame f=new Frame();
f.setTitle("Border Layout Test");
//f.setSize(200, 150);
f.setLayout(new BorderLayout());
//si cambio el border por flowLayout los botones apareceran de forma horizontal
Button b1=new Button("Button 1 (Norte)");
f.add(b1,BorderLayout.NORTH);
Button b2=new Button("Boton 2(Oeste)");
f.add(b2,BorderLayout.WEST);
Button b3=new Button("Boton 3(Centro)");
f.add(b3,BorderLayout.CENTER);
Button b4=new Button("Boton 4(este)");
f.add(b4,BorderLayout.EAST);
Button b5=new Button("boton 5(Sur)");
f.add(b5,BorderLayout.SOUTH);
f.pack();
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
f.setVisible(true);
}
}
No hay comentarios:
Publicar un comentario