PROGRAM APLIKASI TIKET BUS
APLIKASI INI DI
BUAT
MENGGUNAKAN JAVA/NETBEANS.
Saya akan membuat
aplikasi sederhana yaitu, APLIKAS TIKET BUS. Aplikasi ini dapat membantu
mempermudah saat memesan tiket bus secara efektif.
1. Pertama - tama kita mendesain awal Jframe, seperti ini,
2. Berikut
langkah-langkah dalam pemesanan tiket:
- Input
nama
-
Memilih
tujuan yang akan di tuju seperti.
1.
Jakarta
- Semarang
2.
Semarang
– Jakarta
3.
Yogyakarta
– Bandung
4.
Surabaya
– Jakarta
-
Pilih
jenis tiket.
1.
Ekonomi
2.
VIP
-
Harga
tiket akan muncul setelah memilih jenis tiket.
-
Pilih
Jam keberangkatan
-
Pilih
jumlah tiket yang akan di pesan
-
Setelah
itu Klik tombol PROSES dan akan muncul total keseluruhan
-
Jika tidak
jadi memesan tiket klik tombol hapus.
3. Inilah contoh setelah sudah di input semua.
Source code :
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tiketbus;
/**
*
* @author Asus
*/
public class Tiket extends javax.swing.JFrame {
private Object Interger;
private Object hargaSatuan;
private Object HargaSatuan;
/**
* Creates new form Tiket
*/
public Tiket() {
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() {
jDesktopPane1 = new
javax.swing.JDesktopPane();
jLabel1 = new
javax.swing.JLabel();
jLabel2 = new
javax.swing.JLabel();
jLabel3 = new
javax.swing.JLabel();
jLabel4 = new
javax.swing.JLabel();
jLabel5 = new
javax.swing.JLabel();
jLabel6 = new
javax.swing.JLabel();
jLabel7 = new
javax.swing.JLabel();
Nama = new
javax.swing.JTextField();
Tujuan = new javax.swing.JComboBox();
JamBerangkat = new
javax.swing.JComboBox();
jButton1 = new
javax.swing.JButton();
jButton2 = new
javax.swing.JButton();
JumlahTotal = new
javax.swing.JTextField();
JumlahTiket = new
javax.swing.JTextField();
EKONOMI = new
javax.swing.JRadioButton();
VIP = new
javax.swing.JRadioButton();
HARGATIKET = new
javax.swing.JTextField();
jLabel8 = new
javax.swing.JLabel();
javax.swing.GroupLayout
jDesktopPane1Layout = new javax.swing.GroupLayout(jDesktopPane1);
jDesktopPane1.setLayout(jDesktopPane1Layout);
jDesktopPane1Layout.setHorizontalGroup(
jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100,
Short.MAX_VALUE)
);
jDesktopPane1Layout.setVerticalGroup(
jDesktopPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100,
Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new
java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setText("PROGRAM
TIKET BUS");
jLabel2.setText("NAMA");
jLabel3.setText("PILIH
TUJUAN");
jLabel4.setText("PILIH
JENIS TIKET");
jLabel5.setText("JAM
KEBERANGKATAN");
jLabel6.setText("JUMLAH
TIKET");
Nama.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
NamaActionPerformed(evt);
}
});
Tujuan.setModel(new
javax.swing.DefaultComboBoxModel(new String[] { "PILIH", "1.
JAKARTA - SEMARANG", "2. SEMARANG - JAKARTA", "3.
YOGYAKARTA - BANDUNG", "4. SURABAYA - JAKARTA" }));
Tujuan.setToolTipText("");
Tujuan.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
TujuanActionPerformed(evt);
}
});
JamBerangkat.setModel(new
javax.swing.DefaultComboBoxModel(new String[] { "- 10:00", "-
13:00 ", "- 15:00 ", "- 18:00", "- 20:00 "
}));
jButton1.setText("PROSES");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setText("HAPUS");
jButton2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
JumlahTotal.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
JumlahTotalActionPerformed(evt);
}
});
JumlahTiket.addActionListener(new java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
JumlahTiketActionPerformed(evt);
}
});
EKONOMI.setText("EKONOMI");
EKONOMI.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
EKONOMIActionPerformed(evt);
}
});
VIP.setText("VIP");
VIP.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
VIPActionPerformed(evt);
}
});
HARGATIKET.addActionListener(new java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
HARGATIKETActionPerformed(evt);
}
});
jLabel8.setText("HARGA
TIKET");
javax.swing.GroupLayout
layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(149, 149, 149)
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(28,
Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7)
.addComponent(jLabel8))
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(EKONOMI)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(VIP))
.addComponent(HARGATIKET,
javax.swing.GroupLayout.PREFERRED_SIZE, 69,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JamBerangkat, javax.swing.GroupLayout.PREFERRED_SIZE, 88,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Nama,
javax.swing.GroupLayout.PREFERRED_SIZE, 180,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(JumlahTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 107,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Tujuan,
javax.swing.GroupLayout.PREFERRED_SIZE, 152,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(JumlahTiket, javax.swing.GroupLayout.PREFERRED_SIZE, 46,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(63,
63, 63)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)))
.addGap(21, 21, 21))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 14,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 19,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Nama, javax.swing.GroupLayout.PREFERRED_SIZE, 27,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(Tujuan, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(EKONOMI)
.addComponent(VIP))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(HARGATIKET, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(JamBerangkat, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jButton1)
.addComponent(jButton2)
.addComponent(JumlahTiket, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(32, 32, 32)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(JumlahTotal, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(55, 55, 55))
);
pack();
}// </editor-fold>
private void
TujuanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling
code here:
}
private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling
code here:
JumlahTotal.setText("");
JumlahTiket.setText("");
Nama.setText("");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling
code here:
int a =
Integer.parseInt(HARGATIKET.getText());
int b =
Integer.parseInt(JumlahTiket.getText());
int hasil = a * b;
JumlahTotal.setText("Rp.
" + hasil);
}
private void
NamaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling
code here:
}
private void
JumlahTiketActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling
code here:
}
private void
EKONOMIActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling
code here:
HARGATIKET.setText("150000");
}
private void
VIPActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling
code here:
HARGATIKET.setText("300000");
}
private void HARGATIKETActionPerformed(java.awt.event.ActionEvent
evt) {
// TODO add your handling
code here:
}
private void
JumlahTotalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling
code here:
}
/**
* @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(Tiket.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(InstantiationException ex) {
java.util.logging.Logger.getLogger(Tiket.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Tiket.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Tiket.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
Tiket().setVisible(true);
}
});
}
private javax.swing.JRadioButton
EKONOMI;
private javax.swing.JTextField
HARGATIKET;
private javax.swing.JComboBox
JamBerangkat;
private javax.swing.JTextField
JumlahTiket;
private javax.swing.JTextField
JumlahTotal;
private javax.swing.JTextField
Nama;
private javax.swing.JComboBox
Tujuan;
private javax.swing.JRadioButton
VIP;
private javax.swing.JButton
jButton1;
private javax.swing.JButton
jButton2;
private javax.swing.JDesktopPane
jDesktopPane1;
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;
// End of variables declaration
}
Sekian
dari saya, cara membuat aplikasi pemesanan tiket bus. Semoga bermanfaat bagi
kailan semua yang membutuhkan.
Tidak ada komentar:
Posting Komentar