Anda di halaman 1dari 2

/* * MainFrame.java * * Created on July 26, 2008, 3:14 PM */ package Latihan.Blog; import java.awt.

Color; /** * @cca */ public class MainFrame extends javax.swing.JFrame { int a =2; //pesan variable a

/** Creates new form MainFrame */ public MainFrame() { initComponents(); } //bagian ini tidak dapat di ubah /** 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. */ Generated code.. //yang terjadi ketika tombol ubah ditekan private void bGantiActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: a++; //nilai a terus bertambah satu setiap di tekan //if conditional, bagian ini mengatur warna lampu dan radio button if(a%3 == 0){ pMerah.setBackground(Color.GRAY); //set warna pHijau.setBackground(Color.GREEN); rbStop.setSelected(false); //seleksi yang tidak aktif rbGo.setSelected(true); //seleksi yang aktif } else if(a%3 == 1){ pHijau.setBackground(Color.GRAY); pJingga.setBackground(Color.ORANGE); rbGo.setSelected(false); rbHati2.setSelected(true); } else { pJingga.setBackground(Color.GRAY); pMerah.setBackground(Color.RED); rbHati2.setSelected(false); rbStop.setSelected(true); } //memasang atau mengompile objek-objek

} private void bGantiMouseEntered(java.awt.event.MouseEvent evt) { // TODO add your handling code here: setCursor(Cursor.HAND_CURSOR); //saat kursor masuk area tombol, kursor berubah bentuk } private void bGantiMouseExited(java.awt.event.MouseEvent evt) { // TODO add your handling code here: setCursor(Cursor.DEFAULT_CURSOR); //saat kursor kelua area tombol, kursor kembali seperti semula } /** * @ param args the command line arguments */