Postingan

Menampilkan postingan dari Desember, 2011

trimakasih Yesus

Trimakasih Tuhan untuk segala nikmat yang Engkau berikan... Aku sekarang menyadari arti segalanya itu sempurna adanya... Terimakasih Yesus, Engkau juga mengijinkan untuk merasakan segala hal yang baik,,,amin....

akhirnya

akhirnya libur ujian juga..... wuah seneng tenan aku....

tread bintang UTS

import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.awt.geom.Rectangle2D; import java.util.Random; import javax.swing.JPanel; public class Bintang extends JPanel {     private static GeneralPath gp;     int jum=1;            // draw general paths     @Override    public void paintComponent( Graphics g )    {       super.paintComponent( g ); // call superclass's paintComponent       Random random = new Random(); // get random number generator       Graphics2D g2d = ( Graphics2D ) g;             g2d.translate( 200, 200 ); // translate the origin to (200, 200)       if (jum==18)           jum=0;       // rotate around origin and draw stars in random colors       for ( int count = 1; count <= jum; count++ )       {          g2d.rotate( Math.PI / 9.0 ); // rotate coordinate system          // set random drawing color          g2d.setColor( new Color( random.nextInt( 256 ),         

shape latihan

panel shape:| import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.RoundRectangle2D; import javax.swing.JPanel; /**  *  * @author admin  */ public class ShapePanel extends JPanel {     public ShapePanel() {         setBackground(Color.white);     }     @Override     public void paintComponent(Graphics g) {         super.paintComponent(g);         g.setColor(Color.BLUE);         g.drawLine(0, 10, 50, 60);         g.setColor(Color.red);         g.drawRect(50, 10, 50, 50);         g.setColor(new Color(255, 0, 0));         g.fillOval(100, 10, 50, 50);         g.setColor(new Color(0, 255, 0));         g.fillArc(150, 10, 50, 50, 0, 180);         Graphics2D g2 = (Graphics2D) g; // fill RoundRectangle2D.Double         GradientPaint redtowhite = new GradientPaint(200, 10, Color.red, 250, 10, Color.black);         g2.setPaint(redtowhite);         g2.fill(new RoundRectangle2D.Double(200,

shape...

import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.util.Random; import javax.swing.JPanel; public class Shapes2JPanel extends JPanel {    // draw general paths     @Override    public void paintComponent( Graphics g )    {       super.paintComponent( g ); // call superclass's paintComponent       Random random = new Random(); // get random number generator //      int xPoints[] = { 55, 67, 109, 73, 83, 55, 27, 37, 1, 43 }; //      int yPoints[] = { 0, 36, 36, 54, 96, 72, 96, 54, 36, 36 }; int xPoints[] = { 60, 0, 120 };       int yPoints[] = { 0, 60, 60 };       Graphics2D g2d = ( Graphics2D ) g;       GeneralPath star = new GeneralPath(); // create GeneralPath object       // set the initial coordinate of the General Path       star.moveTo( xPoints[ 0 ], yPoints[ 0 ] );       // create the star--this does not draw the star       for ( int count = 1; count < xPoints.length; count++

ujian - ujian

uuuuuuuuuuuuuuujjjjjjjjjjjjjjjjjjjiiiiiiiiiiiiiiiiiiiiiaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnn

shape panel

package pertemuan13_pbo; import java.awt.BorderLayout; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.geom.RoundRectangle2D; import javax.swing.JFrame; import javax.swing.JPanel; /**  *  * @author admin  */ public class ShapePanel extends JPanel {     public ShapePanel() {         setBackground(Color.white);     }     @Override     public void paintComponent(Graphics g) {         super.paintComponent(g);         g.setColor(Color.BLUE);         g.drawLine(0, 10, 50, 60);         g.setColor(Color.red);         g.drawRect(50, 10, 50, 50);         g.setColor(new Color(255, 0, 0));         g.fillOval(100, 10, 50, 50);         g.setColor(new Color(0, 255, 0));         g.fillArc(150, 10, 50, 50, 0, 180);         Graphics2D g2 = (Graphics2D) g; // fill RoundRectangle2D.Double         GradientPaint redtowhite = n

exception integer

package exception; import javax.swing.JOptionPane; public class interger {     public int bagi(int pembilang, int penyebut) {         int hasilBagi;         try {             if (penyebut < 0) {                 throw new Exception("\n pembilang tidak sama dengan 0");             } else if (penyebut == 0) {                 throw new Exception("\n anda salah penyebut");             }         }         catch (Exception ex) {             JOptionPane.showMessageDialog(null,                     "ERROR " + ex.getMessage());         }                hasilBagi = pembilang / penyebut;        return  hasilBagi;     } } class Main {     public static void main(String[] args) throws Exception {         interger bilangan = new interger();         int pembilang = Integer.parseInt(JOptionPane.showInputDialog("Masukkan pembilang :"));         int penyebut = Integer.parseInt(JOptionPane.showInputDialog("Masukkan penyebut :&q

exception perpustakaan

package perpustakaan2; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import javax.swing.JOptionPane; /**  *  * @author admin  */ public class Id implements Comparable{     private String idkolek;     private String judul;     private int tahun;     private String penerbit;     private Date tglPinjam;     private Date tglKembali;     public long denda;     public int waktuPinjam;     // untuk mendapatkan nilai dari main     public String getIdkolek() {         return idkolek;     }     // untuk mendapatkan nilai dari main     public String getJudul() {         return judul;     }     // untuk mendapatkan nilai tahun     public int getTahun() {         return tahun;     }     // untuk mendapatkan nilai penerbit     public String getPenerbit() {         return penerbit;     }     /**      * untuk mengembalikan nilai id koleksi      * @param idkolek the idkolek to set    

memasukkan image pada panel

public class ImagePanel extends JPanel {     private BufferedImage logo;     /** Creates a new instance of ImagePanel */     public ImagePanel() {         try {             // buka file             File img = new File("gambar/Winter.jpg");             // baca image             logo = ImageIO.read(img);             //img.close();         } catch (IOException ex) {             ex.printStackTrace();         }     }     @Override     public void paintComponent(Graphics g) {         g.drawImage(logo,0, 0, 400, 300,                 0, 0, logo.getWidth(null), logo.getHeight(null),                 null);     }     public static void main(String args[]) {         JFrame frame = new JFrame("Using Java2D");         frame.setLayout(new BorderLayout());         ImagePanel gc = new ImagePanel();         frame.add(gc, BorderLayout.CENTER);         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         frame.setSize(600, 250);         frame.set

bikin bentuk bentuk graphic

import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import javax.swing.*; public class DrawingArc extends JPanel {     public DrawingArc() {         this.setBackground(Color.CYAN);     }     @Override     public void paintComponent(Graphics g) {         super.paintComponent(g);         g.setColor(Color.PINK);         g.fillArc(40, 40, 100, 100, 45, 180);         g.setFont(new Font("SansSerif", Font.BOLD, 12));         g.setColor(Color.BLACK);         g.drawString("ini adalah arc", 50, 65);         Graphics2D g2 = (Graphics2D) g;         g2.setPaint(Color.BLUE);         g2.setStroke(new BasicStroke(11.0f));         g2.drawOval(180, 70, 70, 100);         BufferedImage buffImage = new BufferedImage(10, 10,                 BufferedImage.TYPE_INT_RGB);         g2.setPaint(new TexturePaint(buffImage, new Rectangle(10, 10)));         Graphics2D g3 = buffImage.createGra

circle

public class CirclePanel extends JPanel {     //* Deklarasi atribut     private int number;         //* Constructor     public CirclePanel()     {             }         //* Method accessor dan mutator untuk mengubah nilai atribut     public void setNumber(int number)     {         this.number=number;     }         public int getNumber()     {         return number;     }         //* Method untuk membuat lingkaran, dengan instruksi bersyarat     @Override     public void paintComponent(Graphics graph)     {         super.paintComponent(graph);         if(number%2==0)             graph.setColor(Color.GREEN);         else             graph.setColor(Color.WHITE);                     graph.fillOval(20,10,200,200);     } } public class CircleCounter extends Thread {     //* Deklarasi atribut     private JTextField textField;     private JButton starStop;     Thread thread;     private boolean counter = false;     private int number = 0;     CircleP

counter

public class Counter implements Runnable {     JLabel outputLabel;     private int value;     Thread thread;     private boolean start = true;     /** Creates a new instance of Counter */     public Counter() {         setValue(0);     }     /** Creates a new instance of Counter */     public Counter(JLabel output) {         outputLabel = output;         setValue(0);         thread = new Thread(this);         thread.start();     }     public void run() {         while (isStart()) {             outputLabel.setText("Counter: " + getValue());             try {                 thread.sleep(500);                 setValue(getValue() + 1);             } catch (InterruptedException ex) {                 ex.printStackTrace();             }         }     }     public boolean isStart() {         return start;     }     public void setStart(boolean start) {         this.start = start;     }     public int getValue() {         return value;     }

Bikin Random Gui

public class RandomCounter_Test {     public static void main(String [] args)     {         //* Menjalankan fungsi thread dari kelas RandomCounterGUI dan menampilkannya         RandomCounterGUI test=new RandomCounterGUI();         test.setVisible(true);     } } import javax.swing.*; import java.awt.*; import java.awt.event.*; public class RandomCounterGUI extends JFrame {     //* Dekarasi atribut     private JTextField textfield;     private JButton startStopButton;     private JPanel mainPanel;     boolean start=true;     RandomCounter counter;         public RandomCounterGUI()     {         //* Mengatur semua tentang frame         this.setLocation(100,100);         this.setSize(200,100);         this.setLayout(new BorderLayout());         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         this.setTitle("Random Counter");                 //* Mengatur panel beserta komponen di dalamnya         mainPanel=new JPanel();         mainPan

materi bintang - bintang

import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.GeneralPath; import java.util.Random; import javax.swing.JPanel; public class Bintang extends JPanel {     private static GeneralPath gp;     int jum=1;            // draw general paths    public void paintComponent( Graphics g )    {       super.paintComponent( g ); // call superclass's paintComponent       Random random = new Random(); // get random number generator       Graphics2D g2d = ( Graphics2D ) g;             g2d.translate( 200, 200 ); // translate the origin to (200, 200)       if (jum==18)           jum=0;       // rotate around origin and draw stars in random colors       for ( int count = 1; count <= jum; count++ )       {          g2d.rotate( Math.PI / 9.0 ); // rotate coordinate system          // set random drawing color          g2d.setColor( new Color( random.nextInt( 256 ),             random.nextInt( 256 ), random.nextInt( 256 ) )

panel - panel

public class TestNo3 {     public static void main(String[] args) {         No3 tiga = new No3();         tiga.setVisible(true);     } } import java.awt.Container; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; /**  *  * @author admin  */     public class No3 extends JFrame implements ActionListener {     private static final int FRAME_WIDTH = 1000;     private static final int FRAME_HEIGHT = 800;     private static final int FRAME_X_ORIGIN = 150;     private static final int FRAME_Y_ORIGIN = 250;     private JMenu utama1;     private JMenu utama2;     private String nm2,pass2;     private JMenuItem psswd, exit;     private JButton okButton;    

exception handling

public class TestKaryawan {     public static void main(String[] args) {         Karyawan k = new Karyawan();                     int tgl = Integer.parseInt(JOptionPane.showInputDialog("masukkan tanggal lahir: "));             k.setTglLahir(tgl);             int bln = Integer.parseInt(JOptionPane.showInputDialog("masukkan bulan lahir :"));             k.setBlnLahir(bln);             int thn = Integer.parseInt(JOptionPane.showInputDialog("masukkan tahun lahir:"));             k.setThnLahir(thn);     } } import javax.swing.JOptionPane; /**  *  * @author admin  */ public class Karyawan { private String nama; private int tglLahir; private int blnLahir; private int thnLahir;     public Karyawan(){     }     /**      * @return the nama      */     public String getNama() {         return nama;     }     /**      * @param nama the nama to set      */     public void setNama(String nama) {         this.nama = nama;    

JPanel

import java.awt.Container; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JTextField; /**  *  * @author admin  */ public class MainNo1 extends JFrame {     private static final int FRAME_WIDTH = 500;     private static final int FRAME_HEIGHT = 400;     private static final int FRAME_X_ORIGIN = 150;     private static final int FRAME_Y_ORIGIN = 250;     private JMenu utama1;     private JMenu utama2;     private JMenuItem utama1a, utama1b, utama1c;     private JButton okButton;     private static final int BUTTON_WIDTH = 80;     private static final int BUTTON_HEIGHT = 30;     public MainNo1() {         setTitle("UTS Satu");         setSize(FRAME_WIDTH, FRAME_HEIGHT);         setResizable(false);         setLocation(FRAME_X_ORIGIN, FRAME_Y_ORIGIN);