Modifikasi “Address Book 2nd Show” dengan Java Swing (NetBeans IDE 7.3)
Contoh sederhana Input–Output berdasarkan masukan dari pengguna melalui Input Dialog dan di tampilkan melalui Text Area.
Reverensi menggunaan editor NetBeans IDE 7.3 Sumber
1. Jalankan NetBeans IDE 7.3.
2. Klik File > New Project atau tekan tombol Ctrl+Shift+N pada keyboard.
3. Pada jendela New Project, pada bagian Categories pilih “Java”. Pada pilihan Project pilih “Java Application” kemudian klik tombol “Next >”.
4. Pada jendela New Java Application, Pada kotak isian Project Name: “MODAddressBook2ndShowApp”. Hilangkan pilihan Create Main Class. Kemudian klik tombol Finish.
5. Pada jendela Project, klik kanan MODAddressBook2ndShowApp pilih New > JFrame Form…
6. Pada jendela New JFrame Form, Pada kotak isian Class Name: “MODAddressBook2ndShowUI”. Pada kotak isian Package: “My.MODAddressBook2ndShow” kemudian klik tombol “Finish”
Setting Control Property:
Object | Name | Properties | Setting |
Form | jFrame | title resizable Generate Center | Address Book False True |
Label | jLabel1 | text | Name: |
Text Field | jTextField1 | text | (Empty) |
Button | jButton1 | text | … |
Label | jLabel1 | text | E-Mail: |
Text Field | jTextField2 | text | (Empty) |
Button | jButton2 | text | … |
Label | jLabel1 | text | Mobile: |
Text Field | jTextField3 | text | (Empty) |
Button | jButton3 | text | … |
Button | jButton4 | text | Show |
Text Area | jTextArea1 | text | (Empty) |
Button | jButton5 | text enabled | Clear False |
Button | jButton6 | text | Exit |
Event Program:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String strInboxName;
strInboxName = JOptionPane.showInputDialog("Please Enter Your Name:");
jTextField1.setText(strInboxName);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
String strInboxEMail;
strInboxEMail = JOptionPane.showInputDialog("Please Enter Your E-Mail Address:");
jTextField2.setText(strInboxEMail);
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
String strInboxMobile;
strInboxMobile = JOptionPane.showInputDialog("Please Enter Your Mobile Number:");
jTextField3.setText(strInboxMobile);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea1.append("Name: " + jTextField1.getText()
+ "\n" + "E-Mail: " + jTextField2.getText()
+ "\n" + "Mobile: " + jTextField3.getText());
jButton4.setEnabled(false);
jButton5.setEnabled(true);
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText("");
jTextField2.setText("");
jTextField3.setText("");
jTextArea1.setText("");
jButton4.setEnabled(true);
jButton5.setEnabled(false);
jTextField1.grabFocus();
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
7. Jalankan Project, pada ToolBar klik tombol Run Project atau klik F6 pada keyboard
8. Pada jendela Run Project klik tombol OK untuk menjadikan MODAddressBook2ndShowUI menjadi main class.
Label: Java SE
0 Komentar:
Posting Komentar
Berlangganan Posting Komentar [Atom]
<< Beranda