Powered By Blogger

Minggu, 04 Desember 2011

TUGAS BESAR 2 PEMROGRAMAN VISUAL

ini nih source code - source code yang udah pernah aku pelajarinn , yukk mari liat......

ini yang buat frame sama ada buttonnya
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;


public class Main {
    public static void main(String []args){
      
        final JFrame frame =new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(300,300);
        frame.setLocationRelativeTo(null);
      
        frame.setLayout(null);
      
        JButton button = new JButton("Start");
        button.addActionListener(new ActionListener() {
          
            @Override
            public void actionPerformed(ActionEvent e) {
              
                JDialog x = new JDialog();
                x.setSize(600,200);
                x.setModal(true);
                x.setLocationRelativeTo(frame);
                x.setVisible(true);
              
              
            }
        });
        button.setBounds(10,50,120,40);
        frame.add(button);
   
      
      
    }

}
yang ini coba - coba bikin
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;


public class Coba {
    public static void main(String args[]){
        JFrame frame = new JFrame("Login Dulu");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(500, 500);
        frame.setLayout(new FlowLayout());
        frame.setLocationRelativeTo(null);
       
        JLabel nama = new JLabel("NAMA :");
        JLabel password = new JLabel("PASSWORD :");
       
        final JTextField isinama = new JTextField(15);
        final JPasswordField isipassword = new JPasswordField(15);
        JPanel panel = new JPanel();
        panel.add(nama);
        panel.add(isinama);
        panel.add(password);
        panel.add(isipassword);
       
        final JButton button = new JButton();
        button.setText("Login");
        button.addActionListener(new ActionListener() {
           
            @Override
            public void actionPerformed(ActionEvent arg0) {
                String unama = isinama.getText();
                @SuppressWarnings("deprecation")
                String pass = isipassword.getText();
                if (unama.equals("ina") && pass.equals("meyta"))
                {
                    JOptionPane.showMessageDialog(null, "Selamat datang anda berhasil login");
                   
                }
                else
                    JOptionPane.showMessageDialog(null, "Nama dan password yang anda masukkan salah");
                    isinama.setText("");
                    isipassword.setText("");
                    isinama.requestFocus();
               
            }
        });
        final JButton button2 = new JButton();
        button2.setText("Exit");
        button2.addActionListener(new ActionListener() {
           
            @Override
            public void actionPerformed(ActionEvent arg0) {
                int pesan = JOptionPane.showConfirmDialog(null,"Keluar aplikasi?","Peringatan", JOptionPane.YES_NO_OPTION);
                if(pesan==0);
                System.exit(0);
               
               
            }
        });
        frame.add(panel);
        frame.add(button);
        frame.add(button2);
        frame.setVisible(true);
       
    }

}
ini juga coba - coba
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;


public class Cobacoba {
    public static void main(String args[]){
        final JFrame frame = new JFrame("Selamat Datang");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(300, 300);
        frame.getContentPane().setBackground(Color.BLUE);
        frame.setLayout(new FlowLayout());
        frame.setLocationRelativeTo(null);
       
        JLabel label = new JLabel("Silahkan isi");
        final JTextField isinama = new JTextField(10);
        JPanel panel = new JPanel();
        panel.add(label);
        panel.add(isinama);
       
        final JButton button = new JButton();
        button.setText("Click Me!");
        button.setBackground(Color.PINK);
        button.addActionListener(new ActionListener() {
           
            @Override
            public void actionPerformed(ActionEvent arg0) {
                // TODO Auto-generated method stub
                String unama = isinama.getText();
                if(unama.equals("meyta")) {
                    JOptionPane.showMessageDialog(null, "Horee berhasil");
                }
                else {
                    JOptionPane.showMessageDialog(null, "Maaf namanya salah");
                }
                   
               
            }
        });
        frame.add(panel);
        frame.add(button);
        frame.setVisible(true);
        //frame.show(true);
       
   
    }

}
nah yang ini buat latihan mau kuis
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;


public class Latihan {
    public static void main(String args []){
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(500, 500);
        frame.setTitle("Selamat datang ^^");
        frame.setLocationRelativeTo(null);
        frame.setLayout(new FlowLayout());
       
        JLabel nama = new JLabel("Masukkan nama");
        final JTextField isinama = new JTextField(10);
        JPanel panel = new JPanel();
        panel.add(nama);
        panel.add(isinama);
       
       
        final JButton button = new JButton();
        button.setText("Cick me !");
        button.addActionListener(new ActionListener() {
           
            @Override
            public void actionPerformed(ActionEvent arg0) {
                String unama = isinama.getText();
                if(unama.equals("meyta")){
                    JOptionPane.showMessageDialog(null, "Selamat datang");
                }
                else {
                    JOptionPane.showMessageDialog(null, "Nama yang anda masukkan salah");
                }
                isinama.setText("");
                isinama.requestFocus();
               
               
               
            }
        });
        frame.add(panel);
        frame.add(button);
        frame.setVisible(true);
    }

}
ini juga latihan lagi
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;


