0

I have a custom JComponent that performs come complicated painting. It is set to non-opaque so that the background of its parent shows through the parts it does not paint.

I need an mouse overlay (a simple shape) that follows the mouse. It really shouldn't need to repaint the component below it every time the mouse moves. So I'm thinking to buffer the JComponent but because it's non-opaque, calling .paint(buffer) will not paint the background of the parent.

Any ideas?

Thanks in advance.

flux
  • 189
  • 3
  • 13
  • This is a little unclear to me. Perhaps you could use a Glass Pane? See "The Glass Pane" section of [How to Use Root Panes](http://download.oracle.com/javase/tutorial/uiswing/components/rootpane.html). – mre Jul 13 '11 at 13:34

2 Answers2

2

I have a custom JComponent that performs come complicated painting.

Maybe your complication painting can be done to a BufferedImage. Then the component just draws the image so you don't have to invoke the complicated code every time. The image would be recreated whenever properties affecting the image are changed.

camickr
  • 321,443
  • 19
  • 166
  • 288
1

May me you can use JWindow. Just make it visible and change position of the JWindow on mouse move?

StanislavL
  • 56,971
  • 9
  • 68
  • 98
  • +1 but are you meaning this one ??? http://stackoverflow.com/questions/5957241/text-mouseover-popups-over-a-swing-jtextarea/5957405#5957405 – mKorbel Jul 13 '11 at 07:33