Beranda > Java Tutorial, Sinaung > Image Processing dengan Java

Image Processing dengan Java


Image processing with java

// berikut ini adalah program untuk menampilkan gambar atau sering disebut image processing // menggunakan java. dengan menggunakan GUI unuk mempercantik panampilan.
// by rawza… for yutta…
//
 import javax.swing.*;
 import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class grafikImage extends JComponent implements ActionListener {
private String nmFile;
private JButton b_open;
private JFileChooser openFile_dialog; private JLabel label;
public grafikImage() {
 nmFile=””;
openFile_dialog = new JFileChooser();
setLayout(new FlowLayout(FlowLayout.LEFT));
b_open = new JButton(“Buka”);
label = new JLabel(“”,JLabel.CENTER);
add(b_open); add(label);
b_open.addActionListener(this);
}
public void paintComponent(Graphics g) {
Image gambar = Toolkit.getDefaultToolkit().getImage(nmFile);
 g.drawImage(gambar,5,35,this);
}
public void actionPerformed(ActionEvent aksi) {
if(aksi.getSource()==b_open) {
int hasil = openFile_dialog.showOpenDialog(this);
 if(hasil==JFileChooser.APPROVE_OPTION) {
 nmFile=openFile_dialog.getSelectedFile().toString();
 label.setText(nmFile); repaint();
} } }
 public static void main (String[] args) {
JFrame form = new JFrame(“COntoh ambil gambar”);
//form.setLayout(null); form.setDefaultLookAndFeelDecorated(true);
 form.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
form.getContentPane().add(new grafikImage());
form.setBounds(0,0,600,600);
form.setLocationRelativeTo(null);
form.setVisible(true);
} }
  1. Belum ada komentar.
  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: