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

Java GUI Rental Calculator Code

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)
10 views3 pages

Java GUI Rental Calculator Code

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

PAKAI BUTTON

private void
jButton1ActionPerformed([Link]
[Link] evt) {
int
jml_pinjam=[Link](jTextFiel
[Link]());

if
([Link]()==true)
total=total-100000;

if
([Link]()==true)
total=total-200000;

int harga_sewa=0;
if([Link]()==
0){
harga_sewa=300000;

if([Link]()==1)
total=total(jml_pinjam*25000);

}
[Link]("Jumlah yang
dibayar "+total);
if([Link]()==
1){
harga_sewa=250000;
}

}
private void
formWindowActivated([Link]
.WindowEvent evt) {
// TODO add your handling code
here:
[Link]("Luar Kota");

if([Link]()==
2){
harga_sewa=200000;

[Link]("Dalam Kota");
}

}
private void
jButton2ActionPerformed([Link]
[Link] evt) {
int total=0;

// TODO add your handling code


here:
[Link](0);

if([Link]()==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[]) {
[Link](ne
w Runnable() {

public void run() {


new
pbo5_3().setVisible(true);
}
});
}
GAK PAKAI BUTTON
private void tes() {
int
jml_pinjam=[Link](jTextFiel
[Link]());
int harga_sewa=0;
if([Link]()==
0){
harga_sewa=300000;
}

if([Link]()==
1){
harga_sewa=250000;
}

if([Link]()==
2){
harga_sewa=200000;
}

int total=0;
if([Link]()==true)
//apabila checkbox di centang
total=(jml_pinjam*harga_sewa)+
(jml_pinjam*100000);

else
total=(jml_pinjam*harga_sewa);
if
([Link]()==true)
total=total-100000;
if
([Link]()==true)
total=total-200000;

if([Link]()==1)
total=total(jml_pinjam*25000);
[Link]("Jumlah yang
dibayar "+total);
}

private void
formWindowActivated([Link]
.WindowEvent evt) {
// TODO add your handling code
here:
[Link]("Luar Kota");
[Link]("Dalam Kota");
}
private void
jButton2ActionPerformed([Link]
[Link] evt) {
// TODO add your handling code
here:
[Link](0);
}
private void
jTextField1KeyPressed([Link]
.KeyEvent evt) {
// TODO add your handling code
here:
if ([Link]()!=""){
tes();
}
}
private void
jTextField1KeyReleased([Link]
[Link] evt) {

// TODO add your handling code


here:
if ([Link]()!=""){
tes();
}
}

// TODO add your handling code


here:
if ([Link]()!=""){
tes();
}
}

private void
jComboBox1ItemStateChanged(java.
[Link] evt) {
// TODO add your handling code
here:
if ([Link]()!=""){
tes();
}
}

private void
jRadioButton3MouseClicked([Link].
[Link] evt) {
// TODO add your handling code
here:
if ([Link]()!=""){
tes();
}
}

private void
list1ItemStateChanged([Link]
[Link] evt) {
// TODO add your handling code
here:
if ([Link]()!=""){
tes();
}
}

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

private void
jCheckBox1MouseClicked([Link]
[Link] evt) {
// TODO add your handling code
here:
if ([Link]()!=""){
tes();
}
}

public void run() {


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

private void
jRadioButton1MouseClicked([Link].
[Link] evt) {
// TODO add your handling code
here:
if ([Link]()!=""){
tes();
}
}
private void
jRadioButton2MouseClicked([Link].
[Link] evt) {

[Link](ne
w Runnable() {

You might also like