Source Code No.3 - UAS Komgraf [AJIT PRASETIYO]

                Never    
Java
       
package programs;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class PA_UAS3 extends JPanel{
    public PA_UAS3(){
        this.setPreferredSize(new Dimension(350, 250));
        this.setBackground(Color.darkGray);
    }
    protected void paintComponent(Graphics g){
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        Polygon rect = new Polygon();
        
        rect.addPoint(10,10);
        rect.addPoint(150,10);
        rect.addPoint(150,110);
        rect.addPoint(30,110);
        rect.addPoint(10,145);
        rect.addPoint(20,110);
        rect.addPoint(10,110);
        
        g2.setColor(Color.yellow);
        g2.fill(rect);
        g2.setColor(Color.black);
        g2.drawString ("UAS 3 - Komgraf",35,65);
        g2.draw(rect);
    }
    public static void main(String [] args){
        JFrame frame = new JFrame("UAS.3 - KOMGRAF 1");
        frame.addWindowListener(new WindowAdapter (){
            public void windowClosing(WindowEvent e){System.exit(0);}
        });
        PA_UAS3 c = new PA_UAS3();
        frame.getContentPane();
        frame.add(c);
        frame.pack();
        frame.setVisible(true);
    }
}

Raw Text