1

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?

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
codeNinja
  • 1,442
  • 3
  • 25
  • 61

1 Answers1

2

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

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • i tried adding a OverlayLayout to the jLaeredPane. Cant seem to get the comboBox positioned in the right place though – codeNinja Jun 26 '15 at 13:31
  • i added the following code and a overlaylayout. public boolean isOptimizedDrawingEnabled(){ return false; } – codeNinja Jun 26 '15 at 14:03