Senin, 17 Juni 2013

PROJECT PBO

Tugas PBO

Rachmat Hidayat (55411706)
Ajeng Aqmarina Jan (50411486)
Lutfi Noviyanti Utami (54411168)

Ada 2 file:

BlurButton.java

import java.awt.image.Kernel;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.ConvolveOp;
import javax.swing.JButton;

@SuppressWarnings("serial")
public class BlurButton extends JButton
{
public BlurButton(String txt)
{
super(txt);
}
public void paintComponent(Graphics graph)
{
if(isEnabled())
{
super.paintComponent(graph);
return;
}
BufferedImage bi = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
super.paintComponent(bi.getGraphics());
float kernel[] = {0.10f,0.10f,0.10f,
0.10f,0.20f,0.10f,
0.10f,0.10f,0.10f
};
ConvolveOp cop = new ConvolveOp(new Kernel(3, 3, kernel));
Image img = cop.filter(bi, null);
graph.drawImage(img,0,0,null);
}
}


frameButton.java

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.ImageIcon;
import java.awt.Color;

@SuppressWarnings("serial")
public class frameButton extends JFrame
{

private JPanel contentPane;
private JButton btnRefresh;
final JButton btnBlur = new BlurButton("Simpan Blur");
private JTextField txtNPM;
private JTextField txtNama;
private JTextArea textAlamat;
private JTextField txtPhone;
private JLabel lblBg;
private JLabel lblIcon;

public frameButton()
{
super("Program Identitas");
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 528, 398);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
btnRefresh = new JButton("Refresh");
btnRefresh.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent act)
{
btnBlur.setEnabled(isEnabled());
txtNPM.setText("");
txtNama.setText("");
textAlamat.setText("");
txtPhone.setText("");
txtNPM.requestFocus();
}
});
btnRefresh.setBounds(247, 259, 132, 44);
contentPane.add(btnRefresh);
btnBlur.setText("Tampilkan");
btnBlur.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
btnBlur.setEnabled(!btnBlur.isEnabled());
String npm = txtNPM.getText();
String nama = txtNama.getText();
String alamat = textAlamat.getText();
String phone = txtPhone.getText();
JOptionPane.showMessageDialog(null,"NPM : " + npm + "\n" + "Nama : " + nama + "\n" + "Alamat : " + alamat + "\n" + "Phone : " + phone,"Pesan",JOptionPane.INFORMATION_MESSAGE,new ImageIcon("src/Gambar/Pesan.png"));
}
});
btnBlur.setBounds(64, 259,155,44);
contentPane.add(btnBlur);
JLabel lblNpm = new JLabel("NPM : ");
lblNpm.setForeground(new Color(55, 55, 55));
lblNpm.setBounds(12, 12, 70, 15);
contentPane.add(lblNpm);
JLabel lblNama = new JLabel("Nama : ");
lblNama.setForeground(new Color(55, 55, 55));
lblNama.setBounds(12, 59, 70, 15);
contentPane.add(lblNama);
JLabel lblAlamat = new JLabel("Alamat : ");
lblAlamat.setForeground(new Color(55, 55, 55));
lblAlamat.setBounds(12, 103, 70, 15);
contentPane.add(lblAlamat);
JLabel lblPhone = new JLabel("Phone : ");
lblPhone.setForeground(new Color(55, 55, 55));
lblPhone.setBounds(12, 210, 70, 15);
contentPane.add(lblPhone);
txtNPM = new JTextField();
txtNPM.setBounds(82, 10, 155, 26);
contentPane.add(txtNPM);
txtNPM.setColumns(10);
txtNama = new JTextField();
txtNama.setBounds(82, 57, 269, 26);
contentPane.add(txtNama);
txtNama.setColumns(10);
textAlamat = new JTextArea();
textAlamat.setBounds(82, 103, 269, 95);
contentPane.add(textAlamat);
txtPhone = new JTextField();
txtPhone.setBounds(82, 210, 155, 26);
contentPane.add(txtPhone);
txtPhone.setColumns(10);
lblIcon = new JLabel("");
lblIcon.setBounds(369, 59, 132, 122);
contentPane.add(lblIcon);
lblBg = new JLabel("");
lblBg.setBounds(0, 0, 526, 371);
contentPane.add(lblBg);
setLocationRelativeTo(null);
}
/**
* Launch the application.
*/
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
frameButton frame = new frameButton();
frame.setVisible(true);
}
catch (Exception e)
{
e.printStackTrace();
}
}
});
}
}

Output Program

0 komentar:

Posting Komentar

