• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to draw lines without cover the background's image?

 
Chan Vysnow
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I make the image shown on a JLabel, it's a map of a beauty spot, so I want to draw lines refers to the way that tourist visit. Thus the image wouldn't be covered. But how can I achieve that? (The JLabel is on the JScrollPane, and the bottom is JFrame.)
Thanks in advance!
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to extend JLabel to add the custom painting. The basic code would be:

 
Chan Vysnow
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:You need to extend JLabel to add the custom painting. The basic code would be:



Thanks! But what I really want to do is to draw the line dyanmic, and I don't know how to generate it like this. I hava extended JLabel, and the picture is already appeared.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Chan Vysnow wrote:Thanks! But what I really want to do is to draw the line dyanmic, and I don't know how to generate it like this. I hava extended JLabel, and the picture is already appeared.


It doesn't really matter if it's dynamic as you'll still need to draw the line this way. The main difference is that the parameters used in the drawLine method will depend on variables that your program can change.

If this advice doesn't help you, you may wish to post a small compilable program that we can compile and run and that demonstrates your problem, an SSCCE. Much luck!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!