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

Ejer 03

The document describes a Java class for drawing different shapes on a window or frame. The class initializes the frame, defines methods for drawing shapes with different colors and fills, and overrides the paint method to render the shapes.

Uploaded by

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

Ejer 03

The document describes a Java class for drawing different shapes on a window or frame. The class initializes the frame, defines methods for drawing shapes with different colors and fills, and overrides the paint method to render the shapes.

Uploaded by

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

/*

* PATRONES DE DISEÑO DE SOFTWARE Y ARQUITECTURA - A - Semana 07


*/
package ventana;

import java.awt.Color;
import java.awt.Graphics;

/**
*
* @Autor: Carlos Alberto Chirinos Mundaca
*/
public class Formas extends javax.swing.JFrame {

/**
* Creación de Nuevo Formulario de Formas
*/
public Formas() { /* Nombre del Formulario - función Formas() */
initComponents();
this.setBounds(0, 0, 600, 400); /* 600 de Ancho y 400 de Alto */
this.setLocationRelativeTo(null);
}

/**
* Se llama a este método (PATRÓN) desde el constructor para inicializar el
formulario.
* ADVERTENCIA: NO modifique este código.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

javax.swing.GroupLayout layout = new


javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);

pack();
}// </editor-fold>

/**
* @param args los argumentos de la línea de comandos
*/
public static void main(String args[]) {
/* Ajuste el aspecto y la sensación de Nimbus */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the
default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(Formas.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(Formas.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(Formas.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(Formas.class.getName()).log(java.util.logging.Le
vel.SEVERE, null, ex);
}
//</editor-fold>

/* Crear y mostrar el formulario */


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Formas().setVisible(true); /*con false no se aprecia el
formulario*/
}
});
}

// Variables declaration - do not modify


// End of variables declaration

public void paint(Graphics g){


super.paint(g);

g.setColor(Color.BLUE);
g.drawLine(0, 70, 100, 70);
g.drawRect(150, 70, 50, 70);
g.drawRoundRect(250, 70, 50, 70, 6, 6);
g.drawOval(350, 70, 50, 70);

int vectorX [] = {500, 550, 450};


int vectory [] = {70, 120, 120};
g.drawPolygon(vectorX, vectory, 3);

g.setColor(Color.GREEN);
g.fillRect(150, 270, 50, 70);
g.fillRoundRect(250, 270, 50, 70, 6, 6);
g.fillOval(350, 270, 50, 70);
int[] vectorx2 = {500, 550, 450};
int[] vectory2 = {270, 320, 320};
g.fillPolygon(vectorx2, vectory2, 3);

}
}

You might also like