Rabu, 21 Desember 2011

Proyek PBO_Kelas KotakMasuk

package uts_pbo_2;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

public class KotakMasuk extends JFrame {

    JMenu menuFile, menuHelp;
    JMenuItem itemPengirim, exit, baca, semua;
    JMenuBar bar;
    DataSuratMasuk surat;
    Read read;
    ImageIcon img;
    JLabel label;

    public KotakMasuk() {
        Container content = getContentPane();
        setSize(400, 300);
        setLocation(300, 300);
        setTitle("Kotak Masuk");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        img = new ImageIcon("Koala.jpg");
        label = new JLabel(img);
        content.add(label);

        menuFile = new JMenu("File");
        menuHelp = new JMenu("Help");
        bar = new JMenuBar();
        itemPengirim = new JMenuItem("New Mail");
        baca = new JMenuItem("Read Mail");
        semua = new JMenuItem("Mail Table");
        exit = new JMenuItem("Exit");

        setJMenuBar(bar);
        bar.add(menuFile);
        bar.add(menuHelp);

        menuFile.add(baca);
        menuFile.add(itemPengirim);
        menuFile.add(semua);
        menuFile.addSeparator();
        menuFile.add(exit);

        baca.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                DataHandler data = new DataHandler();
                read = new Read(new KotakMasuk());
                read.setVisible(true);
            }
        });

        itemPengirim.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                surat = new DataSuratMasuk(new KotakMasuk());
                surat.setVisible(true);
            }
        });

        semua.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                try {
                    JDialog dialog = new JDialog(new JFrame(), true);
                    AllTable searchPanel = new AllTable("");
                    dialog.add(searchPanel);
                    dialog.setSize(600, 300);
                    dialog.setVisible(true);
                } catch (SQLException ex) {
                    Logger.getLogger(KotakMasuk.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });

        exit.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                System.exit(0);
            }
        });
        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

}

Tidak ada komentar:

Posting Komentar