Results 1 to 6 of 6
  1. #1
    Madhan is offline Member
    Join Date
    May 2014
    Posts
    2
    Rep Power
    0

    Default draw Geometry Shapes

    Hai...

    can someone help me to draw geometry shapes(line,circle) inside a textarea.


    Thanks.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: draw Geometry Shapes

    textareas are for text. What kind of text characters do you want to use to make a shape?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,376
    Rep Power
    5

    Default Re: draw Geometry Shapes

    The easiest way I know of drawing shapes using text is to setup an n x m (e.g. 100 x 100) character array and then treat each element in the array
    as a large "pixel." Then just use the formulas for circles, etc to generate the coordinates and fill in the appropriate element. Then print out the array.
    Of course, this would all be relatively trivial to do in a real Graphics context.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: draw Geometry Shapes

    Quote Originally Posted by jim829 View Post
    The easiest way I know of drawing shapes using text is to setup an n x m (e.g. 100 x 100) character array and then treat each element in the array
    as a large "pixel." Then just use the formulas for circles, etc to generate the coordinates and fill in the appropriate element. Then print out the array.
    Of course, this would all be relatively trivial to do in a real Graphics context.
    Hogwash; real men (like me) override the paintComponent( ... ) method of a JTextArea and happily draw whatever we want ...

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,376
    Rep Power
    5

    Default Re: draw Geometry Shapes

    Quote Originally Posted by JosAH View Post
    Hogwash; real men (like me) override the paintComponent( ... ) method of a JTextArea and happily draw whatever we want ...

    kind regards,

    Jos ;-)

    You know, there are still lots of things I don't know about Java (or even consider doing). But that worked perfectly.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: draw Geometry Shapes

    Quote Originally Posted by jim829 View Post
    You know, there are still lots of things I don't know about Java (or even consider doing). But that worked perfectly.
    Of course it does; did you ever see me talking nonsense here? ;-) A JTextArea is just a JComponent (that manages and draws text) and (of course) its paintComponent( ... ) method can be redefined in a child class.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. please help me draw these shapes
    By sozoki in forum New To Java
    Replies: 0
    Last Post: 12-08-2013, 05:00 PM
  2. java.awt.geometry - Rotating anImage with AffineTransform
    By natdizzle in forum Advanced Java
    Replies: 1
    Last Post: 02-17-2012, 11:21 PM
  3. Button click for drawing geometry shape
    By nnur in forum AWT / Swing
    Replies: 5
    Last Post: 05-15-2010, 07:48 PM
  4. Draw shapes by pressing a button
    By SWEngineer in forum AWT / Swing
    Replies: 16
    Last Post: 05-14-2010, 05:26 AM
  5. Efficient Looping to Draw Shapes
    By clam in forum New To Java
    Replies: 18
    Last Post: 10-31-2009, 04:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •