Tugas Pemrograman Java P7 EL Event Handler & Menu
Disusun oleh: RIDLO PAMUJI 13111111 / 22
PROGRAM STUDI TEKNIK INFORMATIKA FAKULTAS TEKNOLOGI INFORMASI UNIVERSITAS MERCU BUANA YOGYAKARTA 2015/2016
1. Source Code Class Menu_EL (Menu) /* Tugas Elearning P7 * Ridlo Pamuji 13111111 * Pemrograman Java */ import javax.swing.*; import java.awt.event.*; class Menu_EL extends JFrame { JMenuBar MainMenu=new JMenuBar(); JMenu File=new JMenu("File"); JMenuItem Keluar=new JMenuItem("Exit"); JMenu Data=new JMenu("Data"); JMenuItem Data_Mhs=new JMenuItem("Data Mahasiswa"); EL_Identity EL_Identity_New=new EL_Identity(); JMenu About=new JMenu("About"); JMenuItem Detail=new JMenuItem("About Us"); Menu_EL() { setTitle("Menu Project P6 Event Handling"); setLocation(250,100); setSize(400,300); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } void view_data() { setJMenuBar(MainMenu); MainMenu.add(File); File.add(Keluar); MainMenu.add(Data); Data.add(Data_Mhs); MainMenu.add(About); About.add(Detail); setVisible(true); } void instruksi()
{ Data_Mhs.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { EL_Identity_New.Form_Elearning(); EL_Identity_New.instruksi(); } }); Keluar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); Detail.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "Tugas ~ By SQ UMBY
http://sidiq.mercubuana-yogya.ac.id NIM : 13111111
Nama : Ridlo Pamuji", "Informasi", JOptionPane.INFORMATION_MESSAGE); } }); } public static void main(String[] args) { Menu_EL M_EL=new Menu_EL(); M_EL.view_data(); M_EL.instruksi(); } }
2. Source Code Class EL_Identity (Event Handler) /* Tugas Elearning P7 * Ridlo Pamuji 13111111 * Pemrograman Java */ import javax.swing.*; import java.awt.event.*; class EL_Identity extends JFrame { JLabel labelmysin=new JLabel("SIN : 13111111"); JLabel labelmyname=new JLabel("Name : Ridlo Pamuji"); JLabel labelELidentity=new JLabel("E-Learning (Identity)"); JLabel labelSIN=new JLabel("SIN"); JTextField textSIN=new JTextField(8); JLabel labelName=new JLabel("Name"); JTextField textName=new JTextField(40); JLabel labelAddres=new JLabel("Addres"); JTextField textAddress=new JTextField(50); JLabel labelGender=new JLabel("Gender"); JRadioButton radioMale=new JRadioButton("Male"); JRadioButton radioFemale=new JRadioButton("Female"); ButtonGroup groupGender=new ButtonGroup(); JLabel labelReligion=new JLabel("Religion"); String[] Religion={"Islamic", "Katholic", "Christian", "Budhis","Hindu", "Konghucu"}; JComboBox comboReligion = new JComboBox(Religion); JLabel labelHobby=new JLabel("Hobby"); JCheckBox Watching=new JCheckBox("Watching TV"); JCheckBox Sleeping=new JCheckBox("Sleeping"); JLabel labelEmail=new JLabel("E-Mail"); JTextField textEmail=new JTextField(30); JLabel labelFacebook=new JLabel("Facebook"); JTextField textFacebook=new JTextField(40);
JLabel labelPhone=new JLabel("Phone"); JTextField textPhone=new JTextField(12); JTextArea textaView=new JTextArea(); JButton buttonINPUT=new JButton("SAVE"); JButton buttonEXIT=new JButton("EXIT"); EL_Identity () { setTitle("From Projek P6 Event Hadling"); setLocation(350,75); setSize(370,640); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } void Form_Elearning() { getContentPane().setLayout(null); getContentPane().add(labelmysin); labelmysin.setBounds(10,10,200,20); getContentPane().add(labelmyname); labelmyname.setBounds(10,40,200,20); getContentPane().add(labelELidentity); labelELidentity.setBounds(120,80,200,20); getContentPane().add(labelSIN); labelSIN.setBounds(10,120,70,20); getContentPane().add(textSIN); textSIN.setBounds(90,120,100,20); getContentPane().add(labelName); labelName.setBounds(10,150,70,20); getContentPane().add(textName); textName.setBounds(90,150,160,20); getContentPane().add(labelAddres); labelAddres.setBounds(10,180,70,20); getContentPane().add(textAddress); textAddress.setBounds(90,180,250,20); getContentPane().add(labelGender);
labelGender.setBounds(10,210,70,20); getContentPane().add(radioMale); radioMale.setBounds(85,210,70,20); getContentPane().add(radioFemale); radioFemale.setBounds(150,210,100,20); getContentPane().add(labelReligion); labelReligion.setBounds(10,240,70,20); getContentPane().add(comboReligion); comboReligion.setBounds(90,240,85,20 ); getContentPane().add(labelHobby); labelHobby.setBounds(10,270,70,20); getContentPane().add(Watching); Watching.setBounds(85,270,100,20); getContentPane().add(Sleeping); Sleeping.setBounds(85,300,150,20); getContentPane().add(labelEmail); labelEmail.setBounds(10,330,70,20); getContentPane().add(textEmail); textEmail.setBounds(90,330,180,20); getContentPane().add(labelFacebook); labelFacebook.setBounds(10,360,70,20); getContentPane().add(textFacebook); textFacebook.setBounds(90,360,250,20); getContentPane().add(labelPhone); labelPhone.setBounds(10,390,70,20); getContentPane().add(textPhone); textPhone.setBounds(90,390,160,20); getContentPane().add(buttonINPUT); buttonINPUT.setBounds(10,420,74,20); getContentPane().add(buttonEXIT); buttonEXIT.setBounds(10,450,74,20); getContentPane().add(textaView); textaView.setBounds(90,420,250,170); setVisible(true); } void instruksi()
{ buttonINPUT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textaView.append(textSIN.getText()+"\n"); textaView.append(textName.getText()+"\n"); textaView.append(textAddress.getText()+"\n"); if(radioMale.isSelected()==true) { textaView.append(radioMale.getText()+"\n"); } else { textaView.append(radioFemale.getText()+"\n"); } textaView.append(comboReligion.getSelectedItem() + "\n"); if(Watching.isSelected()==true) { textaView.append(Watching.getText()+"\n"); } if(Sleeping.isSelected()==true) { textaView.append(Sleeping.getText()+"\n"); } textaView.append(textEmail.getText()+"\n"); textaView.append(textFacebook.getText()+"\n"); textaView.append(textPhone.getText()+"\n"); } }); buttonEXIT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); } public static void main(String[]args) { EL_Identity EL=new EL_Identity(); EL.Form_Elearning();
EL.instruksi(); } } 3. Capture Class Menu_EL (Menu) Menu “File” -> Sub-menu “Exit”, untuk keluar dari program.
Menu “Data” -> Sub-menu “Data Mahasiswa”, untuk menampilkan form Elearning yang ada pada file class “EL_Identity”.
Menu “About” -> Sub-menu “About Us”, untuk menampilkan form informasi tentang program.
Tampilan informasi tentang program dari menu “About” -> Sub-menu “About Us”.
4. Capture Class EL_Identity (Event Handler) Tampilan Form Elearning sebelum diinput data.
Tampilan Form Elearning setelah diinput data (Event Handler).