0% found this document useful (0 votes)
43 views3 pages

Script

The document contains code for a Java GUI application that calculates rental fees. It gets input from text fields, combo boxes, radio buttons, check boxes and lists. Based on the user selections, it calculates a total rental fee, applying discounts as needed. It displays the total in a label and exits when a button is clicked. The code was refactored to remove button actions and instead call a calculation method anytime an input field changes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views3 pages

Script

The document contains code for a Java GUI application that calculates rental fees. It gets input from text fields, combo boxes, radio buttons, check boxes and lists. Based on the user selections, it calculates a total rental fee, applying discounts as needed. It displays the total in a label and exits when a button is clicked. The code was refactored to remove button actions and instead call a calculation method anytime an input field changes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

PAKAI BUTTON

private void
jButton1ActionPerformed(java.awt.ev
ent.ActionEvent evt) {
int
jml_pinjam=Integer.parseInt(jTextFiel
d1.getText());

if
(jRadioButton2.isSelected()==true)
total=total-100000;

if
(jRadioButton3.isSelected()==true)
total=total-200000;

int harga_sewa=0;
if(jComboBox1.getSelectedIndex()==
0){
harga_sewa=300000;

if(list1.getSelectedIndex()==1)
total=total(jml_pinjam*25000);

}
jLabel6.setText("Jumlah yang
dibayar "+total);
if(jComboBox1.getSelectedIndex()==
1){
harga_sewa=250000;
}

}
private void
formWindowActivated(java.awt.event
.WindowEvent evt) {
// TODO add your handling code
here:
list1.add("Luar Kota");

if(jComboBox1.getSelectedIndex()==
2){
harga_sewa=200000;

list1.add("Dalam Kota");
}

}
private void
jButton2ActionPerformed(java.awt.ev
ent.ActionEvent evt) {
int total=0;

// TODO add your handling code


here:
System.exit(0);

if(jCheckBox1.isSelected()==true)
//apabila checkbox di centang

total=(jml_pinjam*harga_sewa)+
(jml_pinjam*100000);

/**

else
total=(jml_pinjam*harga_sewa);

* @param args the command line


arguments
*/

public static void main(String


args[]) {
java.awt.EventQueue.invokeLater(ne
w Runnable() {

public void run() {


new
pbo5_3().setVisible(true);
}
});
}
GAK PAKAI BUTTON
private void tes() {
int
jml_pinjam=Integer.parseInt(jTextFiel
d1.getText());
int harga_sewa=0;
if(jComboBox1.getSelectedIndex()==
0){
harga_sewa=300000;
}

if(jComboBox1.getSelectedIndex()==
1){
harga_sewa=250000;
}

if(jComboBox1.getSelectedIndex()==
2){
harga_sewa=200000;
}

int total=0;
if(jCheckBox1.isSelected()==true)
//apabila checkbox di centang
total=(jml_pinjam*harga_sewa)+
(jml_pinjam*100000);

else
total=(jml_pinjam*harga_sewa);
if
(jRadioButton2.isSelected()==true)
total=total-100000;
if
(jRadioButton3.isSelected()==true)
total=total-200000;

if(list1.getSelectedIndex()==1)
total=total(jml_pinjam*25000);
jLabel6.setText("Jumlah yang
dibayar "+total);
}

private void
formWindowActivated(java.awt.event
.WindowEvent evt) {
// TODO add your handling code
here:
list1.add("Luar Kota");
list1.add("Dalam Kota");
}
private void
jButton2ActionPerformed(java.awt.ev
ent.ActionEvent evt) {
// TODO add your handling code
here:
System.exit(0);
}
private void
jTextField1KeyPressed(java.awt.event
.KeyEvent evt) {
// TODO add your handling code
here:
if (jTextField1.getText()!=""){
tes();
}
}
private void
jTextField1KeyReleased(java.awt.eve
nt.KeyEvent evt) {

// TODO add your handling code


here:
if (jTextField1.getText()!=""){
tes();
}
}

// TODO add your handling code


here:
if (jTextField1.getText()!=""){
tes();
}
}

private void
jComboBox1ItemStateChanged(java.
awt.event.ItemEvent evt) {
// TODO add your handling code
here:
if (jTextField1.getText()!=""){
tes();
}
}

private void
jRadioButton3MouseClicked(java.awt.
event.MouseEvent evt) {
// TODO add your handling code
here:
if (jTextField1.getText()!=""){
tes();
}
}

private void
list1ItemStateChanged(java.awt.eve
nt.ItemEvent evt) {
// TODO add your handling code
here:
if (jTextField1.getText()!=""){
tes();
}
}

/**
* @param args the command line
arguments
*/
public static void main(String
args[]) {

private void
jCheckBox1MouseClicked(java.awt.ev
ent.MouseEvent evt) {
// TODO add your handling code
here:
if (jTextField1.getText()!=""){
tes();
}
}

public void run() {


new
pbo5_4().setVisible(true);
}
});
}

private void
jRadioButton1MouseClicked(java.awt.
event.MouseEvent evt) {
// TODO add your handling code
here:
if (jTextField1.getText()!=""){
tes();
}
}
private void
jRadioButton2MouseClicked(java.awt.
event.MouseEvent evt) {

java.awt.EventQueue.invokeLater(ne
w Runnable() {

You might also like