popupmenu SWT

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
yoann29
Posts: 2
Joined: Wed Apr 02, 2008 10:35 am
Location: France

popupmenu SWT

Post by yoann29 » Wed Apr 02, 2008 10:40 am

Hey,

I use Jfreechart in a RCP application and I have a problem :
I can't change the popupmenu using a chartComposite is it under development or do I use it badly ?
Here is my code (trying to remove the popupmenu) :

ChartPanel chartPanel = new ChartPanel(chart, true);
chartPanel.setPopupMenu(null);
final ChartComposite frame = new ChartComposite(parent, SWT.NONE,chartPanel.getChart(), true);
------------------------------
Thanks

Yoann

heprom
Posts: 91
Joined: Sat May 27, 2006 4:25 am
Location: Paris

Post by heprom » Sun May 25, 2008 10:26 am

There is something wrong in your code, you do not need the ChartPanel instance :

Code: Select all

final ChartComposite frame = new ChartComposite(parent, SWT.NONE,chart, true);
frame.setPopupMenu(null); 
HTH,
Henry

ahchuan
Posts: 3
Joined: Tue Jun 03, 2008 2:03 am

Post by ahchuan » Tue Jun 03, 2008 2:09 am

There is a way to change the popup menu by overriding the createPopupMenu() method in the subclass of ChartComposite.

Code: Select all

protected Menu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) {
    Menu menu =  super.createPopupMenu(properties, save, print, zoom);

    //Then add your menu items
    MenuItem item = new MenuItem(menu, SWT.SEPARATOR);
    item = new MenuItem(menu, SWT.NONE);
    item.setText("Whatever");
    .....   
    
    //finally return the menu
    return menu;
}

Locked