At the moment I'm using a ChartPanel in a javax.swing.JInternalFrame, and it's working brilliantly. However, I'd like to change the menu from being a JPopupMenu to a JMenuBar on the JInternalFrame. I've pretty much accomplished this like so:
-----------------------------------
ChartPanel chartPanel = new ChartPanel(getMyChart());
JInternalFrame chartFrame = new JInternalFrame("Chart Test");
chartFrame.getContentPane().add(chartPanel);
JMenu chartMenu = new JMenu("Chart Options");
MenuElement[] menuElements = chartPanel.getPopupMenu().getSubElements();
for (int i = 0; i < menuElements.length; i++) {
chartMenu.add((JMenuItem)menuElements);
}
JMenuBar chartMenuBar = new JMenuBar();
chartMenuBar.add(chartMenu);
chartFrame.setJMenuBar(chartMenuBar);
-----------------------------
The menubar of the frame now contains the chart controls as required. The problem is that a small, empty, JPopupMenu remains active upon right click. Is there a way I can get rid of this? Can access to a control menu (built on demand?) be given so that this works even if the menu is turned off using the constructor?
Thanks for reading,
Tom.
Accessing the menu from a ChartPanel?
Re: Accessing the menu from a ChartPanel?
You should be able to set the popup menu on the ChartPanel to null, and then nothing will be displayed.
Regards,
DG
Regards,
DG
Re: Accessing the menu from a ChartPanel?
Oh yeah, I didn't think of that (obviously!).
Brilliant software, brilliant support. Thank you.
Brilliant software, brilliant support. Thank you.