该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
不多说贴代码图片
public AnalTimeChart(String s,List sensorList) {
super(s);
this.sensorList= sensorList;
XYDataset xydataset = createDataset();//X轴数据集合
JFreeChart jfreechart = createChart1(xydataset);
ChartPanel chartpanel = new ChartPanel(jfreechart);
chartpanel.setPreferredSize(new Dimension(900, 500));//相当于设置面板的width height
// JButton YESTERDAY = new JButton("上一天");
//JButton TOMORROW = new JButton("下一天");
//chartpanel.add(YESTERDAY);
//chartpanel.add(TOMORROW);
setContentPane(chartpanel);
}
public static JPanel createDemoPanel()
{
JFreeChart jfreechart = createChart1(createDataset());
return new ChartPanel(jfreechart);
}
private static JFreeChart createChart1(XYDataset xydataset)
{
JFreeChart jfreechart = ChartFactory.createXYLineChart(" ", "时间", "温度", xydataset, PlotOrientation.VERTICAL, true, true, false);
jfreechart.setBackgroundPaint(Color.white);//设置窗口的背景颜色
XYPlot xyplot = (XYPlot)jfreechart.getPlot();
xyplot.setBackgroundPaint(Color.GRAY);//设置图标的背景颜色
xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));//设置外面的标尺 //设置x-y坐标轴
//下面三行是设置不同数据的标点的形状
XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)xyplot.getRenderer();//连接数据点与线,并且绘制形状
xylineandshaperenderer.setShapesVisible(true);
xylineandshaperenderer.setShapesFilled(true);
//以下设置x-y轴的单位距离
NumberAxis numberaxis = (NumberAxis)xyplot.getRangeAxis();//可以访问任意轴的数值数据
numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());//设置标准标记单位
return jfreechart;
}
我想把上一天和下一天放到下面左边和右边,请问大佬们怎么做呢?使用绝对布局的话,那两个按钮不能显示。