Postingan

Menampilkan postingan dari Desember 21, 2011

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, 5...

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.showMes...

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;     }   ...

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 paintCompone...

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;     ...

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)     {         ...

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()); ...

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    ...

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 ...

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 s...

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; /** ...

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(...