Input :
package uts_grafika;
import static java.awt.Color.red;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
public class Uts_grafika extends JFrame {
public Uts_grafika(){
add (new Kanvas());
}
public static void main(String[] args) {
Uts_grafika frame = new Uts_grafika ();
frame.setTitle ("Uts Grafika Komputer");
frame.setSize(500,300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible (true);
}
private static class Kanvas extends JPanel {
@Override
protected void paintComponent (Graphics g) {
super.paintComponent (g);
g.drawLine(20, 20, 150, 20);
g.drawString("A (10,10)", 20-5, 20-5);
g.drawLine(150, 20, 150, 100);
g.drawString("B", 150, 20-5);
g.drawLine(150, 100, 20, 100);
g.drawString("C", 150, 100+15);
g.drawLine(20, 100, 20, 20);
g.drawString("D (150 pixel)", 20-5, 100+15);
g.drawLine(20, 20, 60, 60);
g.drawLine(20, 100, 60, 60);
g.drawString("E (60,60)", 20+50, 60+5);
g.setColor(red);
g.drawString (" NAMA : ROBERT N. SESUN ", 180, 30);
g.drawString (" NIM : 12 11 01 71 ", 190, 50);{
}
}
}
}
Output :
package uts_grafika;
import static java.awt.Color.red;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
public class Uts_grafika extends JFrame {
public Uts_grafika(){
add (new Kanvas());
}
public static void main(String[] args) {
Uts_grafika frame = new Uts_grafika ();
frame.setTitle ("Uts Grafika Komputer");
frame.setSize(500,300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible (true);
}
private static class Kanvas extends JPanel {
@Override
protected void paintComponent (Graphics g) {
super.paintComponent (g);
g.drawLine(20, 20, 150, 20);
g.drawString("A (10,10)", 20-5, 20-5);
g.drawLine(150, 20, 150, 100);
g.drawString("B", 150, 20-5);
g.drawLine(150, 100, 20, 100);
g.drawString("C", 150, 100+15);
g.drawLine(20, 100, 20, 20);
g.drawString("D (150 pixel)", 20-5, 100+15);
g.drawLine(20, 20, 60, 60);
g.drawLine(20, 100, 60, 60);
g.drawString("E (60,60)", 20+50, 60+5);
g.setColor(red);
g.drawString (" NAMA : ROBERT N. SESUN ", 180, 30);
g.drawString (" NIM : 12 11 01 71 ", 190, 50);{
}
}
}
}
Output :
Komentar
Posting Komentar