iseng-iseng aja nh,rumayan bagi-bagi pengalaman...
ok,nih saya mulai dengan penggabunga postingan saya yang dulu tetapi di tambah dengan beberapa tambahan sedikit biar mempermanis aplikasi aja,,
"ini contoh bagannya ",,,
"ini contoh Codingannya".....
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uts;
import java.awt.PopupMenu;
import javax.swing.JOptionPane;
/**
*
* @author Lenovo e440 UC 01
*/
public class UTS1 extends javax.swing.JFrame {
private PopupMenu uts2;
/**
* Creates new form UTS1
*/
public UTS1() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jMenuItem1 = new javax.swing.JMenuItem();
jLabel1 = new javax.swing.JLabel();
jb1 = new javax.swing.JButton();
jb2 = new javax.swing.JButton();
jCheckBox1 = new javax.swing.JCheckBox();
jCheckBox2 = new javax.swing.JCheckBox();
c1 = new javax.swing.JComboBox();
jLabel5 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
j1 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
j2 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
j3 = new javax.swing.JTextField();
jMenuBar1 = new javax.swing.JMenuBar();
ek = new javax.swing.JMenu();
jmkamar = new javax.swing.JMenuItem();
jmdokter = new javax.swing.JMenuItem();
jmpasien = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
lapkamar = new javax.swing.JMenuItem();
lapdokter = new javax.swing.JMenuItem();
lappasien = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenuItem1.setText("jMenuItem1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("RM. Ayam Sambel Setan");
jb1.setText("Hitung");
jb1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jb1ActionPerformed(evt);
}
});
jb2.setText("exit");
jb2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jb2MouseClicked(evt);
}
});
jCheckBox1.setText("Bakar");
jCheckBox2.setText("Goreng");
c1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Bungkus", "prasmanan" }));
jLabel5.setText("menu hidangan");
jLabel4.setText("Hidangan");
jLabel3.setText("Harga Nasi");
jLabel2.setText("jumlah uang");
jLabel6.setText("kembali");
ek.setText("File");
ek.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ekActionPerformed(evt);
}
});
jmkamar.setText("nama pelanggan");
jmkamar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jmkamarActionPerformed(evt);
}
});
ek.add(jmkamar);
jmdokter.setText("nomor pelanggan");
ek.add(jmdokter);
jmpasien.setText("alamat pelanggan");
ek.add(jmpasien);
jMenuBar1.add(ek);
jMenu2.setText("Laporan");
lapkamar.setText("perkantoran");
jMenu2.add(lapkamar);
lapdokter.setText("perumahan");
jMenu2.add(lapdokter);
lappasien.setText("kos-kosan");
jMenu2.add(lappasien);
jMenuBar1.add(jMenu2);
jMenu3.setText("exit");
jMenu3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jMenu3MouseClicked(evt);
}
});
jMenuBar1.add(jMenu3);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(118, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(113, 113, 113))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(j1, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(j2, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(c1, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(j3, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jCheckBox1)
.addGap(26, 26, 26)
.addComponent(jCheckBox2))))))
.addGroup(layout.createSequentialGroup()
.addGap(30, 30, 30)
.addComponent(jb1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jb2)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(j1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(j2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(c1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(22, 22, 22)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jCheckBox1)
.addComponent(jCheckBox2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(j3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(82, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jb1)
.addComponent(jb2))
.addGap(28, 28, 28))))
);
pack();
}// </editor-fold>
private void jMenu3MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
System.exit(1);
}
private void jmkamarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
uts2 ek = new uts2();
this.add(uts2);
ek.setVisible(true);
}
private void ekActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jb1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int jumlahuang = Integer.parseInt(j1.getText());
int harganasi = Integer.parseInt(j2.getText());
int kembali = jumlahuang-harganasi;
String hasil = String.valueOf(kembali);
j3.setText(hasil);
}
private void jb2MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
JOptionPane.showMessageDialog(null,"Cek uang Kembalian Anda","Terimakasih",JOptionPane.INFORMATION_MESSAGE);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(UTS1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(UTS1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(UTS1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(UTS1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new UTS1().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox c1;
private javax.swing.JMenu ek;
private javax.swing.JTextField j1;
private javax.swing.JTextField j2;
private javax.swing.JTextField j3;
private javax.swing.JCheckBox jCheckBox1;
private javax.swing.JCheckBox jCheckBox2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JButton jb1;
private javax.swing.JButton jb2;
private javax.swing.JMenuItem jmdokter;
private javax.swing.JMenuItem jmkamar;
private javax.swing.JMenuItem jmpasien;
private javax.swing.JMenuItem lapdokter;
private javax.swing.JMenuItem lapkamar;
private javax.swing.JMenuItem lappasien;
// End of variables declaration
}
0 komentar:
Posting Komentar