How to create object (ex:rectangle) in java by using mouse

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ragonz
    New Member
    • Jul 2008
    • 24

    #1

    How to create object (ex:rectangle) in java by using mouse

    Hy, i'm kind of new in java language.

    I want to know, how to create simple object such as rectangle by using mouse. Just like "Paint" program. Can anyone give me simple sample code for that case.

    Thx in advance..
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Originally posted by ragonz
    Hy, i'm kind of new in java language.

    I want to know, how to create simple object such as rectangle by using mouse. Just like "Paint" program. Can anyone give me simple sample code for that case.

    Thx in advance..
    Creating a rectangle wouldn't be the easiest thing to do, but you may want to have a look at this tutorial, especially the example with the Glass Pane. I'm not saying, that's what you're supposed to use, but you'll see how to react to mouse interaction with a listener - and that you will need.

    But I do want to say, if you're new to Java, creating a drawing program isn't the best thing to start with - try to write programs without graphical interfaces first (so, programs that you run in the command line) and when you have the grip of that, you can continue to using Swing for GUIs.

    Greetings,
    Nepomuk

    Comment

    • myusernotyours
      New Member
      • Nov 2007
      • 188

      #3
      Originally posted by ragonz
      Can anyone give me simple sample code for that case.

      Thx in advance..
      It's generally not good to ask for sample code on this site. It's better if you ask for help on a particular issue that you have tried out yourself. If it's sample code you want there are other places on the internet where you can find it but if you want to program, i'd say don't use sample code especially if you can't figure out what is going on.

      regards,

      Alex.

      Comment

      Working...