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.
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?
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 aFlowLayout
from the parent class,JPanel
, by default; a surroundingchartHolder
withBoxLayout
may be superfluous.