Sunteți pe pagina 1din 4

Nama :Budi Santoso Kelas:2eb Nim : 1102017

input
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class IDbudi { public static void main(String[] args) { final JLabel an = new JLabel("INPUT NIM"); an.setFont(new Font("Times New Roman",Font.BOLD,20)); an.setForeground(Color.blue); //Input NIM final JLabel ni = new JLabel("Nama"); final JTextField im = new JTextField(15); im.setOpaque(false); im.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray)); im.setFont(new Font("Arial",Font.BOLD,12)); im.setForeground(Color.green); im.setHorizontalAlignment(JTextField.LEFT); final JLabel ou = new JLabel("<< OUTPUT NIM >>"); ou.setFont(new Font("Times New Roman",Font.BOLD,20)); ou.setForeground(Color.blue); final JLabel ju = new JLabel("NIM"); final JTextField im1 = new JTextField(15); im1.setOpaque(false); im1.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray)); im1.setFont(new Font("Arial",Font.BOLD,12)); im1.setForeground(Color.green); im1.setHorizontalAlignment(JTextField.LEFT); final JLabel fa = new JLabel("JURUSAN"); final JTextField im2 = new JTextField(15); im2.setOpaque(false); im2.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray)); im2.setFont(new Font("Arial",Font.BOLD,12)); im2.setForeground(Color.green); im2.setHorizontalAlignment(JTextField.LEFT); final JLabel ag = new JLabel("Angkatan"); final JTextField im3 = new JTextField(15);

im3.setOpaque(false); im3.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray)); im3.setFont(new Font("Arial",Font.BOLD,12)); im3.setForeground(Color.green); im3.setHorizontalAlignment(JTextField.LEFT);

final JTextField im0 = new JTextField ("",15); im0.setHorizontalAlignment(JTextField.RIGHT); im0.setFont(new Font("Arial", Font.BOLD, 12)); im0.setForeground(Color.MAGENTA); im0.addActionListener(new ActionListener(){ public void actionPerformed (ActionEvent e){ if(im0.getText().equals("")){ JOptionPane.showMessageDialog(null, "Upps.., Fill It First !!!"); } else { int nim = Integer.parseInt (im0.getText()); if (nim == 1102017){ im.setText("Budi Santoso"); im1.setText(im0.getText()); im2.setText("Elektro"); im3.setText("xxv"); }else{ JOptionPane.showMessageDialog(null, "coba lagi!"); } } } }); //Process Button final JButton pn1 = new JButton ("Proses NIM"); pn1.addActionListener(new ActionListener(){ public void actionPerformed (ActionEvent e){ if(im0.getText().equals("")){ JOptionPane.showMessageDialog(null, "please entry your nim!"); } else { int nim = Integer.parseInt (im0.getText()); if (nim == 1102017){ im.setText("Budi santoso"); im1.setText(im0.getText()); im2.setText("elektro"); im3.setText("xxv"); }else{ JOptionPane.showMessageDialog(null, "coba lagi! ");

} } } }); //Tombol Reset final JButton rs1 = new JButton ("Reset"); rs1.addActionListener(new ActionListener(){ public void actionPerformed (ActionEvent e){ im0.setText(""); im.setText(""); im1.setText(""); im2.setText(""); im3.setText(""); } });

// Frame JFrame santosoframe = new JFrame("Identifikasi NIM"); santosoframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); santosoframe.getContentPane().setLayout(new java.awt.FlowLayout()); santosoframe.add(an); santosoframe.add(im0); santosoframe.add(ou); santosoframe.add(pn1); santosoframe.add(rs1); santosoframe.add(ni); santosoframe.add(im); santosoframe.add(ju); santosoframe.add(im1); santosoframe.add(fa); santosoframe.add(im2); santosoframe.add(ag); santosoframe.add(im3); santosoframe.setVisible(true); santosoframe.setSize(200,325); santosoframe.setResizable(false); santosoframe.setLocation(100,100); im0.requestFocus(); } }

Output

S-ar putea să vă placă și