berikut contoh sintaknya :
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BorderLayoutApp2 extends JFrame {
public BorderLayoutApp2( ) {
createUserInterface();
}
private void createUserInterface(){
this.setTitle("Border2");
this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
this.setSize(225, 150);
this.setLocation(200, 200);
this.setVisible(true);
this.setLayout(new BorderLayout( ));
JPanel p = new JPanel( );
p.add(new JButton("North"));
this.add(p, BorderLayout.NORTH);
p = new JPanel( );
p.add(new JButton("South"));
this.add(p, BorderLayout.SOUTH);
p = new JPanel( );
p.add(new JButton("East"));
this.add(p, BorderLayout.EAST);
p = new JPanel( );
p.add(new JButton("West"));
this.add(p, BorderLayout.WEST);
p = new JPanel( );
p.add(new JButton("Center"));
this.add(p, BorderLayout.CENTER);
}
public static void main(String[] args) {
BorderLayoutApp2 app = new BorderLayoutApp2();
}
}
0 komentar:
Posting Komentar