|
-
Jul 18th, 2007, 01:03 PM
#1
Thread Starter
Addicted Member
Applets: Paint & Graphics
Can anyone link me to a GOOD tutorial for applets and the paint method and how graphics work all around? I've searched and searched but can't find a site that's really explained how to use graphics to paint on the screen from the view of a person who's never used that function of Java before. I just need to get the basic idea of it down and I haven't been able to do that with the walk-throughs that I've found.
-
Jul 18th, 2007, 09:48 PM
#2
PowerPoster
Re: Applets: Paint & Graphics
Check the Sun documentation,
Paint class.
Graphic class.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Jul 18th, 2007, 10:02 PM
#3
Thread Starter
Addicted Member
Re: Applets: Paint & Graphics
I'm looking for more of a tutorial, not a manual.
-
Jul 19th, 2007, 09:33 PM
#4
PowerPoster
Re: Applets: Paint & Graphics
Documentation also come with examples. But not bulky ones.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Jul 23rd, 2007, 03:38 PM
#5
Thread Starter
Addicted Member
Re: Applets: Paint & Graphics
If the Java documentation were as good as PHP's I'd be set but that's not really the case.
Anyway, I could still use a good example....
-
Jul 23rd, 2007, 11:59 PM
#6
PowerPoster
Re: Applets: Paint & Graphics
It's up to you. I believe that Java documentation is the best one in Java world.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Jul 24th, 2007, 02:17 PM
#7
Re: Applets: Paint & Graphics
 Originally Posted by eranga262154
It's up to you. I believe that Java documentation is the best one in Java world.
Unless you are a copy, paste type of developer
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 24th, 2007, 02:23 PM
#8
Thread Starter
Addicted Member
Re: Applets: Paint & Graphics
I've never copied code in my life... I just don't understand Java graphics and I can't find any examples that explain it from the stance of someone who has never used them.
I understand basic draw functions and whatnot I just don't understand things like the repaint() method and how to get it to paint what I want, when I want it to.
-
Jul 24th, 2007, 02:34 PM
#9
Re: Applets: Paint & Graphics
If that's the case, you might find this tutorial interesting.
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 24th, 2007, 09:15 PM
#10
PowerPoster
Re: Applets: Paint & Graphics
 Originally Posted by ComputerJy
Unless you are a copy, paste type of developer
I Never do that. I used codes on my own practice.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Aug 7th, 2007, 03:38 AM
#11
Member
Re: Applets: Paint & Graphics
Check this site out.
It has good tutorials on writing Java applets for Game Development.
Covers everything you need nicely...
http://www.javacooperation.gmxhome.d...lStartEng.html
-
Aug 7th, 2007, 04:52 AM
#12
PowerPoster
Re: Applets: Paint & Graphics
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Sep 29th, 2007, 11:08 PM
#13
Fanatic Member
Re: Applets: Paint & Graphics
Sorry to ask another question on this thread, but it's sort of related. Is there any way to get Java to draw gradients and/or with semi-transparent colors. This is easy to do in .NET, but I haven't found the APIs to do it in Java.
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Sep 30th, 2007, 11:41 PM
#14
PowerPoster
Re: Applets: Paint & Graphics
I don't know exact API for this. But for the gradients you can use, constructor Gradient() create gradient color with getGradient() method, and GradientPaint() use to fill the gradient color.
As far as I've remember, GradientPaint() syntax use as follows.
Code:
GradientPaint(start_x, start_y, start_color, end_x, end_x, end_color, true)
true define the repeatability of starting and ending colors.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Oct 1st, 2007, 12:30 AM
#15
Re: Applets: Paint & Graphics
Here is a working code sample (it's easier than you might think)
Code:
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.*;
public class Test extends JFrame {
public Test() {
super("Test");
this.setSize(300, 300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
@Override
public void paint(Graphics g) {
super.paint(g);
GradientPaint paint = new GradientPaint(0, 0, Color.BLUE, 300, 300, Color.BLACK);
((Graphics2D) g).setPaint(paint);
g.fillRect(0, 0, 300, 300);
}
public static void main(String[] args) {
new Test();
}
}
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 1st, 2007, 12:44 AM
#16
PowerPoster
Re: Applets: Paint & Graphics
 Originally Posted by ComputerJy
Here is a working code sample (it's easier than you might think)
Is it for me.
On you code, my tip is correct. One question there. You don't use that boolean option in GradientPaint(), means that the default is true, or I'm wrong with parameters list?
On this machine I've work now haven't setup Java yet and I can't test your code.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Oct 1st, 2007, 08:42 AM
#17
Re: Applets: Paint & Graphics
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 1st, 2007, 11:23 PM
#18
PowerPoster
Re: Applets: Paint & Graphics
 Originally Posted by ComputerJy
And by the way, I've never said your code is wrong 
No way pal just checking that I've missing something
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|