Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class date here.
- *
- * @author Steve D.
- * @version 1.2.1
- */
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class ServiceCenter
- {
- String Username = "admin";
- String Password = "admin";
- karyawan mana = new karyawan();
- JTextField Uname = null;
- JPasswordField Pass= null;
- public static void main(String[] args){
- ServiceCenter gui = new ServiceCenter();
- gui.go();
- }
- public void go(){
- JFrame frame1 = new JFrame();
- frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JPanel panel1 = new JPanel();
- JFrame frame2 = new JFrame();
- frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- JPanel panel2 = new JPanel();
- JLabel Unamelbl = new JLabel("Username\t:");
- JLabel Passlbl = new JLabel("Password\t:");
- JTextField Uname = new JTextField(20);
- JPasswordField Pass = new JPasswordField(20);
- JButton okay = new JButton("OK");
- JLabel background = new JLabel(new ImageIcon("img/Back.jpg"));
- JLabel selamat = new JLabel("Selamat Datang di X Service Center");
- ImageIcon service1 = new ImageIcon("img/service1.png");
- JButton service1btn = new JButton(service1);
- ImageIcon service2 = new ImageIcon("img/service2.png");
- JButton service2btn = new JButton(service2);
- JButton setelan = new JButton ("setelan (hanya untuk karyawan)");
- setelan.setLocation(400-50,700-24);
- service1btn.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- mana.prTiketS();
- }
- });
- service2btn.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- mana.prTiketA();
- }
- });
- setelan.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- //JOptionPane.showMessageDialog(null,"maknyus");
- frame1.setVisible(false);
- frame2.setVisible(true);
- }
- });
- okay.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- if(Username.equals(Uname.getText())&&Password.equals(Pass.getText())){
- String pilihan = JOptionPane.showInputDialog("Menu\n1.Lihat Antrian\n2.Reset Antrian\n");
- if(pilihan == null || (pilihan != null&& ("".equals(pilihan)))){
- frame2.setVisible(false);
- frame1.setVisible(true);
- }
- else if(pilihan.charAt(0)=='1') mana.lihatantri();
- else if(pilihan.charAt(0)=='2') mana.resetantri();
- else {
- JOptionPane.showMessageDialog(null, "Pilihan tidak terdapat dalam menu!");
- }
- Uname.setText("");
- Pass.setText("");
- }
- else{
- JOptionPane.showMessageDialog(null, "Username atau Password salah.\nKembali ke menu awal.");
- Uname.setText("");
- Pass.setText("");
- frame2.setVisible(false);
- frame1.setVisible(true);
- }
- }
- });
- panel2.add(Unamelbl);
- panel2.add(Uname);
- panel2.add(Passlbl);
- panel2.add(Pass);
- panel2.add(okay);
- panel2.add(background);
- frame2.getContentPane().add(panel2);
- frame2.setSize(350,700);
- panel1.add(background);
- background.setSize(350,700);
- background.setLayout(new FlowLayout());
- background.add(selamat);
- background.add(service1btn);
- background.add(service2btn);
- background.add(setelan);
- frame1.getContentPane().add(panel1);
- frame1.setSize(350,700);
- frame1.setVisible(true);
- }
- }
Add Comment
Please, Sign In to add comment