Tugas Praktikum Java 4

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Tugas Praktikum Java 4 as PDF for free.

More details

  • Words: 304
  • Pages: 5
TUGAS PRAKTIKUM PEMROGRAMAN JAVA II Modul 4 EVENT HANDLING

Disusun oleh : LITRA ZIKRI DITA 123080126 Plug 9

Assisten : YOGI TOGYANTARA

JURUSAN TEKNIK INFORMATIKA FAKULTAS TEKNOLOGI INDUSTRI UPN ”VETERAN” YOGYAKARTA 2009 import javax.swing.*; import java.awt.event.*;

import java.awt.*; class CobaMenu extends JFrame { JMenuBar menubar; JMenu file, doc, edit, help,tools; JMenuItem open, save, exit, undo, copy, paste, about,license,colour,font; JTextArea A; JPanel p1,p2; JButton bOk,bCancel; public CobaMenu(){ setTitle("Menu"); setSize(200,200); p1 = new JPanel(); p2 = new JPanel(); A = new JTextArea(); bOk = new JButton("Ok"); bCancel = new JButton("Cancel"); p1.setLayout(new GridLayout(1,1)); p1.add(A); p2.setLayout(new GridLayout(1,2)); p2.add(bOk); p2.add(bCancel); setLayout(new BorderLayout()); add(p1,"Center"); add(p2,"South"); file = new JMenu ("File"); file.setMnemonic('F'); doc = new JMenu ("Edit"); doc.setMnemonic('D'); tools = new JMenu ("tools"); tools.setMnemonic('h'); colour = new JMenuItem ("colour"); colour.setMnemonic('p'); font = new JMenuItem ("font"); font.setMnemonic('f');

ImageIcon gbre = new ImageIcon("Open.jpg"); edit = new JMenu ("Edit"); edit.setMnemonic('E'); help = new JMenu ("Help"); help.setMnemonic('H'); ImageIcon gbro = new ImageIcon("Open.jpg"); open = new JMenuItem ("Open",gbro);

open.setMnemonic('O'); open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.ALT_MASK)); ImageIcon gbrs = new ImageIcon("save.jpg"); save = new JMenuItem ("Save",gbrs); save.setMnemonic('S'); save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK)); exit = new JMenuItem ("Exit"); exit.setMnemonic('E'); copy = new JMenuItem ("Copy"); copy.setMnemonic('C'); paste = new JMenuItem ("Paste"); paste.setMnemonic('p'); undo = new JMenuItem ("undo"); undo.setMnemonic('u'); about = new JMenuItem ("About"); about.setMnemonic('P'); license = new JMenuItem ("License"); license.setMnemonic('P'); menubar = new JMenuBar(); setJMenuBar(menubar); menubar.add(file); file.add(open); file.add(save); file.addSeparator(); file.add(exit); menubar.add(doc); doc.add(undo);//jmenu doc.add(copy);//jmenuitem doc.add(paste);//jmenuitem menubar.add(tools); tools.add(colour); tools.add(font); menubar.add(help); help.add(about); help.add(license); save.addActionListener(new ActionListener(){//didalam konstruktor public void actionPerformed(ActionEvent e){ JOptionPane.showMessageDialog(null, "Ingin Menyimpan Data System.exit(0); } }); open.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) {

?");

JOptionPane.showMessageDialog(null, "Ingin Membuka Data ?"); System.exit(0); } }); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "Yakin mau Keluar ?"); System.exit(0); } }); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); }

}

public class MainMenu { public static void main(String[] args) { CobaMenu m = new CobaMenu(); } } MAKA OUTPUTNYA AKAN MENJADI : 1.

2.

3.

4.

Related Documents

Tugas Praktikum Java 4
June 2020 11
Tugas Praktikum 4
June 2020 18
Tugas Praktikum
April 2020 26
Java Java Notes 4
November 2019 66
Java 4
April 2020 16
Java 4
May 2020 16