You are on page 1of 5

FRAME SATU

import java.awt.*;

import javax.swing.*;

import java.awt.event.*;

public class FrameSatu extends JFrame implements ActionListener{

//constructor

public FrameSatu (){

this.setSize(900,900);

this.setLocationRelativeTo(null);

this.setTitle("Frame 1");

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

layoutComponents();

public void layoutComponents(){

JPanel main = new JPanel ();

main.setLayout(new GridLayout (1,3));

add(main);

JPanel box1 = new JPanel(), box2 = new JPanel(), box3 = new JPanel();

box1.setLayout (new GridLayout (1,1));

main.add(box1);

box2.setLayout(new GridLayout (7,1));

box2.add(new JPanel());

JPanel kotak = new JPanel();

kotak.setBackground(Color.red);

box2.add(kotak);

JLabel nim = new JLabel("NIM");

box2.add(nim, BorderLayout.WEST);

JLabel nama = new JLabel("Nama");


box2.add(nama, BorderLayout.WEST);

JLabel angkatan = new JLabel ("Angkatan");

box2.add(angkatan,BorderLayout.WEST);

JPanel button = new JPanel();

button.setLayout(new GridLayout (1,3));

button.add(new JPanel());

button.add(new JPanel());

JButton ok = new JButton ("Ok");

ok.setActionCommand("1");

ok.addActionListener(this);

button.add(ok);

box2.add(button);

box2.add(new JPanel());

main.add(box2);

box3.setLayout (new GridLayout (1,1));

main.add(box3);

@Override

public void actionPerformed(ActionEvent e) {

String str = e.getActionCommand();

if ("1".equals(str)) {

FrameDua x = new FrameDua();

x.setVisible(true);

}
FRAME DUA
import java.awt.*;

import javax.swing.*;

public class FrameDua extends JFrame {

//constructor

public FrameDua (){

this.setSize(500,500);

this.setLocation(0,0);

this.setTitle("Frame 1");

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

layoutComponents();

public void layoutComponents(){

JPanel box = new JPanel ();

box.setLayout(new GridLayout (1,5));

add(box);

JPanel box1 = new JPanel(), box2 = new JPanel(), box3 = new JPanel(), box4 = new JPanel(), box5
= new JPanel();

box1.setLayout(new GridLayout (1,1));

box.add(box1);

box2.setLayout(new GridLayout (9,1));

box2.add(new JPanel());

JPanel merah = new JPanel(), merah1 = new JPanel(), merah2 = new JPanel(), merah3 = new
JPanel(), merah4 = new JPanel(), merah5 = new JPanel(), merah6 = new JPanel();

merah.setBackground(Color.red);

merah1.setBackground(Color.red);

merah2.setBackground(Color.red);

merah3.setBackground(Color.red);
merah4.setBackground(Color.red);

merah5.setBackground(Color.red);

merah6.setBackground(Color.red);

box2.add(merah);

box2.add(merah1);

box2.add(merah2);

box2.add(merah3);

box2.add(merah4);

box2.add(merah5);

box2.add(merah6);

box2.add(new JPanel());

box.add(box2);

box3.setLayout(new GridLayout (1,1));

box.add(box3);

box4.setLayout (new GridLayout (9,1));

box4.add(new JPanel());

JPanel biru = new JPanel();

biru.setBackground(Color.blue);

box4.add(biru);

box4.add(new JPanel());

JPanel hijau = new JPanel();

hijau.setBackground(Color.green);

box4.add(hijau);

box4.add(new JPanel());

JPanel orange = new JPanel();

orange.setBackground(Color.orange);

box4.add(orange);

box4.add(new JPanel());

JPanel kuning = new JPanel();


kuning.setBackground(Color.yellow);

box4.add(kuning);

box4.add(new JPanel());

box.add(box4);

box5.setLayout(new GridLayout (1,1));

box.add(box5);

MAIN CONTROLLER

public class MainControllerFrameSD {

public static void main(String[] args) {

FrameSatu x = new FrameSatu();

x.setVisible(true);

You might also like