FRAME PERPUS

Jumat, 21 Oktober 2011

public class FramePerpus extends JFrame implements ActionListener {

    JMenu File, Edit, View, Help;
    JMenuBar bar;
    JMenuItem itemNew, itemOpen, itemSave, itemSaveAs, itemQuit;
    JLabel foto;

    public FramePerpus() {
        this.setTitle("PERPUSTAKAAN");
        setLocation(100, 200);
        setSize(250, 250);
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        ImageIcon foto1 = new ImageIcon("c:/sunset.jpg");
        foto = new JLabel();
        foto.setIcon(foto1);
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(foto, BorderLayout.NORTH);

        File = new JMenu("File");
        Edit = new JMenu("Edit");
        View = new JMenu("View");
        Help = new JMenu("Help");

        bar = new JMenuBar();
        this.setJMenuBar(bar);
        bar.add(File);
        bar.add(Edit);
        bar.add(View);
        bar.add(Help);

        itemNew = new JMenuItem("New");
        File.add(itemNew);
        itemOpen = new JMenuItem("Open");
        File.add(itemOpen);
        itemSave = new JMenuItem("Save");
        File.add(itemSave);
        itemSaveAs = new JMenuItem("Save As");
        File.add(itemSaveAs);
        File.addSeparator();
        itemQuit = new JMenuItem("Quit");
        File.add(itemQuit);

        itemNew.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == itemNew) {
            PinjamDialog dialog = new PinjamDialog(this);
            dialog.setVisible(true);
        } else {
            if (e.getSource() == itemQuit) {
                System.exit(0);
            }
        }
    }
}

MAIN FRAME:
public class FrameMain {

    public static void main(String[] args) {
        FramePerpus frame = new FramePerpus();
        frame.setVisible(true);
    }
}

Get This Comment Form

0 comment(s):

 
Copyright© 2010 Felisitas Brillianti | Semelekete Weleh Weleh | http://dr214ac.blogspot.com