Java Video Tutorial 49

[ad_1]
Get the Code:

In this part of my Java Video Tutorial, I continue to show you how to make a Java paint application. If you missed part 1 watch it.

I cover numerous topics including: how to draw lines, ellipses, brush strokes. I also cover how to save transparency values for shapes. And, because you requested it how to create a custom event listener and much more.

After this tutorial, you’ll be able to make an app with much of the functionality of Photoshop.


Posted

in

by

Comments

45 responses to “Java Video Tutorial 49”

  1. Huzaifa Babar Avatar

    Hi Derek.

    I've been working on developing an application in Java Swing where the user can drag, drop, recolour and resize basic shapes onto the palette. What do you think I should use as the object/variable type for the shapes?

  2. MIN HTUT MYAT Avatar

    do u have a code of how to clear(erase) what you have drawn? because i noticed that that function is missing

  3. aqua12500 Avatar

    For the brush, is there any way to increase the frequency of the ellipses being drawn? because I'm finding that if I move the mouse too quickly I end up with a bunch of dots rather than a brush stroke.

    Also, is there a way to treat each stroke as its own shape, rather than the individual ellipses? I was thinking about adding some kind of undo function but that wouldn't be clean if each ellipse had to be erased one by one.

    Thank you 🙂 you're essentially the reason I know anything at all about Java

  4. ThePopiang Avatar

    Hi Derek, I've added a save button to your paint app, but can u teach me how to make it work? I've googled, but most people draw image on bufferedimage. So i don't know how to apply that to your paint app. Thanks a million..:)

  5. tasmia arony Avatar

    thank you so much for this tutorial … its amazing .. but ive a question: how do I save this drawing ? after a lot of internet I saw a method saying bufferedImage.. but for that I have to convert the drawing into png .. how I'LL do this? help plz 🙁

  6. Brian Dela Cruz Avatar

    Sir. How do I Save a fixed canvas to Image. 🙁
    Thanks in advance! 🙂

  7. Barnard Rabenold Avatar

    The one person who hit the dislike button had to have hit it by mistake! There's no other explanation.

  8. Mike Seitz Avatar

    Thanks! This helped me so much. Basically a playlist on how to become a java god

  9. Professor Kappa Avatar

    thanks ! i love tutorials like this 🙂

  10. Dragan Milovac Avatar

    Thank You Derek! I learned a lot watching your tutorials..

  11. Joel Rogness Avatar

    What a fun tutorial – thanks!

  12. Weronika Michaluk Avatar

    Hi Derek Are you going to make tutorials about JEE ? 🙂

  13. Dimebag Darrell Avatar

    Derek, which layout for panels is usually the best to use

  14. Iago Soriano Avatar

    Derek, awesome tutorial!
    I got one question, tho: I don't understand the need for the arrays. Why store all these values in arrays and then iterate through them?
    Thanks!

  15. Jaafar Hamza Avatar

    Hi Derek! Thanks for this awesome tutorial. I have a proposition of tutorial:
     Could you please do a tutorial abut live streaming (video and audio).

  16. Gabriel Urtado Avatar

    Hi Derek! Thanks for this awesome tutorial, i have a question : how could be the method of erasing things?

  17. abdullah ahmed Avatar

    how many days do you expect a normal boy take to understand this app paint???

  18. chuckles2035 Avatar

    Have a question with this.. say I wanted to add a text tool that would type whatever the user enters on the keyboard onto the DrawingBoard…

    How difficult would that be?

  19. Derek Banas Avatar

    You could draw a square and fill it with white

  20. Michael Dean Avatar

    How do i change the background to be white when i start the program

  21. byNyoc Avatar

    when i export the project i cant see the buttons

  22. Derek Banas Avatar

    Refer to the code n my site. I'm positive there are no errors

  23. Shut up and eat! Too bad, no bon appetit! Shut up and eat! You know my love is sweet! Avatar

    That worked 🙂

    Would you be able to point me in the right direction on adding a feature for the user to draw strings onto the drawingboard?

    I would use the drawString() method, but drawingBoard doesn't use Graphics(g), and so it doesn't work. Where would i add code to perform this function?

    Please help..

  24. Derek Banas Avatar

    Delete what is stored in the ArrayLists shapes, shapeFill, shapeStroke, transPercent

  25. Shut up and eat! Too bad, no bon appetit! Shut up and eat! You know my love is sweet! Avatar

    I did try shapes.clear(). I added this under a new public function called makeClearButton (similar to what you did).
    The shapes.clear() was inside of an ActionListener, accompanied by a repaint()…
    Still couldn't get it working :'(

  26. Derek Banas Avatar

    Add a button that calls for the arraylist to be deleted, or at least its values

  27. Shut up and eat! Too bad, no bon appetit! Shut up and eat! You know my love is sweet! Avatar

    Been trying to add a button that clears the display, can't seem to figure out how though :/

  28. Derek Banas Avatar

    Copy the array that stores all of the shapes and save it to a file

  29. necroVIEL Avatar

    And also it would be interessting to save the pictures to file. what options and what file formats is java offering? Thanks Derek your work is great!

  30. necroVIEL Avatar

    Yeah, your right. To build menus is not to complicated. But how do I implement a step backward or forward action (command + Z). This would be very interessting with your Paint Progamm 🙂

  31. Derek Banas Avatar

    There is a link to all the code in the description under the video. I've checked it many times so I'm sure it will work

  32. LAAREJ AMINE Avatar

    i followed the tutorial to the letter and yet it doesn't work… i dont know why!! I need the source code

  33. LAAREJ AMINE Avatar

    where can i find the full source code of this tutoriel??

  34. al corn Avatar

    Hi Derek. I have followed all of your tutorials up until this point and have found them to the best I have found. My questions is: Box theBox = Box.createHorizontalBox(); Does this statement give theBox access to all Box classes and methods or does it just set theBox equal to a value created from the createHorizontalBox method? Also I noticed that there is not a call for the paint() method. Is this done with repaint(). If so, how? Thanks again for your help and videos.

  35. al corn Avatar

    In the statement: Box theBox = Box.createHorizontalBox(); Does this statement create a reference to a Box object or does it just return a reference to the value returned from the createHorizontalBox method? Also by using this statment would theBox have access to all methods and classes of the Box class?

  36. al corn Avatar

    Hi Derek. I noticed that there is not a call for the paint() method. Is this done with repaint(). If so, how? Thanks again for your help and videos.

  37. Derek Banas Avatar

    I don't know why I say that instead of assignment? I think many of my oddities come from the fact that I'm 100% self taught from the age of 12, while most people learned this stuff in a classroom? I'll do my best to correct that

  38. DrCrowie Avatar

    Hi Derek, these tutorials are really super great and cover a lot of stuff. I'm getting heaps out of them. I have one small gripe, is that you say "is equal to" when you are referring to the assignment operator =, I think its really important to make that distinction between the logic comparison operator == and the assignment operator =. I always say "gets" in that situation and eliminates confusion for less experienced programmers. So variable x "gets" 22, x = 22;
    Sorry to be a nitpicker!!!

  39. Derek Banas Avatar

    At the time I figured it was so easy that I'd let everybody discover it on their own. I wanted to cover all of the complicated components and then felt kind of bogged down with Swing because of all I covered already. I probably should go back and cover it. Thanks for bringing that up 🙂

  40. TheDivergable Avatar

    you also didnt cover how to make menu bars JMenu or whatever

  41. TheDivergable Avatar

    java tutorial suggestion: Make a tutorial on a text highlighter in java like eclipse it highlights your syntax etc. and test it with a simple language. That tutorial would be covering alot I guess so I think you should make it.

  42. Derek Banas Avatar

    So, you want to make a custom programming language? You could do that, but it would be a pure academic undertaking for the most part. It would be better to use a super fast language like C or assembler if you want to make a good language. All languages are very similar. They all make comparisons, loop, handle input / output, math, etc. You would just translate your language into a language that compiles. I'll think about this

  43. Derek Banas Avatar

    I'm not sure what you mean by a custom language?

  44. Derek Banas Avatar

    Thank you 🙂 I'm glad to hear that. To clear the board, create a method that deletes the stored shapes, fills, etc. in the ArrayLists. Poof! All gone

  45. Atpunk Avatar

    Derek, I kind you not when I say that I have learned more from your tutorials than I every did at school. You actually take the time to explain the terminology and how it needs to be typed amongst everything else.

    My paint app is working great. And I did figure out how to use a Slider to increase the stroke. However, how would I go about clearing the DrawingBoard?

Leave a Reply

Your email address will not be published. Required fields are marked *