Trying to create a translucent paint view over my application.
So far, I have a few objects at play.
paintView //a wrapper class of a JPane.
gScrollPane // the area I'm trying to cover
layeredPane // the layered pane
Here's my code so far
layeredPane = new JLayeredPane();
paintView = new PaintView//rest of constructor
layeredPane.add(gScrollPane);
layeredPane.add(paintView.getComponent(), new Integer(5));
layeredPane.moveToFront(paintView.getComponent());
For some reason, it's just not working. getComponent returns a jPane. So that shouldn't be the issue. I've made the panel red and opaque for testing but no luck. Have I missed something in the documentation?
Edit:
So I'm not seeing the paintview on top of the gScrollPane
and getComponent just returns the internally wrapped pane. That's not really the issue though.
I think it has to do with the layout of the layered pane. (Flow at the moment) Setting to box has the layers horizontally side by side (paintview left, gscrollpane right)
It's difficult to know exactly why you're having problems. It could be a paint issue, it could be a layout issue...
Don't forget,
JLayeredPane
has not layout manager by default. You could use one, but I simply overrode thedoLayout
method and "implemented" my own for the purpose of the example...