Halooo, ketemu lagi dipostingan java
netbeans yang keempat. Kali ini saya akan membuat aplikasi “Cetak Foto”.
Berikut uraian dan penjelasannya.
Yang pertama ini adalah desain dari
jframe “Login”
Source Coding :
Source Coding Pada Button “Masuk” :
if
(Nama.getText().equals("admin")){
//jika nama sudah benar, cek
sandinya
if
(Sandi.getText().equals("nurmala")){
new Isinya().show();
this.dispose();
}else{
JOptionPane.showMessageDialog(rootPane, "Kata Sandi "
+ "salah,Silahkan
Ulangi");
Sandi.setText("");
Sandi.requestFocus();
}
}else{
JOptionPane.showMessageDialog(rootPane, "Nama "
+ "salah,Silahkan
Ulangi");
Nama.setText("");
Sandi.setText("");
Nama.requestFocus();
}
Desain :
Screen Shoot :
Suorce Coding “RadioButton” :
RadioButton 1 :
int hasil=0;
if(rb1.isSelected()){
harga1.setText("4000");
}else{
harga1.setText("");
}
RadioButton 2 :
int hasil=0;
if(rb2.isSelected()){
harga1.setText("4000");
}else{
harga1.setText("");
}
RadioButton 3 :
int hasil=0;
if(rb3.isSelected()){
harga1.setText("4000");
}else{
harga1.setText("");
}
Source Coding “CheckBox” :
CheckBox 1, 2, dan 3 tanpa menggunakan
Source Coding
CheckBox 4 :
int hasil=0;
if(dua.isSelected()){
harga2.setText("1000");
}else{
harga2.setText("");
}
CheckBox 5 :
int hasil=0;
if(tiga.isSelected()){
harga3.setText("3000");
}else{
harga3.setText("");
}
CheckBox 6 :
int hasil=0;
if(empat.isSelected()){
harga4.setText("5000");
}else{
harga4.setText("");
}
CheckBox 7 :
int hasil=0;
if(lima.isSelected()){
harga5.setText("10000");
}else{
harga5.setText("");
}
CheckBox 8 :
int hasil=0;
if(enam.isSelected()){
harga6.setText("10000");
}else{
harga6.setText("");
}
CheckBox 9 :
int hasil=0;
if(tujuh.isSelected()){
harga7.setText("15000");
}else{
harga7.setText("");
}
CheckBox 10 :
if(delapan.isSelected()){
harga8.setText("20000");
}else{
harga8.setText("");
}
CheckBox 11 :
int hasil=0;
if(sembilan.isSelected()){
harga9.setText("25000");
}else{
harga9.setText("");
}
CheckBox 12 :
int hasil=0;
if(sepuluh.isSelected()){
harga10.setText("40000");
}else{
harga10.setText("");
}
Source Coding 5 TextField terakhir,
sisanya tidak menggunakan Source Coding :
Textfield 1 :
int hasil=0;
int h1=Integer.parseInt(harga1.getText());
int h2=Integer.parseInt(harga2.getText());
int h3=Integer.parseInt(harga3.getText());
int h4=Integer.parseInt(harga4.getText());
int h5=Integer.parseInt(harga5.getText());
hasil = h1+h2+h3+h4+h5;
jumlah1.setText(""+hasil);
}
Textfield 2 :
int hasil=0;
int h6=Integer.parseInt(harga6.getText());
int h7=Integer.parseInt(harga7.getText());
int h8=Integer.parseInt(harga8.getText());
int h9=Integer.parseInt(harga9.getText());
int h10=Integer.parseInt(harga10.getText());
hasil = h6+h7+h8+h9+h10;
jumlah4.setText(""+hasil);
}
Textfield 3 :
int hasil=0;
int j1=Integer.parseInt(jumlah1.getText());
int j4=Integer.parseInt(jumlah4.getText());
hasil = j1+j4;
jumlah2.setText(""+hasil);
}
Textfield 4 :
Tanpa menggunakan Source Coding
Textfield 5 :
int hasil=0;
int j2=Integer.parseInt(jumlah2.getText());
int j5=Integer.parseInt(jumlah5.getText());
hasil = j5-j2;
jumlah6.setText(""+hasil);
}
Suorce Coding “Button” :
Button 1 :
harga1.setText("");
harga2.setText("");
harga3.setText("");
harga4.setText("");
harga5.setText("");
harga6.setText("");
harga7.setText("");
harga8.setText("");
harga9.setText("");
harga10.setText("");
jumlah1.setText("");
jumlah2.setText("");
jumlah4.setText("");
jumlah5.setText("");
jumlah6.setText("");
cf.setSelected(false);
ac.setSelected(false);
satu.setSelected(false);
dua.setSelected(false);
tiga.setSelected(false);
empat.setSelected(false);
lima.setSelected(false);
enam.setSelected(false);
tujuh.setSelected(false);
delapan.setSelected(false);
sembilan.setSelected(false);
sepuluh.setSelected(false);
rb1.setSelected(false);
rb2.setSelected(false);
rb3.setSelected(false);
Button 2 :
System.exit(0);
}
Selesai..
Semoga bermanfaat dan dapat dimengerti.. ;)