public class LatihanLagi {
    private static final ActionListener ActionListener = null;

    public static void main(String args[]){
        JFrame frame = new JFrame("Selamat datang!");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(200, 300);
        frame.setLocationRelativeTo(null);
        frame.setLayout(new FlowLayout());
        frame.getContentPane().setBackground(Color.RED);
       
        JButton button = new JButton();
        button.setText("Click me!");
        button.addActionListener(ActionListener);
        //button.setBounds(50, 50, 100, 50);
        frame.add(button);
        frame.setVisible(true);
       
    }

}
ini tugas kelompok bikin frame login
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JTextArea;

import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class LogIn {
    public static void main(String[] args) {
        final JFrame frame = new JFrame("Login");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(new Dimension(300,150));
        frame.setLocationRelativeTo(null);
        frame.setLayout(new FlowLayout());
        frame.getContentPane().setBackground(Color.cyan);
       
        final JLabel nama = new JLabel("Nama                         : ");
        JLabel password = new JLabel("Password : ");

        final JTextField isinama = new JTextField(15);
        final JPasswordField isipassword = new JPasswordField(15);

        final JButton buttonlogin = new JButton("Login");
        buttonlogin.setBackground(Color.pink);
        buttonlogin.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String unama = isinama.getText();
                @SuppressWarnings("deprecation")
                String pass = isipassword.getText();
                if (unama.equals("meyta") && pass.equals("shinta")) {
                    JOptionPane.showMessageDialog(null,
                            "Selamat Datang Anda Berhasil Login");
                    isinama.setText("");
                    isipassword.setText("");
                    isinama.requestFocus();
                    final JFrame frame2 = new JFrame("Masuk Log in");
                    frame2.setSize(450, 200);
                    frame2.setLocationRelativeTo(null);
                    frame2.setLayout(new FlowLayout(FlowLayout.LEFT));
                    frame2.getContentPane().setBackground(Color.magenta);
                       

                    JMenuBar bar = new JMenuBar();
                   
                    JMenu menuhome = new JMenu("Beranda");
                    bar.add(menuhome);
                   
                    JMenuItem itemaccount = new JMenuItem("Pengaturan Account");
                    menuhome.add(itemaccount);
                   
                    JMenuItem itemLogout = new JMenuItem("Logout");
                    itemLogout.addActionListener(new ActionListener() {
                       
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            int pesan = JOptionPane.showConfirmDialog(null,
                                    "Keluar aplikasi?", "Peringatan",
                                    JOptionPane.YES_NO_OPTION);
                            if (pesan == 0)
//                                System.exit(0);
                            frame2.setVisible(false);
                           
                        }
                    });
                    menuhome.add(itemLogout);
                   
                   
                    JMenu menuprof = new JMenu("Profil");
                    bar.add(menuprof);
                   
                    JMenuItem menuabout = new JMenu("About as");
                    menuprof.add(menuabout);
                    //((JMenu) menuabout).addSeparator();
                   
                    JMenuItem itemgambar = new JMenuItem("Gambar");
                    itemgambar.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent arg0) {
                           
                            final JFrame frameprof = new JFrame("Profil");
                            frameprof.setSize(800, 600);
                            frameprof.setLocationRelativeTo(null);
                            frameprof.setLayout(new FlowLayout());
                           
                            ImageIcon gambar = new ImageIcon("PIS1002.JPG");
                            JLabel lgambar = new JLabel("PIS1002", gambar, SwingConstants.CENTER);
                            frameprof.add(lgambar);
                            frameprof.setVisible(true);
                           

                        }
                    });
                    menuabout.add(itemgambar);
                   
                    JMenuItem iteminfo = new JMenuItem("Info");
                    iteminfo.addActionListener(new ActionListener() {
                       
                        @Override
                        public void actionPerformed(ActionEvent arg0) {
                            JFrame note = new JFrame("Info");
                            note.setSize(300,150 );
                            note.setLayout(new FlowLayout());
                            note.setLocationRelativeTo(null);
                            String isiinfo =("PIS1002 adalah nama kelas di Politeknik Telkom , didalamnya terdiri dari orang-orang " +
                                    "yang berasal dari berbagai kota. Memiliki karakter yang berbeda-beda");
                            JTextArea info = new JTextArea(isiinfo, 5, 40);
                            info.setLineWrap(true);
                            info.setWrapStyleWord(true);
                            info.setForeground(Color.BLUE);
                            info.setFont(new Font("Papyrus", Font.ITALIC, 12));
                           
                            note.add(info);
                            note.setVisible(true);
                           
                           
                        }
                    });
                    menuabout.add(iteminfo);
               
                   
                   
                    JMenu menuSearch = new JMenu("Pencarian");
                    bar.add(menuSearch);
                   
                    JMenuItem itemnama = new JMenuItem("Nama");
                    menuSearch.add(itemnama);
                    JMenuItem itememail = new JMenuItem("E-mail");
                    menuSearch.add(itememail);
                   
                    final JLabel selamat = new JLabel("Selamat Datang " +
                    "Apa Kabar Anda Hari Ini ?");
                    selamat.setFont(new Font("Papyrus", Font.BOLD, 18));
                    frame2.add(bar);
                    frame2.add(selamat);
                    frame2.setVisible(true);

                } else {
                    JOptionPane.showMessageDialog(null,
                            "Nama dan Password Anda salah, silahkan ulangi");
                    isinama.setText("");
                    isipassword.setText("");
                    isinama.requestFocus();
                }

            }
        });
        final JButton buttonreset = new JButton("Reset");
        buttonreset.setBackground(Color.pink);
        //buttonreset.setText("Reset");
        buttonreset.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                isinama.setText("");
                isipassword.setText("");
                isinama.requestFocus();

            }
        });

        frame.add(nama);
        frame.add(isinama);
        frame.add(password);
        frame.add(isipassword);
        frame.add(buttonlogin);
        frame.add(buttonreset);
        frame.setVisible(true);
    }

}
kalo yang ini tugas juga bikin url
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import javax.swing.JFrame;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

