package menubar;import java.awt.*;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import org.jfree.chart.demo.*;
import org.jfree.ui.RefineryUtilities;public class queryblock extends JFrame {
private XYLayout xYLayout1 = new XYLayout();
private JLabel jLabel1 = new JLabel();
private JComboBox jComboBox1 = new JComboBox();
private Button button1 = new Button();
private Button button2 = new Button(); public queryblock() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));
jLabel1.setText("请选择小区:");
this.getContentPane().setLayout(xYLayout1);
jComboBox1.setFont(new java.awt.Font("SansSerif", 0, 16));
button1.setFont(new java.awt.Font("Dialog", 0, 16));
button1.setLabel("查询");
button2.setLabel("取消");
button2.setFont(new java.awt.Font("Dialog", 0, 16));
this.getContentPane().add(jLabel1, new XYConstraints(22, 36, 101, 26));
this.getContentPane().add(jComboBox1, new XYConstraints(117, 36, 111, 26));
this.getContentPane().add(button1, new XYConstraints(243, 33, 70, 28));
this.getContentPane().add(button2, new XYConstraints(322, 32, 70, 28));
}
public static void main(String[] args) { VerticalBarChartDemo demo = new VerticalBarChartDemo("Vertical Bar Chart Demo",new String[]{"one","two","three","four"});
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true); }
}/* ======================================
* JFreeChart : a free Java chart library
*/package org.jfree.chart.demo;import java.awt.Color;import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.HorizontalCategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.data.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;/**
* A simple demonstration application showing how to create a vertical bar chart.
*
* @author David Gilbert
*/
public class VerticalBarChartDemo extends ApplicationFrame { /**
* Creates a new demo instance.
*
* @param title the frame title.
*/
public VerticalBarChartDemo(String title,String Lcategory[]) { super(title); String category[]=new String[Lcategory.length+1];
// row keys... String series1 = "First";
String series2 = "Second";
String series3 = "Third"; // column keys...
for(int i=0;i<Lcategory.length;i++){ category[i+1]=Lcategory[i];
}
// create the dataset...
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, series1, category[1]);
dataset.addValue(4.0, series1, category[2]);
dataset.addValue(3.0, series1, category[3]);
dataset.addValue(5.0, series1, category[4]);
dataset.addValue(5.0, series2, category[1]);
dataset.addValue(7.0, series2, category[2]);
dataset.addValue(6.0, series2, category[3]);
dataset.addValue(8.0, series2, category[4]);
dataset.addValue(4.0, series3, category[1]);
dataset.addValue(3.0, series3, category[2]);
dataset.addValue(2.0, series3, category[3]);
dataset.addValue(3.0, series3, category[4]); // create the chart...
JFreeChart chart = ChartFactory.createVerticalBarChart(
"Vertical Bar Chart", // chart title
"Category", // domain axis label
"Value", // range axis label
dataset, // data
true, // include legend
true,
false
); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart...
chart.setBackgroundPaint(new Color(0xBBBBDD)); // get a reference to the plot for further customisation...
CategoryPlot plot = chart.getCategoryPlot(); // skip some labels if they overlap...
HorizontalCategoryAxis domainAxis = (HorizontalCategoryAxis) plot.getDomainAxis();
domainAxis.setSkipCategoryLabelsToFit(true); // set the range axis to display integers only...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. // add the chart to a panel...
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel); } /**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) { VerticalBarChartDemo demo = new VerticalBarChartDemo("Vertical Bar Chart Demo",new String[]{"one","two","three","four"});
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true); }}
怎么无法显示柱状图?
import com.borland.jbcl.layout.*;
import javax.swing.*;
import org.jfree.chart.demo.*;
import org.jfree.ui.RefineryUtilities;public class queryblock extends JFrame {
private XYLayout xYLayout1 = new XYLayout();
private JLabel jLabel1 = new JLabel();
private JComboBox jComboBox1 = new JComboBox();
private Button button1 = new Button();
private Button button2 = new Button(); public queryblock() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
jLabel1.setFont(new java.awt.Font("Dialog", 0, 16));
jLabel1.setText("请选择小区:");
this.getContentPane().setLayout(xYLayout1);
jComboBox1.setFont(new java.awt.Font("SansSerif", 0, 16));
button1.setFont(new java.awt.Font("Dialog", 0, 16));
button1.setLabel("查询");
button2.setLabel("取消");
button2.setFont(new java.awt.Font("Dialog", 0, 16));
this.getContentPane().add(jLabel1, new XYConstraints(22, 36, 101, 26));
this.getContentPane().add(jComboBox1, new XYConstraints(117, 36, 111, 26));
this.getContentPane().add(button1, new XYConstraints(243, 33, 70, 28));
this.getContentPane().add(button2, new XYConstraints(322, 32, 70, 28));
}
public static void main(String[] args) { VerticalBarChartDemo demo = new VerticalBarChartDemo("Vertical Bar Chart Demo",new String[]{"one","two","three","four"});
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true); }
}/* ======================================
* JFreeChart : a free Java chart library
*/package org.jfree.chart.demo;import java.awt.Color;import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.HorizontalCategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.data.DefaultCategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;/**
* A simple demonstration application showing how to create a vertical bar chart.
*
* @author David Gilbert
*/
public class VerticalBarChartDemo extends ApplicationFrame { /**
* Creates a new demo instance.
*
* @param title the frame title.
*/
public VerticalBarChartDemo(String title,String Lcategory[]) { super(title); String category[]=new String[Lcategory.length+1];
// row keys... String series1 = "First";
String series2 = "Second";
String series3 = "Third"; // column keys...
for(int i=0;i<Lcategory.length;i++){ category[i+1]=Lcategory[i];
}
// create the dataset...
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, series1, category[1]);
dataset.addValue(4.0, series1, category[2]);
dataset.addValue(3.0, series1, category[3]);
dataset.addValue(5.0, series1, category[4]);
dataset.addValue(5.0, series2, category[1]);
dataset.addValue(7.0, series2, category[2]);
dataset.addValue(6.0, series2, category[3]);
dataset.addValue(8.0, series2, category[4]);
dataset.addValue(4.0, series3, category[1]);
dataset.addValue(3.0, series3, category[2]);
dataset.addValue(2.0, series3, category[3]);
dataset.addValue(3.0, series3, category[4]); // create the chart...
JFreeChart chart = ChartFactory.createVerticalBarChart(
"Vertical Bar Chart", // chart title
"Category", // domain axis label
"Value", // range axis label
dataset, // data
true, // include legend
true,
false
); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart...
chart.setBackgroundPaint(new Color(0xBBBBDD)); // get a reference to the plot for further customisation...
CategoryPlot plot = chart.getCategoryPlot(); // skip some labels if they overlap...
HorizontalCategoryAxis domainAxis = (HorizontalCategoryAxis) plot.getDomainAxis();
domainAxis.setSkipCategoryLabelsToFit(true); // set the range axis to display integers only...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. // add the chart to a panel...
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel); } /**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) { VerticalBarChartDemo demo = new VerticalBarChartDemo("Vertical Bar Chart Demo",new String[]{"one","two","three","four"});
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true); }}
怎么无法显示柱状图?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货