简体   繁体   English

使用jfreechart或swing将单选按钮添加到用Java绘制的图形上

[英]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. 我已经在Java中使用jfreeChart绘制了图形。 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. 提前致谢。

You should have a ChartPanel instance to add JFreeChart to your application. 您应该有一个ChartPanel实例将JFreeChart添加到您的应用程序。 Try to set some LayoutManager eg BoxLayout or BorderLayout and just add the Radio Button to the panel with proper constraints to define desired position. 尝试设置一些LayoutManager例如BoxLayoutBorderLayout然后将单选按钮添加到具有适当约束的面板中以定义所需的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM