use paintComponent(Graphics g)
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
He said he wanted to draw some graphics on a JLabel, well that's how. Maybe you should think a little harder before posting stupid replys. Besides, if you didn't even know what I was talking about, why did you even post? It was obvious that helped...Now stop taking away from other people's posts.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
ohhh Sorry dude, I thought you were like trying to insult my intelligence or something....Dang, I hate it when I do that...Really, I am sorry for being an a$$...please forgive me...
Anyways,
JLabel, is a component in swing...It's like any other label, in any other programming language..All it does is display information, and in matt's case, he's wanting to draw on top of the component...So, in order to do that, he has to override the paintComponent method...And no, it doesn't fully answer his question, it answers only part of it...I'll try answering the rest of it later...
Again, I'm really sorry..I thought you were trying to say that I didn't know what I was talking about! sorry :o
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
You can draw an arc in java, I guess that would be the same thing as a curve:
Somthing like... Graphics.drawArc(//code);
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
Are you talking about not answering the curve part? Could you just drwa multiple lines making it appear to be a curve only being made up of line segments.
That's probably not a bad idea, although I would check out the drawArc() method first, and if that didn't work for him, then doing what you said certainly would.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
(you'll have to excuse me i don't even own a computer, i just keep read this stuff until i can afford one)?
Wow! if that is true, you are one dedicated person.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
Your not doing that right, but answer this: Do you have to draw on a label? I mean you wont get much of an area to draw on...A much better way, would be to create an external class that extends Canvas, and use that as your drawing surface..When you have the external class created, you would override the paintComponent method, not the paint() method. Once the external class is created, you would simply add it to the other main class. If you want to do it this way, I can help you a lot more.
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
you can't do this:
public void paint(Graphics g) extends JLabel
this is a method extending?
second, you have to ovveride the paintComponent method, not paint();
I think it would be something like this:
public void paintComponent(Graphics g) {
g.drawLine(x1,x2,y1,y1);
JLabelName.paintComponent(g);
}
I'm not sure about the last line of the code, but It might work..
server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20