JComboBox disappears when positioned over a JFreeChart in a JLayeredPane

148 views Asked by At

I have a JPanel that has a JLayeredPane. The JLayeredPane has a JPanel which has a BoxLayout and holds a JFreeChart. The JLayeredPane also has a JComboBox; see image below.

enter image description here

The Graph object is added to the chartHolder at runtime.

When i run the app the comboBox display correctly. Once the graph object is added to the chartHolder the combobox stops rendering. Only the graph will display.

If I click in the area where the combo box should be, the dropdown and the combobox become visible. If I click the graph to dismiss the dropdown the combo box disappears again.

chartHolder --> DEFAULT_LAYER in the jLayeredPane comboBox --> Pallette_Layer in the jLayeredPane.

Based on the ordering I have provided to the JLayeredPane, the combo box should always render above the graph.

What is the issue?

1

There are 1 answers

2
trashgod On

How to Use Layered Panes: Laying Out Components in a Layered Pane mentions that "By default, a layered pane has no layout manager." You'll have to verify that you're setting both the position and size of each component, as shown here using setBounds(). ChartPanel inherits a FlowLayout from the parent class, JPanel, by default; a surrounding chartHolder with BoxLayout may be superfluous.

image