Kodingnya
package tishift;
/**
*
* @author Darryl
*/
public class menu extends javax.swing.JFrame {
/** Creates new form menu */
public menu() {
initComponents();
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
new cafe().setVisible(true);
// TODO add your handling code here:
}
private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
Selanjutnya design Kembali Sesuai selera.
Kodingnya :
public class cafe extends javax.swing.JFrame {
String namamakanan,namaminuman;
int hargamakanan,hargaminuman,total,bayar,kembalian,kembali;
/** Creates new form cafe */
public cafe() {
initComponents();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
total=hargaminuman+hargamakanan;
txttotal.setText(String.valueOf(total));
}
private void txtbayarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void txtkembaliActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void cbminumanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String namaminuman;
namaminuman=cbminuman.getSelectedItem().toString();
if(namaminuman.equalsIgnoreCase("jus"))
{
hargaminuman=5000;
}
else if(namaminuman.equalsIgnoreCase("Susu"))
{
hargaminuman=6000;
}
txthmin.setText(String.valueOf(hargaminuman));
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
bayar=Integer.parseInt(txtbayar.getText());
total=Integer.parseInt(txttotal.getText());
kembalian=bayar-total;
txtkembali.setText(String.valueOf(kembalian));
}
private void cbmakananActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String namamakanan;
namamakanan=cbmakanan.getSelectedItem().toString();
if(namamakanan.equalsIgnoreCase("Burger"))
{
hargamakanan=15000;
}
else if(namamakanan.equalsIgnoreCase("Kacang"))
{
hargamakanan=5000;
}
txthmak.setText(String.valueOf(hargamakanan));
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
cbminuman.setSelectedIndex(0);
cbmakanan.setSelectedIndex(0);
txthmin.setText("");
txthmak.setText("");
txttotal.setText("");
txtbayar.setText("");
txtkembali.setText("");
}
Dan Hasilnya akan menjadi seperti ini :
Rabu, 09 November 2011
Membuat daftar Menu Cafe Menggunakan Net Beans
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar