B. Listing Program
/*
* To change this
template, choose Tools | Templates
* and open the
template in the editor.
*/
package tiket;
import javax.swing.JOptionPane;
/**
*
* @author sugi
*/
public class quiz extends javax.swing.JFrame {
int
Anak,Dewasa,Harga,Beli,Total;
private void
SelesaiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
int
answer=JOptionPane.showConfirmDialog(null, "Thanks You",
"Selesai", JOptionPane.OK_OPTION);
if
(answer==JOptionPane.OK_OPTION){
dispose();
}
}
private void
jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
if(jComboBox1.getSelectedItem().equals("TR111")){
c.setText("Matarmaja");
jCombo.addItem("Pasar Senen-Tegal");
jCombo.addItem("Pasar Senen-Madiun");
jCombo.removeItem("Tanah Abang-Tegal");
jCombo.removeItem("Tanah Abang-Madiun");
jCombo.removeItem("Gambir-Lempuyangan");
jCombo.removeItem("Gambir-Kutoarjo");
}
else
if(jComboBox1.getSelectedItem().equals("TR222")){
c.setText("Brantas");
jCombo.addItem("Tanah Abang-Madiun");
jCombo.addItem("Tanah Abang-Tegal");
jCombo.removeItem("Pasar Senen-Tegal");
jCombo.removeItem("Pasar
Senen-Madiun");
jCombo.removeItem("Gambir-Lempuyangan");
jCombo.removeItem("Gambir-Kutoarjo");
}
else
if(jComboBox1.getSelectedItem().equals("TR333")){
c.setText("Bengawan");
jCombo.addItem("Gambir-Kutoarjo");
jCombo.addItem("Gambir-Lempuyangan");
jCombo.removeItem("Tanah Abang-Tegal");
jCombo.removeItem("Tanah Abang-Madiun");
jCombo.removeItem("Pasar Senen-Tegal");
jCombo.removeItem("Pasar Senen-Madiun");
}
else
if(jComboBox1.getSelectedItem().equals("--PILIH JURUSAN--")){
c.setText("--PILIH JURUSAN--");
jCombo.removeItem("Gambir-Kutoarjo");
jCombo.removeItem("Gambir-Lempuyangan");
jCombo.removeItem("Tanah Abang-Tegal");
jCombo.removeItem("Tanah Abang-Madiun");
jCombo.removeItem("Pasar Senen-Tegal");
jCombo.removeItem("Pasar Senen-Madiun");
}
}
private void
jComboActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
if(jCombo.getSelectedItem().equals("----Jurusan----")){
buttonGroup1.clearSelection();
d.setText("");
}
else
if(jCombo.getSelectedItem().equals("Pasar Senen-Tegal")){
Anak=30000;
Dewasa=60000;
}
else
if(jCombo.getSelectedItem().equals("Pasar Senen-Madiun")){
Anak=35000;
Dewasa=65000;
}
else
if(jCombo.getSelectedItem().equals("Tanah Abang-Tegal")){
Anak=40000;
Dewasa=70000;
}
else
if(jCombo.getSelectedItem().equals("Tanah Abang-Madiun")){
Anak=35000;
Dewasa=75000;
}
else
if(jCombo.getSelectedItem().equals("Gambir-Kutoarjo")){
Anak=50000;
Dewasa=80000;
}
else
if(jCombo.getSelectedItem().equals("Gambir-Lemputangan")){
Anak=55000;
Dewasa=85000;
}
}
private void
Rd1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
if(Rd1.isSelected()){
d.setText(String.valueOf(Anak));
}
}
private void
LagiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
a.setText("");
jComboBox1.setSelectedItem("--PILIH KODE--");
c.setText("");
jCombo.setSelectedItem("--PILIH JURUSAN--");
buttonGroup1.clearSelection();
d.setText("");
e.setText("");
f.setText("");
}
private void
Rd2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
if(Rd2.isSelected()){
d.setText(String.valueOf(Dewasa));
}
}
private void
eActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
Beli=Integer.parseInt(e.getText());
Harga=Integer.parseInt(d.getText());
Total=Beli*Harga;
f.setText(String.valueOf(Total));
}