Senin, 17 Juni 2013

PROJECT PBO

Tugas PBO

Rachmat Hidayat (55411706)
Ajeng Aqmarina Jan (50411486)
Lutfi Noviyanti Utami (54411168)

Ada 2 file:

BlurButton.java

import java.awt.image.Kernel;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.ConvolveOp;
import javax.swing.JButton;

@SuppressWarnings("serial")
public class BlurButton extends JButton
{
public BlurButton(String txt)
{
super(txt);
}
public void paintComponent(Graphics graph)
{
if(isEnabled())
{
super.paintComponent(graph);
return;
}
BufferedImage bi = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
super.paintComponent(bi.getGraphics());
float kernel[] = {0.10f,0.10f,0.10f,
0.10f,0.20f,0.10f,
0.10f,0.10f,0.10f
};
ConvolveOp cop = new ConvolveOp(new Kernel(3, 3, kernel));
Image img = cop.filter(bi, null);
graph.drawImage(img,0,0,null);
}
}


frameButton.java

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.ImageIcon;
import java.awt.Color;

@SuppressWarnings("serial")
public class frameButton extends JFrame
{

private JPanel contentPane;
private JButton btnRefresh;
final JButton btnBlur = new BlurButton("Simpan Blur");
private JTextField txtNPM;
private JTextField txtNama;
private JTextArea textAlamat;
private JTextField txtPhone;
private JLabel lblBg;
private JLabel lblIcon;

public frameButton()
{
super("Program Identitas");
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 528, 398);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
btnRefresh = new JButton("Refresh");
btnRefresh.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent act)
{
btnBlur.setEnabled(isEnabled());
txtNPM.setText("");
txtNama.setText("");
textAlamat.setText("");
txtPhone.setText("");
txtNPM.requestFocus();
}
});
btnRefresh.setBounds(247, 259, 132, 44);
contentPane.add(btnRefresh);
btnBlur.setText("Tampilkan");
btnBlur.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
btnBlur.setEnabled(!btnBlur.isEnabled());
String npm = txtNPM.getText();
String nama = txtNama.getText();
String alamat = textAlamat.getText();
String phone = txtPhone.getText();
JOptionPane.showMessageDialog(null,"NPM : " + npm + "\n" + "Nama : " + nama + "\n" + "Alamat : " + alamat + "\n" + "Phone : " + phone,"Pesan",JOptionPane.INFORMATION_MESSAGE,new ImageIcon("src/Gambar/Pesan.png"));
}
});
btnBlur.setBounds(64, 259,155,44);
contentPane.add(btnBlur);
JLabel lblNpm = new JLabel("NPM : ");
lblNpm.setForeground(new Color(55, 55, 55));
lblNpm.setBounds(12, 12, 70, 15);
contentPane.add(lblNpm);
JLabel lblNama = new JLabel("Nama : ");
lblNama.setForeground(new Color(55, 55, 55));
lblNama.setBounds(12, 59, 70, 15);
contentPane.add(lblNama);
JLabel lblAlamat = new JLabel("Alamat : ");
lblAlamat.setForeground(new Color(55, 55, 55));
lblAlamat.setBounds(12, 103, 70, 15);
contentPane.add(lblAlamat);
JLabel lblPhone = new JLabel("Phone : ");
lblPhone.setForeground(new Color(55, 55, 55));
lblPhone.setBounds(12, 210, 70, 15);
contentPane.add(lblPhone);
txtNPM = new JTextField();
txtNPM.setBounds(82, 10, 155, 26);
contentPane.add(txtNPM);
txtNPM.setColumns(10);
txtNama = new JTextField();
txtNama.setBounds(82, 57, 269, 26);
contentPane.add(txtNama);
txtNama.setColumns(10);
textAlamat = new JTextArea();
textAlamat.setBounds(82, 103, 269, 95);
contentPane.add(textAlamat);
txtPhone = new JTextField();
txtPhone.setBounds(82, 210, 155, 26);
contentPane.add(txtPhone);
txtPhone.setColumns(10);
lblIcon = new JLabel("");
lblIcon.setBounds(369, 59, 132, 122);
contentPane.add(lblIcon);
lblBg = new JLabel("");
lblBg.setBounds(0, 0, 526, 371);
contentPane.add(lblBg);
setLocationRelativeTo(null);
}
/**
* Launch the application.
*/
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable()
{
public void run()
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
frameButton frame = new frameButton();
frame.setVisible(true);
}
catch (Exception e)
{
e.printStackTrace();
}
}
});
}
}

Output Program

Tidak ada komentar:

Posting Komentar