Foro de elhacker.net

Programación => Java => Mensaje iniciado por: MARYPRINCE en 8 Octubre 2010, 01:25 am



Título: POR FAVOR UN PAINT EN JAVA(NETBEAN)
Publicado por: MARYPRINCE en 8 Octubre 2010, 01:25 am
ES QUE NECESITO UNA FORMA DE PAINT EN JAVA QUE TE DIBUJE MUY SENCILLO UN CIRCULO, RECTANGULO CUADRADO, FIGURAS GEOMETRICAS CON EL METODO
Graphics g=getGraphics()  POR FAVOR AYUDA


Título: Re: POR FAVOR UN PAINT EN JAVA(NETBEAN)
Publicado por: Ariath en 8 Octubre 2010, 01:32 am
¿Tu te has pasado a mirar tan solo la documentación de Java para la clase Graphics?

http://download.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html

Código
  1. abstract  void  drawOval(int x, int y, int width, int height)
  2. abstract  void  drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
  3.          void  drawPolygon(Polygon p)
  4. abstract  void  drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
  5.          void  drawRect(int x, int y, int width, int height)
  6. abstract  void  drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
  7.  

Y no escribas en mayúsculas, implica grito.

Salu2


Título: Re: POR FAVOR UN PAINT EN JAVA(NETBEAN)
Publicado por: Leyer en 8 Octubre 2010, 02:04 am
Un circulo

Código
  1. g.fillOval(0, 0, 240, 240);

Un Cuadrado

Código
  1. g.fillRect(220, 60, 120, 120);

Un triangulo
Código
  1. g.drawLine(320, 100, 320+(130/2), 100+230);
  2. g.drawLine(320+(130/2), 100+230, 320-(130/2), 100+230);
  3. g.drawLine(320,100,320-(130/2), 100+230);

Un rectángulo
Código
  1. g.drawRect( 100,100,300,200 );

Coloca un MouseListener a frame y obtienes las coordenadas x , y y luego pintas.

Aquí tienes un applet con su respectivo fuente
:http://www.chuidiang.com/java/codigo_descargable/appletpaint.php

Un saludo.


Título: Re: POR FAVOR UN PAINT EN JAVA(NETBEAN)
Publicado por: Ariath en 8 Octubre 2010, 17:17 pm
@MARYPRINCE: Y principalmente porque he leído el mensaje que pusiste, que veo que ya borraron.

Te puse no solo el enlace hacia la documentación (que te podría haber dado simplemente eso, porque no es difícil encontrar los métodos ni mucho menos), sino además los métodos que tienes disponibles para hacer lo que buscas.

Otra cosa es que busques a alguien que te construya directamente el paint, y en el foro se ha dicho en muchas ocasiones que no se hacen tareas (porque esto huele a una).

Salu2


Título: Re: POR FAVOR UN PAINT EN JAVA(NETBEAN)
Publicado por: Debci en 8 Octubre 2010, 19:58 pm
A pesar de que lo han hecho, tienes que saber que esta prohibido pedir tareas...
No todo el mundo es tan bueno como los que te han ayudado.

Saludos