我正在使用JFreeChart在我的程序中創建圖表。我的問題是我無法正確設置高度。我已經嘗試了所有我能想到的命令,但我已將其放在其他面板中,但沒有任何效果。 我希望能夠將它放在角落......或任何地方,並能夠設置寬度和高度。我也嘗試過setPrefferedSize,但它只適用於寬度。java餅圖高度未正確放置
代碼:
DefaultPieDataset result = new DefaultPieDataset();
result.setValue("TotalSwag", totalSwag);
result.setValue("TotalYolo", totalYolo);
result.setValue("TotalCool", totalCool);
result.setValue("TotalLame", totalLame);
JFreeChart chart = ChartFactory.createPieChart3D("Swag-O-meter", result, true, true, false);
PiePlot3D plot = (PiePlot3D) chart.getPlot();
plot.setStartAngle(290);
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
ChartPanel chartPanel = new ChartPanel(chart, W, H, W, H, W, H,
false, true, true, true, true, true);
chartPanel.setMaximumSize(new Dimension(150, 150));
charPanel.add(chartPanel);
charPanel.setSize(W, H);
contentPane.add(charPanel, BorderLayout.WEST);
嘗試在frame.setVisible(true);之前調用'frame.pack();'。 – Bobulous 2013-04-21 18:04:01
有沒有辦法做到這一點,而不會強制框架的大小與它內部的東西有關?我希望所有窗戶的尺寸相同 – Ted 2013-04-21 18:33:05
嗯,我的答案是修復它的那個,但我只能在24小時內接受它,原因是某種原因。儘管如此,你的加入是非常有用的,謝謝 – Ted 2013-04-22 12:55:47