How to Draw Lines on the Screen (Part 2)

Posted by Geertjan on Oracle Blogs See other posts from Oracle Blogs or by Geertjan
Published on Wed, 12 Sep 2012 16:28:32 +0000 Indexed on 2012/09/12 21:45 UTC
Read the original article Hit count: 164

Filed under:

In part 1, I showed how you can click on the screen to create widgets and then connect those widgets together. But that's not really drawing, is it? (And I'm surprised nobody made that point in the comments to that blog entry.)

Drawing doesn't really revolve around connecting dots together. It's more about using a free-flow style and being able to randomly write stuff onto a screen, without constraints. Something like this:

I achieved the above by changing one line of code from the original referred to above. Instead of using a "mousePressed" event, I'm now using a "mouseDragged" event. That's all. And now the widgets are created when I drag my mouse on the scene. (I removed the rectangular select action, since that's also invoked during dragging and since that doesn't apply to the above scenario.)

Now, the next step is to rewrite the NetBeans Platform Paint Application Tutorial, so that the Visual Library is used. That would be pretty cool.

© Oracle Blogs or respective owner

Related posts about /NetBeans IDE