Place JComponent On The Top Of JXLayer
- by Yan Cheng CHEOK
Hello, currently, I had successful applying JXLayer on my charting component, to draw a yellow information box on the top of it.
final org.jdesktop.jxlayer.JXLayer<ChartPanel> layer = new org.jdesktop.jxlayer.JXLayer<ChartPanel>(this.chartPanel);
this.chartLayerUI = new ChartLayerUI<ChartPanel>(this);
layer.setUI(this.chartLayerUI);
At the same time, I wish to add the following JComponent (DefaultDrawingView) on the top of JXLayer. This JComponent has the ability
1) To receive mouse event to draw figures on itself.
Within ChartLayerUI, I add the following code
@Override
@SuppressWarnings("unchecked")
public void installUI(JComponent c) {
super.installUI(c);
JXLayer<JComponent> l = (JXLayer<JComponent>) c;
l.getGlassPane().setLayout(new java.awt.BorderLayout());
// this.view is DefaultDrawingView drawing object.
l.getGlassPane().add(this.view, java.awt.BorderLayout.CENTER);
}
However, after having the above code, I get the following outcome
1) My charting component ChartPanel are being blocked by DefaultDrawingView
2) My charting component no longer able to receive mouse event.
What I wish is that
A) ChartPanel and DefaultDrawingView able to show up
B) ChartPanel and DefaultDrawingView able to receive mouse event
Is there other steps I had missed out, or did wrong?
Thanks.