Contentimport javax.swing.*;import java.awt.*;import java.awt.event.*;class MainForm extends JFrame {private String nim;private String nama;MainForm() {nim = "";nama = "";// 1 - containerContainer c = getContentPane();// 2 - layout managerc.setLayout(new BorderLayout());setVisible(true);setSize(800, 600);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 3 - komponenfinal JDesktopPane desktop = new JDesktopPane();c.add(desktop);// 1 - buat obyek menubarJMenuBar menuBar = new JMenuBar();setJMenuBar(menuBar); // 2 set menubar sebagai menubar aktif// 3 - tambah menuJMenu menu1 = new JMenu("Program");JMenu menu2 = new JMenu("Contoh JCheckBox");JMenu menu3 = new JMenu("Help");menuBar.add(menu1);menuBar.add(menu2);menuBar.add(menu3);// 4 - tambah itemJMenuItem item1 = new JMenuItem("Exit");JMenuItem item2 = new JMenuItem("Contoh 1");JMenuItem item3 = new JMenuItem("Contoh 2");JMenuItem item4 = new JMenuItem("About Us");menu1.add(item1);menu2.add(item2);menu2.add(item3);menu3.add(item4);// action listeneritem1.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {System.exit(0);}});item2.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// membuat form siswaJInternalFrame frameContoh2 =new JInternalFrame("Contoh JChecBox 1", true, true, true,true);frameContoh2.setVisible(true);frameContoh2.setSize(300,200);desktop.add(frameContoh2);JCheckBox check5 = new JCheckBox("KELOMPOK TUJUH");frameContoh2.add(check5);}});item3.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// membuat form siswaJInternalFrame frameContoh1 = new JInternalFrame("Contoh JCheckBox 2", true, true ,true, true);frameContoh1.setVisible(true);frameContoh1.setSize(300,200);desktop.add(frameContoh1);/*JCheckBox check1 = new JCheckBox("STMIK");frameContoh1.add(check1);JCheckBox check2 = new JCheckBox("AMIKOM");frameContoh1.add(check2);JCheckBox check3 = new JCheckBox("YOGYAKARTA");frameContoh1.add(check3);*/JCheckBox cek4 = new JCheckBox("STMIK AMIKOM YOGYAKARTA",true);frameContoh1.add(cek4);}});item4.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {// membuat form siswaJInternalFrame frameAbout =new JInternalFrame("About Kelompok 7", true, true, true,true);frameAbout.setVisible(true);frameAbout.setSize(300,200);desktop.add(frameAbout);JTextArea teks = new JTextArea();teks.setColumns(30);teks.setRows(30);teks.setText("r3m1ck \n INDONESIANHACKER.ORG");frameAbout.add(teks);}});}public static void main (String [] args) {new MainForm();}}silahkan dicoba
Tidak ada komentar :
Posting Komentar