Example usage for javax.swing JFrame setContentPane

List of usage examples for javax.swing JFrame setContentPane

Introduction

In this page you can find the example usage for javax.swing JFrame setContentPane.

Prototype

@BeanProperty(bound = false, hidden = true, description = "The client area of the frame where child components are normally inserted.")
public void setContentPane(Container contentPane) 

Source Link

Document

Sets the contentPane property.

Usage

From source file:ar.com.mantinanmatias.calculadoraderivadas.Interface.java

public void GraficarFuncion(String funcion, Node nodo_funcion, double desde, double hasta, double intervalo)
        throws ParseException {

    XYSeries seriesPuntos = new XYSeries("Puntos");

    double[] valores_x = increment(desde, intervalo, hasta);
    double[] valores_y = ObtenerValoresFuncion(valores_x, seriesPuntos, funcion, nodo_funcion);

    XYSeriesCollection dataset = new XYSeriesCollection(seriesPuntos);

    JFreeChart graficoXY = ChartFactory.createXYLineChart(funcion, "x", "y", dataset, PlotOrientation.VERTICAL,
            true, true, false);//from  w w w . j  a va2 s  . com

    ChartPanel panelGrafico = new ChartPanel(graficoXY);

    //Plot2DPanel panelGrafico= new Plot2DPanel();
    //    panelGrafico.addLinePlot(funcion, valores_x, valores_y);
    JFrame ventanaGrafico = new JFrame("Grfico");
    ventanaGrafico.setSize(500, 500);
    ventanaGrafico.setContentPane(panelGrafico);
    ventanaGrafico.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    ventanaGrafico.setLocationRelativeTo(null);
    ventanaGrafico.setVisible(true);

}

From source file:org.spantus.exp.segment.draw.DrawDtw.java

public void showChart() {
    JFrame frame = new JFrame("Dtw chart");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JFreeChart chart = createXYZChart();
    int width = 600;
    int height = 600;
    ChartPanel chartPanel = new ChartPanel(chart, width, height, 16, 16, width * 10, height * 10, true, true,
            true, true, true, true);//from  w ww. j  ava 2  s.  co m
    frame.setContentPane(chartPanel);
    frame.pack();
    frame.setVisible(true);
}

From source file:LineChart.java

public LineChart(JTable table) {
    final JFrame frame = new JFrame("jshow Chart");

    final JFreeChart chart = createDataset(table);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    frame.setContentPane(chartPanel);

    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    frame.setIconImage(Toolkit.getDefaultToolkit()
            .createImage(LineChart.class.getResource("de/skelton/images/chart.png")));

    frame.pack();/*from   ww  w  . j  a v a  2  s  .  co m*/
    frame.setVisible(true);
    frame.requestFocus();
    frame.toFront();
}

From source file:edu.pdi2.visual.ViewSignature.java

public ViewSignature(String name, byte[] sign) {
    super();// www .  j  a v  a2 s.  co m
    XYSeries signature = new XYSeries("Signature");
    for (int i = 0; i < sign.length; i++) {
        signature.add(i, sign[i]);
    }

    JFrame frame = new JFrame();
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(signature);
    JFreeChart signatureG = ChartFactory.createXYLineChart("Signature " + name, "Valorx", "Valory", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartpanel = new ChartPanel(signatureG);
    chartpanel.setPreferredSize(new Dimension(390, 290));
    frame.setContentPane(chartpanel);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    frame.pack();
    frame.setSize(400, 300);
    frame.setVisible(true);
    if (name == " RED")
        frame.setLocation(0, 300);
    else
        frame.setLocation(400, 300);

}

From source file:turtlekit.pvequalsnrt.PhysicsChecker.java

@Override
public void setupFrame(JFrame frame) {
    XYSeriesCollection dataset = new XYSeriesCollection();
    final ChartPanel chartPanel = ChartsUtil.createChartPanel(dataset, "PV = nRT", null, null);
    chartPanel.setPreferredSize(new java.awt.Dimension(550, 250));
    rightSide = new XYSeries("Gas on the right side");
    dataset.addSeries(rightSide);/*from w w w.j a  va2 s.c o m*/
    total = new XYSeries("Total");
    dataset.addSeries(total);
    frame.setContentPane(chartPanel);
    frame.setLocation(50, 0);
    XYSeries s = dataset.getSeries("Total");
}

From source file:charts.Chart.java

public static Vector MultipleLineChart(CategoryDataset[] datasets, String title, String x_axis_label,
        String y_axis_label, boolean showlegend, float maxvalue, float minvalue, boolean showchart) {

    CategoryAxis domainAxis = new CategoryAxis(x_axis_label);
    ValueAxis rangeAxis = new NumberAxis(y_axis_label);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    if (minvalue == 0 && maxvalue == 0) {
        rangeAxis.setAutoRange(true);//from  w  w  w .  j a va  2 s.c o m
    } else {
        rangeAxis.setRange(minvalue, maxvalue);
    }
    CombinedDomainCategoryPlot parent = new CombinedDomainCategoryPlot(new CategoryAxis(x_axis_label));

    for (int i = 0; i < datasets.length; i++) {
        CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();//new CategoryStepRenderer(true);
        renderer.setBaseStroke(new BasicStroke(2.0f));
        renderer.setBaseSeriesVisibleInLegend(showlegend);
        CategoryPlot subplot = new CategoryPlot(datasets[i], domainAxis, rangeAxis, renderer);
        subplot.setBackgroundPaint(Color.white);
        subplot.setRangeGridlinePaint(Color.black);
        subplot.setDomainGridlinesVisible(true);
        //subplot.setDrawSharedDomainAxis(true);
        parent.add(subplot, 1);
    }

    JFreeChart jfreechart = new JFreeChart(title, parent);
    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));

    //if (showchart) {
    JFrame chartwindow = new JFrame(title);
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
    //}
    Vector res = new Vector();
    res.add(0, jfreechart);
    res.add(1, chartwindow);
    return res;
}

