Project PBO
kemudian tambahkan form seperti berikut :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* FormPBO_netBeans.java
*
* Created on 12 Nov 11, 17:21:50
*/
package PBO_MHW;
/**
*
* @author Administrator
*/
public class FormPBO_netBeans extends javax.swing.JFrame {
/** Creates new form FormPBO_netBeans */
public FormPBO_netBeans() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
jTabbedPane2 = new javax.swing.JTabbedPane();
jPanel7 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jScrollPane2 = new javax.swing.JScrollPane();
jTextArea2 = new javax.swing.JTextArea();
jPanel6 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jButton9 = new javax.swing.JButton();
jButton10 = new javax.swing.JButton();
jScrollPane3 = new javax.swing.JScrollPane();
jTextArea3 = new javax.swing.JTextArea();
jScrollPane9 = new javax.swing.JScrollPane();
jEditorPane2 = new javax.swing.JEditorPane();
jPanel4 = new javax.swing.JPanel();
jTabbedPane3 = new javax.swing.JTabbedPane();
jPanel8 = new javax.swing.JPanel();
jLabel7 = new javax.swing.JLabel();
jScrollPane4 = new javax.swing.JScrollPane();
jEditorPane1 = new javax.swing.JEditorPane();
jButton11 = new javax.swing.JButton();
jScrollPane5 = new javax.swing.JScrollPane();
jTextArea4 = new javax.swing.JTextArea();
jButton12 = new javax.swing.JButton();
jPanel9 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
jScrollPane6 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jButton13 = new javax.swing.JButton();
jScrollPane7 = new javax.swing.JScrollPane();
jTextArea5 = new javax.swing.JTextArea();
jPanel5 = new javax.swing.JPanel();
jButton14 = new javax.swing.JButton();
jButton15 = new javax.swing.JButton();
jScrollPane8 = new javax.swing.JScrollPane();
jTextArea6 = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("KUMPULAN CONTOH PBO");
getContentPane().setLayout(new java.awt.CardLayout());
jButton1.setText("MANUSIA");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("SISWA");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("GURU");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setText("OBJEK ARRAY");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(45, 45, 45)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addGap(10, 10, 10)
.addComponent(jButton4))
.addComponent(jButton1))
.addContainerGap(193, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(25, 25, 25)
.addComponent(jButton1)
.addGap(10, 10, 10)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2)
.addComponent(jButton3)
.addComponent(jButton4))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(33, Short.MAX_VALUE))
);
jTabbedPane1.addTab("1.Turunan/Pewarisan/Inheritance", jPanel1);
jPanel2.setLayout(new java.awt.CardLayout());
jLabel1.setText("berlaku pada Construktor dan Method");
jLabel2.setText("Constructor");
jLabel3.setText("Method");
jButton5.setText("MOBIL");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton6.setText("BENTUK3D-1");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jButton7.setText("BENTUK3D-2");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jButton8.setText("BENTUK3D-3");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jTextArea2.setColumns(20);
jTextArea2.setRows(5);
jScrollPane2.setViewportView(jTextArea2);
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap(306, Short.MAX_VALUE)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton5))
.addGroup(jPanel7Layout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addGroup(jPanel7Layout.createSequentialGroup()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton6)
.addComponent(jButton7)
.addComponent(jButton8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(106, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(jLabel2))
.addGroup(jPanel7Layout.createSequentialGroup()
.addGap(25, 25, 25)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jButton5))))
.addGap(18, 18, 18)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(jButton6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton8))
.addComponent(jScrollPane2, 0, 0, Short.MAX_VALUE))
.addContainerGap(96, Short.MAX_VALUE))
);
jTabbedPane2.addTab("1.OverLoad/OverLoading", jPanel7);
jLabel4.setText("berlaku pada = method() TURUNAN/SUBCLASS");
jLabel5.setText("bisa dilihat pada Pewarisan");
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel4))
.addContainerGap(257, Short.MAX_VALUE))
);
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel5)
.addContainerGap(212, Short.MAX_VALUE))
);
jTabbedPane2.addTab("2.OverRide/OverRiding", jPanel6);
jPanel2.add(jTabbedPane2, "card2");
jTabbedPane1.addTab("2.PerubahanBentuk/Polymorphism/Polimofisme", jPanel2);
jLabel6.setText("Tingkat Akses = private, protected, public dan default (tanpa tanda modifier)");
jButton9.setText("Kue Tart");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
jButton10.setText("Kue Marie");
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
jTextArea3.setColumns(20);
jTextArea3.setRows(5);
jScrollPane3.setViewportView(jTextArea3);
jEditorPane2.setText("1.Private - Method dan variable hanya dpt diakses di dalam class itu sendiri.\n2.Protected - Method dan variable hanya dpt diakses didalam package dan sub classnya.\n3.Default - Method dan variable hanya dpt diakses hanya pada package yang sama.\n4.Public - Method dan variable dpt diakses pada semua package.");
jEditorPane2.setOpaque(false);
jScrollPane9.setViewportView(jEditorPane2);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButton9)
.addComponent(jButton10))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(36, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jButton9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton10))
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(166, 166, 166))
);
jTabbedPane1.addTab("3.Pembungkusan/Tingkat-Akses/Encapsulation", jPanel3);
jPanel4.setLayout(new java.awt.CardLayout());
jLabel7.setText("Ciri-ciri :");
jEditorPane1.setText("1. Method statis hanya dpt memanggil method yang bersifat statis\n2. Method statis hanya dpt mengakses data-data yang bersifat statis\n3. Method statis tidak dapat diacu melalui referensi this maupun super\n4. Modifier static artinya method dan attribute milik kelas, menjadi sifat bersama dari semua objek dalam kelas tersebut (tidak memerlukan instansiasi objek untuk menjalankannya).");
jEditorPane1.setOpaque(false);
jScrollPane4.setViewportView(jEditorPane1);
jButton11.setText("Tes Statis 1");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
jTextArea4.setColumns(20);
jTextArea4.setRows(5);
jScrollPane5.setViewportView(jTextArea4);
jButton12.setText("Tes Statis 2");
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
jPanel8.setLayout(jPanel8Layout);
jPanel8Layout.setHorizontalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(24, 24, 24)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addComponent(jButton11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton12))
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 174, Short.MAX_VALUE)))
.addGap(92, 92, 92))
);
jPanel8Layout.setVerticalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(27, 27, 27)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton11)
.addComponent(jButton12))
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE))
.addGap(122, 122, 122))
);
jTabbedPane3.addTab("1.static", jPanel8);
jLabel8.setText("Ciri-ciri :");
jTextPane1.setText("1. Mencegah Method dari Proses OverRide\n2. Menjadikan Class tidak dapat diturunkan lagi\n3. Menjadikan Variable tidak dapat diubah (menjadi Konstanta)");
jScrollPane6.setViewportView(jTextPane1);
jButton13.setText("Tes Final");
jButton13.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton13ActionPerformed(evt);
}
});
jTextArea5.setColumns(20);
jTextArea5.setRows(5);
jScrollPane7.setViewportView(jTextArea5);
javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
jPanel9.setLayout(jPanel9Layout);
jPanel9Layout.setHorizontalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton13)
.addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(127, Short.MAX_VALUE))
);
jPanel9Layout.setVerticalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel9Layout.createSequentialGroup()
.addComponent(jButton13)
.addGap(18, 18, 18)
.addComponent(jScrollPane7))
.addGroup(jPanel9Layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(39, Short.MAX_VALUE))
);
jTabbedPane3.addTab("2.final", jPanel9);
jPanel4.add(jTabbedPane3, "card2");
jTabbedPane1.addTab("4.modifier (static & final)", jPanel4);
jButton14.setText("Test Abstract");
jButton14.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton14ActionPerformed(evt);
}
});
jButton15.setText("Test Interface");
jButton15.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton15ActionPerformed(evt);
}
});
jTextArea6.setColumns(20);
jTextArea6.setRows(5);
jScrollPane8.setViewportView(jTextArea6);
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(44, 44, 44)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(155, Short.MAX_VALUE))
.addGroup(jPanel5Layout.createSequentialGroup()
.addComponent(jButton14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 135, Short.MAX_VALUE)
.addComponent(jButton15)
.addGap(143, 143, 143))))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton14)
.addComponent(jButton15))
.addGap(18, 18, 18)
.addComponent(jScrollPane8, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(38, Short.MAX_VALUE))
);
jTabbedPane1.addTab("5.Abstract & Interface", jPanel5);
getContentPane().add(jTabbedPane1, "card2");
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Manusia dahlan=new Manusia("Dahlan Iskan");
jTextArea1.setText("Nama = "+dahlan.tampilkanNama()+
"\n"+dahlan.makan()+"\n"+dahlan.kerja()+"\n\n"+dahlan.tidur());
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Siswa angga = new Siswa("Si Ali");
jTextArea1.setText("Nama = "+angga.tampilkanNama()+
"\n"+angga.makan()+"\n"+angga.kerja()+"\n\n"+angga.tidur());
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
Guru hadi=new Guru("M Hadi Wijaya");
jTextArea1.setText("Nama Guru = "+hadi.tampilkanNama()+
"\nSifat Turunan = "+hadi.makan()+"\nSifat Overrides = "+
hadi.kerja()+"\nSifat Asli = "+hadi.tugas(null));
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
Manusia[] profesi=new Manusia[3];
profesi[0] = new Siswa("Angga Darmawan");
profesi[1] = new Guru("Hadi Wijaya");
profesi[2] = new Manusia("Simonchelli");
String statement1="Nama Siswa = "+profesi[0].tampilkanNama()+
"\n"+"Nama Guru = "+profesi[1].tampilkanNama()+
"\nNama Manusia (pembalap) = "+profesi[2].tampilkanNama();
String statement2="\n\n\n\n\nPekerjaan siswa = "+profesi[0].kerja()+
"\nPekerjaan guru = "+profesi[1].kerja()+
"\nPekerjaan pembalap = "+profesi[2].kerja();
jTextArea1.setText(statement1+statement2);
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
Bentuk3D bentuk=new Bentuk3D(3.5);
jTextArea2.setText("Panjang = "+bentuk.panjang+"\nLebar = "+
bentuk.lebar+"\nTinggi = "+bentuk.tinggi);
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
Bentuk3D bentuk=new Bentuk3D(3.5,2.4);
jTextArea2.setText("Panjang = "+bentuk.panjang+"\nLebar = "+
bentuk.lebar+"\nTinggi = "+bentuk.tinggi);
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
Bentuk3D bentuk=new Bentuk3D(3.5,2.4,4.7);
jTextArea2.setText("Panjang = "+bentuk.panjang+"\nLebar = "+
bentuk.lebar+"\nTinggi = "+bentuk.tinggi);
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
Mobil kijang=new Mobil("Kijang Innova");
jTextArea2.setText(kijang.st+"\n"+kijang.bergerak("depan")+"\n"+
kijang.bergerak("belakang",3));
}
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
Basah tart=new Basah("Kue Tart");
jTextArea3.setText(tart.kadaluarsa());
}
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {
Basah tart=new Basah("Kue Marie");
jTextArea3.setText(tart.kadaluarsa());
}
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
//instansiasi pertama :)
//Sepeda motor = new Sepeda();
Sepeda.jmlRoda =2;
String stm1=("Jumlah Roda Motor = "+Sepeda.jmlRoda);
//instansiasi kedua :)
//Sepeda becak = new Sepeda();
Sepeda.jmlRoda = 3;
String stm2=("Jumlah Roda Becak = "+Sepeda.jmlRoda);
// apa yang terjadi ketika objek motor dipanggil lagi ...
String stm3=("Jreng..jreng...,apa yang terjadi pada jumlah roda motor...");
String stm4=("Jumlah Roda Motor = "+Sepeda.jmlRoda);
jTextArea4.setText(stm1+"\n"+stm2+"\n"+stm3+"\n"+stm4+"\n"+
Sepeda.melaju(null));
}
private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {
//mengeset data langsung dr Class tanpa pembuatan objek
Sepeda.jmlRoda = 5;
jTextArea4.setText("Jumlah roda sepeda = "+Sepeda.jmlRoda);
}
private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
Hitung lingkaran = new Hitung(76);
//ilegal access
//lingkaran.phi=4.15;
jTextArea5.setText("phi ="+lingkaran.phi+"\n"+"jari2 ="+lingkaran.jari2+"\n"+"Luas Lingkaran = "+lingkaran.Luas());
}
private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {
Manusia andri=new Manusia("Andri Bagus Nugroho");
Animal kucing=new Animal();
//MakhlukHidup a = null;
String stm1=(andri.tampilkanNama()+"\n"+andri.makan()+"\n"+andri.jalan());
String stm2=("\n\nSi Puss"+" "+kucing.jalan()+"\n"+"kalo bernafas bersuara "+kucing.bernafas());
jTextArea6.setText(stm1+stm2);
}
private void jButton15ActionPerformed(java.awt.event.ActionEvent evt) {
PencariIlmu toni = new PencariIlmu();
jTextArea6.setText("toni adalah objek PencariIlmu\n\nkerjaannya :\n"+toni.lakukanSesuatu()+"\n"+
toni.lakukanExtraSesuatu()+"\n"+
toni.lakukanJob());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(FormPBO_netBeans.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(FormPBO_netBeans.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(FormPBO_netBeans.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(FormPBO_netBeans.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FormPBO_netBeans().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton11;
private javax.swing.JButton jButton12;
private javax.swing.JButton jButton13;
private javax.swing.JButton jButton14;
private javax.swing.JButton jButton15;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JEditorPane jEditorPane1;
private javax.swing.JEditorPane jEditorPane2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JPanel jPanel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JScrollPane jScrollPane7;
private javax.swing.JScrollPane jScrollPane8;
private javax.swing.JScrollPane jScrollPane9;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTabbedPane jTabbedPane2;
private javax.swing.JTabbedPane jTabbedPane3;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextArea jTextArea2;
private javax.swing.JTextArea jTextArea3;
private javax.swing.JTextArea jTextArea4;
private javax.swing.JTextArea jTextArea5;
private javax.swing.JTextArea jTextArea6;
private javax.swing.JTextPane jTextPane1;
// End of variables declaration
}
kemudian akan muncul hasil seperti berikut saat di run :
Membuat Program Enkripsi Dengan Java Applet
Gambar diatas adalah program enkripsi dengan Java Applet
Untuk Codingnya kita lihat dibawah ini:
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import java.io.BufferedWriter;
import java.io.PrintWriter;
import java.io.FileWriter;
import javax.swing.JOptionPane;
import javax.swing.*;
import java.io.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.filechooser.FileFilter;
public class ta_java extends javax.swing.JFrame {
public ta_java() {
initComponents();
this.setTitle("Untitled - NOTES");
fc = new JFileChooser();
fc.addChoosableFileFilter(new jenisFile(EXT));
fc.addChoosableFileFilter(new jenisFile(EXT2));
fc.setAcceptAllFileFilterUsed(false);
fileBaru = true;
}
JFileChooser fc;
File file;
boolean fileBaru;
final String[] EXT = { ".csv" };
final String[] EXT2 = { ".txt", ".java" };
public String text,namafiletext;
private void msg(String pesan) {
JOptionPane.showMessageDialog(this,pesan,"Informasi", JOptionPane.INFORMATION_MESSAGE);
}
private boolean okToReplace() {
return (JOptionPane.showConfirmDialog(this, "File "+file.getName()+" Sudah Ada\n"+ "Akan Ditimpa ?",
"Peringatan",JOptionPane.YES_NO_OPTION)==0) ;
}
class jenisFile extends FileFilter {
private String[] s;
jenisFile(String[] sArg) {
s = sArg;
}
public boolean accept(File fArg) {
if (fArg.isDirectory())
return true;
for (int i = 0; i < s.length; ++i)
if (fArg.getName().toLowerCase().indexOf(s[i].toLowerCase()) > 0)
return true;
return false;
}
public String getDescription() {
String tmp = "";
for (int i = 0; i < s.length; ++i)
tmp += "*" + s[i] + " ";
return tmp;
}
}
private void SimpanFile() {
PrintWriter pw = null;
try {
pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
} catch (IOException e) {
msg("Gagal Simpan File : '" + file.getName());
return;
}
pw.print(isi1.getText());
pw.close();
this.setTitle(file.getName()+" - NOTES" );
fileBaru = false;
}
class Enskripsimd5 {
private String convertToHex(byte[] data) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < data.length; i++) {
int halfbyte = (data[i] >>> 4) & 0x0F;
int two_halfs = 0;
do {
if ((0 <= halfbyte) && (halfbyte <= 9)) {
buf.append((char) ('0' + halfbyte));
} else {
buf.append((char) ('a' + (halfbyte - (int) geser.getValue())));
}
halfbyte = data[i] & 0x0F;
} while (two_halfs++ < 1);
}
return buf.toString();
}
public String MD5(String text)
throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md;
md = MessageDigest.getInstance("MD5");
byte[] md5hash = new byte[32];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
md5hash = md.digest();
return convertToHex(md5hash);
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ta_java().setVisible(true);
}
});
}
private String readFile(File file){
String result="";
try{
FileInputStream fis=new FileInputStream(file);
BufferedInputStream bis=new BufferedInputStream(fis);
DataInputStream dis=new DataInputStream(bis);
while(dis.available()!=0){
result +=dis.readLine()+"\n";
}
}
catch(FileNotFoundException e){
}
catch(IOException e){
}
return result;
}
private void bukaActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser fc= new JFileChooser();
JFrame jf= new JFrame();
int ret= fc.showOpenDialog(jf.add(fc));
if(ret==JFileChooser.APPROVE_OPTION) {
File file=fc.getSelectedFile();
text=readFile(file);
isi1.setText(text);
namafiletext=file.getPath().toString();
nama_file.setText(namafiletext);
}
}
private void simpanActionPerformed(java.awt.event.ActionEvent evt) {
if (fileBaru)
simpan.doClick();
else
SimpanFile();
}
private void simpan_sbgActionPerformed(java.awt.event.ActionEvent evt) {
if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION){
file = fc.getSelectedFile();
if (!file.exists() || okToReplace())
SimpanFile();
}
}
private void baruActionPerformed(java.awt.event.ActionEvent evt) {
isi1.setText("");
isi1.requestFocus();
this.setTitle("Untitled - NOTES");
fileBaru = true;
}
private void keluarActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void ubahActionPerformed(java.awt.event.ActionEvent evt) {
isi1.setEnabled(true);
}
private void md5_1ActionPerformed(java.awt.event.ActionEvent evt) {
save2.setEnabled(true);
password2.setEnabled(true);
pass2.setEnabled(true);
isi2.setEnabled(true);
saveas2.setEnabled(true);
md5_2.setEnabled(true);
random2.setEnabled(true);
Enskripsimd5 md5 = new Enskripsimd5();
try {
isi2.setText(md5.MD5(isi1.getText()));
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(ta_java.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(ta_java.class.getName()).log(Level.SEVERE, null);
}
}
private void random1ActionPerformed(java.awt.event.ActionEvent evt) {
save2.setEnabled(true);
password1.setEnabled(true);
pass2.setEnabled(true);
isi2.setEnabled(true);
saveas2.setEnabled(true);
md5_2.setEnabled(true);
random2.setEnabled(true);
String randomKey = "";
double randomNumber;
for (int i = 0; i < isi1.getText().length(); i++) {
randomNumber = Math.random() * 25 + 65;
randomKey = randomKey + (char) randomNumber;
}
isi2.setText(randomKey);
}
private void save2ActionPerformed(java.awt.event.ActionEvent evt) {
if (fileBaru) {
saveas2.doClick();
} else {
SimpanFile();
}
}
private void saveas2ActionPerformed(java.awt.event.ActionEvent evt) {
if (fc.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
file = fc.getSelectedFile();
if (!file.exists() || okToReplace()) {
SimpanFile();
}
}
}
private void random2ActionPerformed(java.awt.event.ActionEvent evt) {
String randomKey = "";
double randomNumber;
for (int i = 0; i < isi2.getText().length(); i++) {
randomNumber = Math.random() * 25 + 65;
randomKey = randomKey + (char) randomNumber;
}
isi1.setText(randomKey);
}
private void password1ActionPerformed(java.awt.event.ActionEvent evt) {
if (pass2.getText().equals(pass1.getText())) {
msg("password anda benar : " + pass1.getText());
isi1.setText(isi2.getText());
} else {
msg("password anda salah : " + pass1.getText());
}
}
private void password2ActionPerformed(java.awt.event.ActionEvent evt) {
if (pass1.getText().equals(pass2.getText())) {
msg("password anda benar : " + pass2.getText());
isi2.setText(isi1.getText());
} else {
msg("password anda salah : " + pass2.getText());
}
}
Write File
Ini sekedar contoh buat nulis file diaplikasi java terus hasil tulisannya itu dipindahin ke notepad :
package testjeni;
import java.io.*;
/**
*
* @author Mothed
*/
public class WriteFile {
public static void main(String args[]) throws IOException {
System.out.println("What is the name of the file to be written to?");
String filename;
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
filename = br.readLine();
System.out.println("Enter data to write to " + filename +
"...");
System.out.println("Type q$ to end.");
FileOutputStream fos = null;
try {
fos = new FileOutputStream(filename);
}
catch (FileNotFoundException ex) {
System.out.println("File cannot be opened for writing.");
}
try {
boolean done = false;
int data;
do {
data = br.read();
if ((char)data == 'q') {
data = br.read();
if ((char)data == '$') {
done = true;
} else {
fos.write('q');
fos.write(data);
}
} else {
fos.write(data);
}
} while (!done);
} catch (IOException ex) {
System.out.println("Problem in reading from the file.");
}
}
}
INGET, jangan lupa sediain satu file notepad juga di D atau E yang belum ada isinya , untuk dituliskan di notepad ini sebagai hasil dari program ini
contoh outputnya adalah
senang_deh_belajar_java_q$
q$
;
$
Selamat mencoba teman-teman :D
Greet User
Kalo yg ini buat manggil nama si pemakai :
package testjeni;
import java.io.*;
/**
*
* @author ACER
*/
public class GreetUser {
public static void main(String args[]) throws IOException {
System.out.println("Hi, what's your name?");
String name;
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
name = br.readLine();
System.out.println("Nice to meet you, " + name + "! :)");
}
}
hasil outputnya :
Hi, what's your name?
dea
Nice to meet you, dea! :)
I /O Stream
1. Tujuan
· Tahu tipe-tipe stream yang umum digunakan
· Menggunakan class File dan methodnya
· Karakter dan Stream byte
· Input dan Output Streams
· Node dan Filter Streams
· Menggunakan class-class Input/Output yang berbeda
· Reader
· Writer
· InputStream
· OutputStream
· Memahami konsep dari stream chaining
· Mendefinisikan serialisasi
· Memahami penggunaan dari kata kunci transient
· Menulis dan membaca dari sebuah object stream
2. Latar Belakang
Dalam module sebelumnya, Anda telah mempelajari bagaimana untuk mendapatkan
input user dan memanipulasi file-file menggunakan strea. Kini Anda akan mempelajari lebih banyak tentang stream dan class-class stream yang lain.
Tipe-Tipe Stream yang Umum Digunakan
Stream Karakter dan Byte
Seperti yang elah disebutkan sebelumnya, secara umum ada dua tipe dari stream, yaitu stream karakter dan byte. Kita hanya mengulang perbedaan mendasar antara keduanya. Stream byte adalah abstraksi file atau alat untuk data biner sedangkan stream karakter adalah untuk karakter Unicode.
Class InputStream adalah abstraksi class root untuk semua input stream byte sedangkan class OutputStream adalah class root abstraksi dari semua output stream byte. Untuk stream karakter, superclasss yang sesuai dari semua class-class secara berturut-turut
adalah class Reader dan the Writer. Kedua class-class ini adalah abstraksi class-class untuk membaca dan menulis stream karakter.
Input dan Output Stream
Stream juga dikategorikan berdasarkan apakah mereka digunakan untuk membaca atau menulis stream.Walaupun ini sudah cukup nyata, izinkan saya untuk mendefinisikan tipe stream ini. Anda diijinan untuk membaca dari input stream tapi tidak menulisnya. Di lain pihak, Anda diijinkan untuk menulis output streams tapi tidak membacanya. Class InputStream dan class Reader adalah superclass-superclass dari semua input stream. Class OutputStream dan class Writer adalah class-class root dari semua output stream. Input stream juga dikenal sebagai stream sumber (source stream) sejak kita memperoleh informasi dari stream ini. sementara itu output stream disebut juga stream
hasil(sink stream).
Node dan Stream Filter
Kini package java.io membedakan antara node dan stream filter. Sebuah stream node adalah sebuah stream dengan fungsi dasar berupa fungsi membaca atau menulis dari sebuah lokasi khusus seperti pada disk atau dari jaringan. Tipe-tipe dari stream node terdiri atas file, memory dan jalur data. Stream filter, di lain pihak, diletakkan pada layer stream node diantara threads atau proses untuk menyediakan fungsi tambahan yang tidak dapat ditemukan dalam stream node oleh stream node itu sendiri. Penambahan
lapisan pada sebuah stream node disebut dengan stream chaining. Sesi ini berturut-turut mempunyai sebuah tujuan dariclass-class stream yang berbeda. Untuk melengkapi daftar dari class-class ini, silahkan melihat dokumentasi Java's API.
3. sedikit contoh :)
Informasi File atau Folder:
import java.io.*;
public class IO01 {
public static void main(String args[]) {
String fileName = args[0];
File fn = new File(fileName);
System.out.println("Name: " + fn.getName());
if (!fn.exists()) {
System.out.println(fileName + " does not exists.");
/* membuat sebuah temporary directory . */
System.out.println("Creating temp directory...");
fileName = "temp";
fn = new File(fileName);
fn.mkdir();
System.out.println(fileName + (fn.exists()? "exists": "does not exist"));
System.out.println("Deleting temp directory...");
fn.delete();
System.out.println(fileName + (fn.exists()? "exists": "does not exist"));
return;
}
System.out.println(fileName + " is a " + (fn.isFile()? "file." :"directory."));
if (fn.isDirectory()) {
String content[] = fn.list();
System.out.println("The content of this directory:");
for (int i = 0; i < content.length; i++) {
System.out.println(content[i]);
}
}
if (!fn.canRead()) {
System.out.println(fileName + " is not readable.");
return;
}
System.out.println(fileName + " is " + fn.length() + " bytes long.");
System.out.println(fileName + " is " + fn.lastModified() + " bytes long.");
if (!fn.canWrite()) {
System.out.println(fileName + " is not writable.");
}
}
}
Read File
Kalo yg satu ini, buat ngebaca isi yg ada di notepad kita, melalui aplikasi java kita :
package testjeni;
import java.io.*;
/**
*
* @author Mothed
*/
public class ReadFile {
public static void main(String args[]) throws IOException {
System.out.println("What is the name of the file to read from?");
String filename;
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
filename = br.readLine();
System.out.println("Now reading from " + filename + "...");
FileInputStream fis = null;
try {
fis = new FileInputStream(filename);
} catch (FileNotFoundException ex) {
System.out.println("File not found.");
}
try {
char data;
int temp;
do {
temp = fis.read();
data = (char) temp;
if (temp != -1) {
System.out.print(data);
}
} while (temp != -1);
} catch (IOException ex) {
System.out.println("Problem in reading from the file.");
}
}
}
contoh penulisannya gini : direktori yg kalian kehendaki:/nama file yg mau kalian baca
C:/bijak.txt
*INGET, file yg bisa dibaca cuma dengan format txt!
Selamat mencoba :D
GUI. SWT,SWING,AWT
Java AWT
Abstrak Windows Toolkit (AWT) adalah Jawa asli GUI tool kit.
Keuntungan utama AWT adalah bahwa ia datang standar dengan
setiap versi teknologi Java, termasuk implementasi Java di browser
Web tua, dan sangat stabil. Ini berarti Anda tidak perlu menginstalnya,
Anda dapat bergantung pada itu menjadi tersedia di mana Anda menemukan
lingkungan runtime Jawa, dan akan memiliki fitur yang Anda harapkan.
Java SWT
SWT adalah tingkat rendah GUI tool kit sebanding dalam konsep untuk AWT.
JFace adalah seperangkat komponen ditingkatkan dan layanan utilitas untuk
membuat bangunan dengan GUI SWT lebih mudah. Pembangun SWT dipelajari
dari implementasi AWT dan Swing dan mencoba untuk membangun sebuah
sistem yang memiliki keunggulan dari kedua tanpa kelemahan mereka.
Dalam banyak hal, mereka berhasil.
Java Swing
Java Swing, juga dikenal sebagai bagian dari Java Yayasan Kelas (JFC),
merupakan upaya untuk memecahkan sebagian besar kekurangan AWT
tersebut. Dalam Swing, Sun menciptakan, sangat baik-rekayasa fleksibel
kit alat, kuat GUI. Sayangnya, ini swing berarti membutuhkan waktu untuk
belajar, dan kadang-kadang terlalu rumit untuk situasi umum.