Ejer 03
Ejer 03
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">
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
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>
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);
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);
}
}