X

Geertjan's Blog

  • September 12, 2012

How to Draw Lines on the Screen (Part 2)

Geertjan Wielenga
Product Manager

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.

Join the discussion

Comments ( 3 )
  • Toni Epple Thursday, September 13, 2012

    I don't think Visual Library would be a great choice for creating a paint application. You'll end up with a lot of Widgets, and Java2D is much better for creating bitmaps. Maybe Vislib could be used in combination with it for providing tools though. E.g. you could easily create a selection rectangle, or an eraser you can move to manipulate the background.

    Thanks for your recent blog posts about vislib. Lot's of useful code snippets :-)!


  • Javier Ortiz Thursday, September 13, 2012

    That would be great! I should provide the examples I need!


  • guest Sunday, September 16, 2012

    I am fascinated by your "mouse dragging" technique to create more realistic screen writing. I thought that 'net' and 'beans' were both created in widget format; obviously, my untrained eye! Which one is done by dragging? Or am I being naive enough to not even know how to ask the question? LOL or not! :)K


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha