Change to the 'right-click' menu

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
arwelbath
Posts: 24
Joined: Fri Aug 10, 2007 12:37 pm

Change to the 'right-click' menu

Post by arwelbath » Tue Feb 17, 2009 4:01 pm

Hi,
I want to modify the menu that appears when I right click on a chart. Specifically, I want to keep the 'Save As', 'Print' and zooming options, but I want to remove the first 'properties' option.

Could someone suggest how I could do this?
Cheers,
Arwel

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Tue Feb 17, 2009 4:07 pm

Check the constructor for org.jfree.chart.ChartPanel. Specifically, pass false for the value of this parameter

Code: Select all

boolean properties,

MitchBuell
Posts: 47
Joined: Thu Dec 11, 2008 7:59 pm

Post by MitchBuell » Tue Feb 17, 2009 8:04 pm

Elaborating of what skunk said, there are two constructors for a ChartPanel to control what shows in the right click menu.

Code: Select all

ChartPanel(JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips)

and

ChartPanel(JFreeChart chart, int width, int height, int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, int maximumDrawHeight, boolean useBuffer, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips)
You can also replace the right click menu entirely with your own.

Code: Select all

ChartPanel.setPopupMenu(JPopupMenu popup)

Joshi
Posts: 8
Joined: Tue Sep 26, 2017 12:46 pm
antibot: No, of course not.

Re: Change to the 'right-click' menu

Post by Joshi » Fri Aug 03, 2018 10:32 am

you can add menuitem to the list at any index you like. to remove properties option pass false in chartpanel constructor argurments and the rest to true.

Post Reply