import javax.swing.JTextField;

public class PIS1002 {
    public static void main(String[] args) {
        final JFrame frame = new JFrame("PIS-10-02 MEYTA");
        frame.setSize(600, 500);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new FlowLayout(FlowLayout.LEFT));

        JMenuBar bar = new JMenuBar();

        JMenu menufile = new JMenu("File");
        bar.add(menufile);

        JMenuItem itemnew = new JMenuItem("New");
        menufile.add(itemnew);
        menufile.addSeparator();

        JMenuItem itemopen = new JMenuItem("Open");
        menufile.add(itemopen);

        JMenu menuedit = new JMenu("Edit");
        bar.add(menuedit);

        JMenu menuview = new JMenu("View");
        bar.add(menuview);

        JMenu menuSource = new JMenu("Source");
        bar.add(menuSource);

        JMenu menuRefactor = new JMenu("Refactor");
        bar.add(menuRefactor);

        JMenu menuNavigate = new JMenu("Navigate");
        bar.add(menuNavigate);

        frame.add(bar);

        final JTextField text = new JTextField(35);
        frame.add(text);

        final JButton Search = new JButton("Go");

        Search.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (text.getText().equals("")) {
                    System.out.println("tidak ada teks yang ditulis");
                    JOptionPane.showMessageDialog(null, "Masukan URL!");

                } else {
                    final JTextArea area = new JTextArea();
                    final JScrollPane scroll = new JScrollPane(area,
                            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

                    panggilKoneksi(text, area);
                    frame.add(Search);
                    frame.add(scroll, BorderLayout.CENTER);
                    frame.setVisible(true);

                }
            }

            private void panggilKoneksi(final JTextField text,
                    final JTextArea area) {
                try {
                    URL url = new URL(text.getText());

                    URLConnection con = url.openConnection();

                    InputStream is = con.getInputStream();

                    ByteArrayOutputStream os = new ByteArrayOutputStream();

                    byte[] b = new byte[9];
                    int len;
                    while ((len = is.read(b, 0, b.length)) != -1) {
                        os.write(b, 0, len);
                    }
                    area.setText(new String(os.toByteArray()));
                    os.close();
                    is.close();

                } catch (MalformedURLException e) {
                    JLabel label2 = new JLabel("Salah Tulis di URL");
                    JOptionPane.showMessageDialog(frame, label2,
                            "Kesalahan Tulis", 1);
                } catch (IOException e) {
                    JLabel label3 = new JLabel("Salah Tulis di URL ini.");
                    JOptionPane.showMessageDialog(frame, label3,
                            "Kesalahan Tulis", 0);
                }

            }
        });

        frame.add(Search);

        frame.setVisible(true);
    }
}
ini juga tugas lagi bikin google

