Search code examples
javaswingjfreechart

Adding radio buttons onto a graph drawn in java using jfreechart or swing


I need to add a radio button onto a graph that performs a specific action when it is selected. I have drawn the graph using jfreeChart in java. But I am unable to figure out a way to add a radio button onto that graph. Is it possible to do so? If not, is it possible to draw a line graph in swing and add radio buttons on top of it? Thanks in advance.


Solution

  • You should have a ChartPanel instance to add JFreeChart to your application. Try to set some LayoutManager e.g. BoxLayout or BorderLayout and just add the Radio Button to the panel with proper constraints to define desired position.