From source file:charts.Chart.java

public static JFreeChart MultipleStepChart(CategoryDataset[] datasets, String title, String x_axis_label,
        String y_axis_label, boolean showlegend, float maxvalue, float minvalue, boolean showchart) {

    CategoryAxis domainAxis = new CategoryAxis(x_axis_label);
    ValueAxis rangeAxis = new NumberAxis(y_axis_label);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    if (minvalue == 0 && maxvalue == 0) {
        rangeAxis.setAutoRange(true);/*from w  w w .j  a  va 2 s  .c o m*/
    } else {
        rangeAxis.setRange(minvalue, maxvalue);
    }
    CombinedDomainCategoryPlot parent = new CombinedDomainCategoryPlot(new CategoryAxis(x_axis_label));

    for (int i = 0; i < datasets.length; i++) {
        CategoryItemRenderer renderer = new CategoryStepRenderer(true);
        renderer.setBaseStroke(new BasicStroke(2.0f));
        CategoryPlot subplot = new CategoryPlot(datasets[i], domainAxis, rangeAxis, renderer);
        subplot.setBackgroundPaint(Color.white);
        subplot.setRangeGridlinePaint(Color.black);
        subplot.setDomainGridlinesVisible(true);
        //subplot.setDrawSharedDomainAxis(true);
        parent.add(subplot, 1);
    }

    JFreeChart jfreechart = new JFreeChart(title, parent);
    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));

    if (showchart) {
        JFrame chartwindow = new JFrame(title);
        chartwindow.setContentPane(jpanel);
        chartwindow.pack();
        RefineryUtilities.centerFrameOnScreen(chartwindow);
        chartwindow.setVisible(true);
    }
    return jfreechart;
}

From source file:charts.Chart.java

public static JFreeChart MultipleSplineLineChart(XYDataset[] datasets, String title, String x_axis_label,
        String y_axis_label, boolean showlegend, float maxvalue, float minvalue, boolean showchart) {

    ValueAxis domainAxis = new NumberAxis(x_axis_label);
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    ValueAxis rangeAxis = new NumberAxis(y_axis_label);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());

    if (minvalue == 0 && maxvalue == 0) {
        rangeAxis.setAutoRange(true);//from w  w  w.ja  va2  s  .  com
    } else {
        rangeAxis.setRange(minvalue, maxvalue);
    }

    //define o grafo combinado, determinando o label do eixo x.
    CombinedDomainXYPlot parent = new CombinedDomainXYPlot(domainAxis);

    for (int i = 0; i < datasets.length; i++) {
        XYSplineRenderer renderer = new XYSplineRenderer();
        renderer.setBaseStroke(new BasicStroke(2.0f));
        renderer.setBaseSeriesVisibleInLegend(showlegend);
        renderer.setShapesVisible(true);
        XYPlot subplot = new XYPlot(datasets[i], domainAxis, rangeAxis, renderer);
        subplot.setBackgroundPaint(Color.white);
        subplot.setRangeGridlinePaint(Color.black);
        subplot.setDomainGridlinesVisible(true);
        parent.add(subplot, 1);
    }
    JFreeChart jfreechart = new JFreeChart(title, parent);
    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));

    if (showchart) {
        JFrame chartwindow = new JFrame(title);
        chartwindow.setContentPane(jpanel);
        chartwindow.pack();
        RefineryUtilities.centerFrameOnScreen(chartwindow);
        chartwindow.setVisible(true);
    }
    return jfreechart;
}

From source file:charts.Chart.java

public static JFreeChart MultipleStepChartOverlayed(XYDataset[] datasets1, XYDataset[] datasets2, String title,
        String x_axis_label, String y_axis_label, boolean showlegend, float maxvalue, float minvalue,
        boolean showchart) {

    ValueAxis domainAxis = new NumberAxis(x_axis_label);
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    ValueAxis rangeAxis = new NumberAxis(y_axis_label);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());

    if (minvalue == 0 && maxvalue == 0) {
        rangeAxis.setAutoRange(true);//  w  w w. j  a va 2s .c o m
    } else {
        rangeAxis.setRange(minvalue, maxvalue);
    }

    //define o grafo combinado, determinando o label do eixo x.
    CombinedDomainXYPlot parent = new CombinedDomainXYPlot(domainAxis);

    for (int i = 0; i < datasets1.length; i++) {
        XYItemRenderer renderer1 = new XYStepRenderer();
        renderer1.setBaseStroke(new BasicStroke(2.0f));
        renderer1.setBaseSeriesVisibleInLegend(showlegend);
        XYPlot subplot = new XYPlot(datasets1[i], domainAxis, rangeAxis, renderer1);
        subplot.setBackgroundPaint(Color.white);
        subplot.setRangeGridlinePaint(Color.black);
        subplot.setDomainGridlinesVisible(true);

        XYSplineRenderer renderer2 = new XYSplineRenderer();
        renderer2.setSeriesPaint(0, Color.LIGHT_GRAY);
        renderer2.setBaseStroke(new BasicStroke(2.0f));
        renderer2.setShapesVisible(true);
        renderer2.setBaseSeriesVisibleInLegend(false);
        subplot.setDataset(1, datasets2[i]);
        subplot.setRenderer(1, renderer2);
        parent.add(subplot, 1);
    }
    JFreeChart jfreechart = new JFreeChart(title, parent);
    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));

    if (showchart) {
        JFrame chartwindow = new JFrame(title);
        chartwindow.setContentPane(jpanel);
        chartwindow.pack();
        RefineryUtilities.centerFrameOnScreen(chartwindow);
        chartwindow.setVisible(true);
    }
    return jfreechart;
}

From source file:charts.Chart.java

public static Vector MultipleStepChartOverlayed(CategoryDataset[] datasets1, CategoryDataset[] datasets2,
        String title, String x_axis_label, String y_axis_label, boolean showlegend, float maxvalue,
        float minvalue, boolean showchart) {

    CategoryAxis domainAxis = new CategoryAxis(x_axis_label);
    ValueAxis rangeAxis = new NumberAxis(y_axis_label);
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    //if (minvalue == 0 && maxvalue == 0) {
    //    rangeAxis.setAutoRange(true);
    //} else {//from   w w w . j av a2  s .c  o m
    //    rangeAxis.setRange(minvalue, maxvalue);
    //}
    rangeAxis.setAutoRange(true);

    CombinedDomainCategoryPlot parent = new CombinedDomainCategoryPlot(new CategoryAxis(x_axis_label));

    for (int i = 0; i < datasets1.length; i++) {
        CategoryItemRenderer renderer1 = new CategoryStepRenderer(true);
        renderer1.setBaseStroke(new BasicStroke(2.0f));
        renderer1.setBaseSeriesVisibleInLegend(showlegend);

        CategoryPlot subplot = new CategoryPlot(datasets1[i], domainAxis, rangeAxis, renderer1);
        subplot.setBackgroundPaint(Color.white);
        subplot.setRangeGridlinePaint(Color.black);
        subplot.setDomainGridlinesVisible(true);

        DefaultCategoryItemRenderer renderer2 = new DefaultCategoryItemRenderer();
        renderer2.setSeriesPaint(0, Color.LIGHT_GRAY);
        renderer2.setBaseStroke(new BasicStroke(2.0f));
        renderer2.setShapesVisible(true);
        renderer2.setBaseSeriesVisibleInLegend(false);

        subplot.setDataset(1, datasets2[i]);
        subplot.setRenderer(1, renderer2);
        //subplot.setDrawSharedDomainAxis(true);
        parent.add(subplot, 1);
    }

    JFreeChart jfreechart = new JFreeChart(title, parent);
    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));

    //if (showchart) {
    JFrame chartwindow = new JFrame(title);
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
    //}
    Vector res = new Vector();
    res.add(0, jfreechart);
    res.add(1, chartwindow);
    return res;
}