//public class google {
   
   

    import java.awt.Color;
import java.awt.Component;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.JTextField;
import javax.swing.JTextPane;

    public class MyGoogle {

        protected static final Component ScrollPane = null;

        public static void main(String[] args) {
           
            final JFrame frame = new JFrame ();
            frame.setSize(450, 200);
            frame.setTitle("My Google: " + frame.getWidth());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setResizable(false);
            frame.setAlwaysOnTop(true);
            frame.getContentPane().setBackground(Color.cyan);
            frame.setLocationRelativeTo(null);
            frame.setLayout(new FlowLayout());
           
            final JLabel label  = new JLabel ("ENTER THE URL");
            label.setFont(new Font("", 10, 40));
            label.setForeground(Color.pink);
            frame.add(label);
           
            final JTextField field = new JTextField(25);
            field.setToolTipText("www.facebook.com");
            frame.add(field);
           
            JButton button = new JButton ("search");
            button.setForeground(Color.green);
            button.setBackground(Color.red);
            button.addActionListener(new ActionListener() {
               
                @Override
                public void actionPerformed(ActionEvent arg0) {
                    if (field.getText().equals("")) {
                        System.out.println("tidak ada text yang ditulis!!");
                        JOptionPane.showMessageDialog(frame, label, "judul pesannya", 1);
                    } else {
                        JFrame frame2 = new JFrame("frame hasil");
                        frame2.setSize(600, 400);
                        frame2.setLocationRelativeTo(frame);
                        final JTextPane textPane = new JTextPane();
                        @SuppressWarnings("unused")
                        JScrollPane JScrollPane = new JScrollPane(textPane);
                       
                        panggilKoneksi(field, textPane);
                       
                        frame2.add(ScrollPane);
                    }
                   
                }
            });
           
        }

        protected static void panggilKoneksi(JTextField field,
                JTextPane textPane) {
            // TODO Auto-generated method stub
           
        }
    }
ini kuissss
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;


public class Kuis {
    public static void main(String args []){
        JFrame frame = new JFrame("Punya Saya");
        frame.setSize(300, 150);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new FlowLayout());
        frame.getContentPane().setBackground(Color.PINK);
        frame.setLocationRelativeTo(null);
       
        JLabel label = new JLabel("Silahkan isi");
        //frame.add(label, BorderLayout.NORTH);
        final JTextField nama = new JTextField(10);
        //frame.add(nama, BorderLayout.SOUTH);
       
        frame.add(label);
        frame.add(nama);
        frame.setVisible(true);
       
    }

}
ini kuis juga
import java.awt.Color;
import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;


public class Kuis1 {
    public static void main(String args[]){
        final JFrame frame = new JFrame("Punya Saya");
        frame.setSize(300, 150);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLayout(new FlowLayout());
        frame.getContentPane().setBackground(Color.PINK);
        frame.setLocationRelativeTo(null);
       
        JLabel label = new JLabel("Silahkan Isi");
        JTextField nama = new JTextField(10);
       
        frame.add(label);
        frame.add(nama);
        frame.setVisible(true);
    }

}
ini kuiss lagii
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JTextArea;

