Rabu, 21 Desember 2011

Soal1_uts1

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package testSoal_1;

import javax.swing.*;

/**
 *
 * @author admin
 */
public class Soal_1 extends JFrame{
JMenuBar menuBar;
JMenu utama1,utama2;
JMenuItem a1,a2,a3,a4,a5;
JLabel l1;
JTextField t1;
JButton but1;
    public Soal_1(){
        super("UTS Soal");
        menuBar = new JMenuBar();

        utama1 = new JMenu("Utama 1");
        menuBar.add(utama1);

        utama2 = new JMenu("Utama 2");
        menuBar.add(utama2);

        a1 = new JMenuItem("Menu 1A");
        utama1.add(a1);

        a2 = new JMenuItem("Menu 1B");
        utama1.add(a2);
        utama1.addSeparator();

        a3= new JMenuItem("Menu 1C");
        utama1.add(a3);
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        a4=new JMenuItem("Menu 2A");
        utama2.add(a4);

        a5=new JMenuItem("Menu 2B");
        utama2.add(a5);

        this.setJMenuBar(menuBar);

    }

}
kelas main
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package testSoal_1;

import javax.swing.*;

/**
 *
 * @author admin
 */
public class Soal_1 extends JFrame{
JMenuBar menuBar;
JMenu utama1,utama2;
JMenuItem a1,a2,a3,a4,a5;
JLabel l1;
JTextField t1;
JButton but1;
    public Soal_1(){
        super("UTS Soal");
        menuBar = new JMenuBar();

        utama1 = new JMenu("Utama 1");
        menuBar.add(utama1);

        utama2 = new JMenu("Utama 2");
        menuBar.add(utama2);

        a1 = new JMenuItem("Menu 1A");
        utama1.add(a1);

        a2 = new JMenuItem("Menu 1B");
        utama1.add(a2);
        utama1.addSeparator();

        a3= new JMenuItem("Menu 1C");
        utama1.add(a3);
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        a4=new JMenuItem("Menu 2A");
        utama2.add(a4);

        a5=new JMenuItem("Menu 2B");
        utama2.add(a5);

        this.setJMenuBar(menuBar);

    }

}

Tidak ada komentar:

Posting Komentar