I'm trying to make a dial from JFreeChart
work while I press a JButton
made in NetBeans. The problem is that although the code seems ok while outside the JButton
, it gives me errors in the program when I put it inside.
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here
}
public class DemoChartProblem {
private final DefaultValueDataset dataset = new DefaultValueDataset(50);
private final JFrame frame = new JFrame();
public void main(String[] args) throws Exception {
new DemoChartProblem();
}
public DemoChartProblem() {
frame.setPreferredSize(new Dimension(300, 300));
frame.add(buildDialPlot(0, 30, 5));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.setVisible(true);
}
});
}
private ChartPanel buildDialPlot(int minimumValue, int maximumValue,
int majorTickGap) {
DialPlot plot = new DialPlot(dataset);
plot.setDialFrame(new StandardDialFrame());
plot.addLayer(new DialValueIndicator(0));
plot.addLayer(new DialPointer.Pointer());
StandardDialScale scale = new StandardDialScale(minimumValue,
maximumValue, -120, -300, majorTickGap, majorTickGap - 1);
scale.setTickRadius(0.88);
scale.setTickLabelOffset(0.20);
plot.addScale(0, scale);
return new ChartPanel(new JFreeChart(plot));
}
}
I guess it's something obvious, but I dont seem to find the problem; any help is appreciated.