Add button to Chart Properties Dialog

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
karolinas
Posts: 5
Joined: Fri Mar 25, 2016 3:32 pm
antibot: No, of course not.

Add button to Chart Properties Dialog

Post by karolinas » Thu Feb 02, 2017 12:58 pm

Hi I am using the chart editor on the right-click to edit the charts, however the users are asking for the availability to not only have OK and Cancel buttons but also the "Apply" so that the changes can be applied for the user to review without having to click "OK" and re-open the properties window again if he needs to change something. I cannot seem to find where these buttons are added and how do I add the extra one. If these are added by default, is there any way I can add an extra button? Thanks!

daress
Posts: 23
Joined: Tue Mar 13, 2007 4:52 pm
Contact:

Re: Add button to Chart Properties Dialog

Post by daress » Thu Feb 02, 2017 11:13 pm

The chart properties dialog box you are referring to, I believe, is shown from the ChartPanel.java's

Code: Select all

public void doEditChartProperties()
method (I am looking at JFreeChart 1.0.19 source). In looking at that method, the OK and CANCEL buttons you are seeing is from the standard JOptionPane.showConfirmDialog() (link http://docs.oracle.com/javase/tutorial/ ... ialog.html) which is a modal dialog that provides the OK and CANCEL buttons. Adding an APPLY button would require extending the ChartPanel class and overriding the

Code: Select all

public void doEditChartProperties()
method to show a modeless window (a new class) and take appropriate action when the user clicks the APPLY button.

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Add button to Chart Properties Dialog

Post by John Matthews » Fri Feb 03, 2017 1:53 am

This example constructs a JToolBar of buttons that elicit the zoom actions used by the context menu; you can add other actions. On most platforms, the tool bar is detachable, providing a convenient floating palette.

Image

Locked