This tutorial is going to be a ton of fun. Today I’ll show you how to Make a Java Paint Application!
One of you guys asked me to do this and it gives me a great opportunity to review and cover new topics all at once. Somethings I cover that you may want to brush up on include using the Java Box Layout, Java ArrayList, and Java Graphics2D.
All of the code follows the video and it is heavily commented. If you have questions, feel free to ask. Everything used is here Zipped Archive
If you like this video, tell Google please [googleplusone]
Sharing is always appreciated [nttfblike]
Code from the Video
wowwwwwww, it’s awesome..
please make something for collision detection as well.
I’ll cover that very soon. I’m glad you liked this one. It was fun to make π
Thanks alot for the amazing tutorial. I have studiet it around 3 times. I want to be able to create it with out looking att your code π
You’re very welcome π Practicing and experimenting with your own ideas is the best way to go. If you learn to program out of your head, you’ll be able to make anything you can imagine
Great tutorial!
I am learning Design Patterns and I noticed that those kind of software is the best way to learn how to use Design Patterns.
Can you please make a case study video tutorial of a paint application by using Design Patterns ?
I think it will help newbies like me, how to apply OOAD and Design Patterns in real world projects.
Thanks in advance.
Thank you π I am still working with Object Oriented Design in my current tutorial. I will cover more before it is over. I also will be covering design patterns further in my next tutorial on refactoring. I hope that helps
It will be very helpful, thank you very much !
All the time when I made a mouseListener and checked(with the simple System.out.println method) whether the repaint method worked when I release the mouse or not I got no result.
I put the System.out.println method in the paint(Graphics g) method, but it still doesn’t print something in the console when I repaint.
Do you have any idea what probably may have gone wrong?
Btw thanks for the time you spent with helping people! I appreciate it!
You are very welcome π Did you copy the code directly from my website? Are you getting any error messages? I’ll do my best to help
I only have used a part of your code but I tried to change it a little bit and play with it.
private class drawStuff extends JComponent
{
public void paint(Graphics g)
{
Graphics2D graph2 = (Graphics2D)g;
textArea.append(“PAINTING COMPONENT!\n”);
}
}
“
I tried to repaint it in the timer that I used, a schoolmate told me that I should use paintComponent. He didn’t even know that there is just a paint method.
I do not understand cause when I run the program, the paint method is called. (3 times; βPAINTING COMPONENT!\nβ appears) And it still does when I delete the repaint method and then run it again. The repaint method makes no difference…
The timer;
//Timer
new Timer((1000 / 60), new ActionListener() {
public void actionPerformed(ActionEvent e) {
repaint();
}
}).start();
I’m still very glad there’s someone who want to help me(on the web)!
Just made another version that works. I showed my friend who’s good at programming, but even he couldnt find a solution. We created a new file. I’m glad it now works.
And again; Thanks for your tutorials!
You are very welcome π You will learn a great deal by taking my code and expanding on the possibilities.
Can I use this code for my assigment what do I need to change in this code to make it my own ?
You can do anything you’d like with the code. I don’t require anything. If you can figure out a way to sell it, go for it π
hey! thank you very much it’s really helpful to me to design more stuffs using this…
You’re very welcome π
I didn’t about “currentAction = actionNum;”
Is it an alternative for “e.getSource=buton”
Thank you
What IDE do you use? I try opening the archived files you sent with eclipse,but eclipse does not recognize it as an eclipse project
Ok forget that last question,managed to solve it. My problem is..al I do it only draws rectangles. Any idea why?
I have a tutorial on how to install Eclipse for Java. Maybe there is an installation problem because of your other question? Sorry, but I’m not sure.
if i have to guess..you may not have setup the environment variable paths on the computer your using.
I’m using Eclipse. I can’t understand why they wouldn’t open. I just tested this one and it worked. Sorry about that.