0% found this document useful (0 votes)
27 views3 pages

Import: Clase Primaria

This document contains code for a Java program that draws various shapes on a frame window. It defines two classes - one called d that contains the main method to set up and display the frame, and another called di that extends JFrame and overrides the paint method. The paint method draws different colored rectangles, lines, and ovals to create a complex diagram on the frame using Graphics methods.

Uploaded by

Ivan Posadas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Import: Clase Primaria

This document contains code for a Java program that draws various shapes on a frame window. It defines two classes - one called d that contains the main method to set up and display the frame, and another called di that extends JFrame and overrides the paint method. The paint method draws different colored rectangles, lines, and ovals to create a complex diagram on the frame using Graphics methods.

Uploaded by

Ivan Posadas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Clase Primaria

import javax.swing.JFrame;

public class d {

public static void main(String[] args) {


di g= new di();
g.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
g.setSize(600, 600);
g.setVisible(true);
g.setLocationRelativeTo(null);

}
Clase Secundaria
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
public class di extends JFrame{
public di() {
super ("dibujo");
}
@Override
public void paint (Graphics g){
super.paint(g);
this.setBackground(Color.RED);

g.setColor(Color.ORANGE);
g.drawRect(150, 150, 150, 150);
g.drawRect(200,300, 180, 20);
g.drawRect(250,70, 35, 80);
g.drawRect(170, 150, 100, 150);
g.drawRect(300, 150, 70, 150);
g.drawRect(370, 50, 180,100);
g.drawRect(400,80, 100,50);
g.setColor(Color.BLUE);
g.drawLine(284,80, 250,80);
g.drawLine(90, 360, 150,300);
g.drawLine(200,361,90,361);
g.drawLine(200,350,100,350);
g.drawLine(200,360, 200,300);
g.drawLine(370,150, 470,150);
g.drawLine(550,150, 550,190);
g.drawLine(10,370, 600,370);
g.drawLine(550,70, 370,70);
g.drawLine(450,80, 450,128);
g.setColor(Color.DARK_GRAY);
g.drawOval(200, 320,50, 50);
g.drawOval(260, 320,50, 50);
g.drawOval(325, 320,50, 50);
g.drawOval(370, 150,200, 220);
g.drawOval(380, 160,180, 200);
g.drawOval(440, 240,50, 50);
}
}

You might also like