import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class LogIn {
    public static void main(String[] args) {
        final JFrame frame = new JFrame("Login");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(new Dimension(300,150));
        frame.setLocationRelativeTo(null);
        frame.setLayout(new FlowLayout());
        frame.getContentPane().setBackground(Color.cyan);
       
        final JLabel nama = new JLabel("Nama                         : ");
        JLabel password = new JLabel("Password : ");

        final JTextField isinama = new JTextField(15);
        final JPasswordField isipassword = new JPasswordField(15);

        final JButton buttonlogin = new JButton("Login");
        buttonlogin.setBackground(Color.pink);
        buttonlogin.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                String unama = isinama.getText();
                @SuppressWarnings("deprecation")
                String pass = isipassword.getText();
                if (unama.equals("meyta") && pass.equals("shinta")) {
                    JOptionPane.showMessageDialog(null,
                            "Selamat Datang Anda Berhasil Login");
                    isinama.setText("");
                    isipassword.setText("");
                    isinama.requestFocus();
                    final JFrame frame2 = new JFrame("Masuk Log in");
                    frame2.setSize(450, 200);
                    frame2.setLocationRelativeTo(null);
                    frame2.setLayout(new FlowLayout(FlowLayout.LEFT));
                    frame2.getContentPane().setBackground(Color.magenta);
                       

                    JMenuBar bar = new JMenuBar();
                   
                    JMenu menuhome = new JMenu("Beranda");
                    bar.add(menuhome);
                   
                    JMenuItem itemaccount = new JMenuItem("Pengaturan Account");
                    menuhome.add(itemaccount);
                   
                    JMenuItem itemLogout = new JMenuItem("Logout");
                    itemLogout.addActionListener(new ActionListener() {
                       
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            int pesan = JOptionPane.showConfirmDialog(null,
                                    "Keluar aplikasi?", "Peringatan",
                                    JOptionPane.YES_NO_OPTION);
                            if (pesan == 0)
//                                System.exit(0);
                            frame2.setVisible(false);
                           
                        }
                    });
                    menuhome.add(itemLogout);
                   
                   
                    JMenu menuprof = new JMenu("Profil");
                    bar.add(menuprof);
                   
                    JMenuItem menuabout = new JMenu("About as");
                    menuprof.add(menuabout);
                    //((JMenu) menuabout).addSeparator();
                   
                    JMenuItem itemgambar = new JMenuItem("Gambar");
                    itemgambar.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent arg0) {
                           
                            final JFrame frameprof = new JFrame("Profil");
                            frameprof.setSize(800, 600);
                            frameprof.setLocationRelativeTo(null);
                            frameprof.setLayout(new FlowLayout());
                           
                            ImageIcon gambar = new ImageIcon("PIS1002.JPG");
                            JLabel lgambar = new JLabel("PIS1002", gambar, SwingConstants.CENTER);
                            frameprof.add(lgambar);
                            frameprof.setVisible(true);
                           

                        }
                    });
                    menuabout.add(itemgambar);
                   
                    JMenuItem iteminfo = new JMenuItem("Info");
                    iteminfo.addActionListener(new ActionListener() {
                       
                        @Override
                        public void actionPerformed(ActionEvent arg0) {
                            JFrame note = new JFrame("Info");
                            note.setSize(300,150 );
                            note.setLayout(new FlowLayout());
                            note.setLocationRelativeTo(null);
                            String isiinfo =("PIS1002 adalah nama kelas di Politeknik Telkom , didalamnya terdiri dari orang-orang " +
                                    "yang berasal dari berbagai kota. Memiliki karakter yang berbeda-beda");
                            JTextArea info = new JTextArea(isiinfo, 5, 40);
                            info.setLineWrap(true);
                            info.setWrapStyleWord(true);
                            info.setForeground(Color.BLUE);
                            info.setFont(new Font("Papyrus", Font.ITALIC, 12));
                           
                            note.add(info);
                            note.setVisible(true);
                           
                           
                        }
                    });
                    menuabout.add(iteminfo);
               
                   
                   
                    JMenu menuSearch = new JMenu("Pencarian");
                    bar.add(menuSearch);
                   
                    JMenuItem itemnama = new JMenuItem("Nama");
                    menuSearch.add(itemnama);
                    JMenuItem itememail = new JMenuItem("E-mail");
                    menuSearch.add(itememail);
                   
                    final JLabel selamat = new JLabel("Selamat Datang " +
                    "Apa Kabar Anda Hari Ini ?");
                    selamat.setFont(new Font("Papyrus", Font.BOLD, 18));
                    frame2.add(bar);
                    frame2.add(selamat);
                    frame2.setVisible(true);

                } else {
                    JOptionPane.showMessageDialog(null,
                            "Nama dan Password Anda salah, silahkan ulangi");
                    isinama.setText("");
                    isipassword.setText("");
                    isinama.requestFocus();
                }

            }
        });
        final JButton buttonreset = new JButton("Reset");
        buttonreset.setBackground(Color.pink);
        //buttonreset.setText("Reset");
        buttonreset.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                isinama.setText("");
                isipassword.setText("");
                isinama.requestFocus();

            }
        });

        frame.add(nama);
        frame.add(isinama);
        frame.add(password);
        frame.add(isipassword);
        frame.add(buttonlogin);
        frame.add(buttonreset);
        frame.setVisible(true);
    }

}
nah itu dia beberapa kodingan yang bikin pusing tapi menarik buat dipelajarin . itu mah belum seberapa , mari kita belajar lebih banyak , fighting ^ ^
 

Tidak ada komentar:

Posting Komentar