Example usage for java.awt Frame add

List of usage examples for java.awt Frame add

Introduction

In this page you can find the example usage for java.awt Frame add.

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:grafici.MediciTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * //w  w w .  jav a2s  .  c  o m
 * @param title
 *            the frame title.
 */
public MediciTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);

    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));
    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:grafici.PrenotazioneTimeSeriesChart.java

/**
 * A demonstration application showing how to create a simple time series
 * chart. This example uses monthly data.
 * //  w ww . ja  v  a 2  s . c o  m
 * @param title
 *            the frame title.
 */
public PrenotazioneTimeSeriesChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);

    Label titolo = new Label(this, SWT.NONE);
    titolo.setFont(new Font(titolo.getDisplay(), "arial", 15, SWT.BOLD));
    titolo.setText(title);
    GridData gdLbl = new GridData(SWT.FILL);
    titolo.setLayoutData(gdLbl);
    Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
    GridData gdCmp = new GridData(SWT.FILL);
    gdCmp.horizontalAlignment = SWT.FILL;
    gdCmp.verticalAlignment = SWT.FILL;
    gdCmp.grabExcessHorizontalSpace = true;
    gdCmp.grabExcessVerticalSpace = true;
    cmp.setLayoutData(gdCmp);
    cmp.setLayout(new GridLayout(1, false));
    JPanel chartPanel = createDemoPanel(tipo);
    Frame graphFrame = SWT_AWT.new_Frame(cmp);
    graphFrame.add(chartPanel);
    graphFrame.pack();

    GridData gdThis = new GridData(SWT.FILL);
    gdThis.horizontalAlignment = SWT.FILL;
    gdThis.verticalAlignment = SWT.FILL;
    gdThis.grabExcessHorizontalSpace = true;
    gdThis.grabExcessVerticalSpace = true;

    this.setLayoutData(gdThis);
    this.setLayout(new GridLayout(1, false));
}

From source file:grafici.StatisticheBarChart.java

/**
 * Creates a new demo instance./*from  w w w. ja v a 2 s .c o m*/
 * 
 * @param title
 *            the frame title.
 */
public StatisticheBarChart(Table risultati, Composite parent, int style, int variabile, int valore) {
    super(parent, style);
    try {
        this.titolo = risultati.getColumn(variabile).getText().toUpperCase() + " - "
                + risultati.getColumn(valore).getText().toUpperCase();
        GridData gdThis = new GridData(SWT.FILL);
        gdThis.horizontalAlignment = SWT.FILL;
        gdThis.verticalAlignment = SWT.FILL;
        gdThis.grabExcessHorizontalSpace = true;
        gdThis.grabExcessVerticalSpace = true;
        this.setLayoutData(gdThis);
        this.setLayout(new GridLayout(1, false));
        Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
        GridData gdCmp = new GridData(SWT.FILL);
        gdCmp.horizontalAlignment = SWT.FILL;
        gdCmp.verticalAlignment = SWT.FILL;
        gdCmp.grabExcessHorizontalSpace = true;
        gdCmp.grabExcessVerticalSpace = true;
        cmp.setLayoutData(gdCmp);
        cmp.setLayout(new GridLayout(1, false));

        CategoryDataset dataset = createDataset(risultati, variabile, valore);
        JFreeChart chart = createChart(dataset, risultati, variabile, valore);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setFillZoomRectangle(true);
        // chartPanel.setMouseWheelEnabled(true);
        // chartPanel.setPreferredSize(new Dimension(1000, 700));
        Frame graphFrame = SWT_AWT.new_Frame(cmp);
        graphFrame.add(chartPanel);
        graphFrame.pack();

    } catch (Exception e) {
        alertGraficoNonDisp();
    }
}

From source file:org.ietr.preesm.mapper.ui.GanttPlotter.java

/**
 * Gantt chart plotting function in a given composite
 *///from  ww w .j av  a2s. com
public void plotInComposite(Composite parent) {

    Composite composite = new Composite(parent, SWT.EMBEDDED | SWT.FILL);
    parent.setLayout(new FillLayout());
    Frame frame = SWT_AWT.new_Frame(composite);
    frame.add(getContentPane());

    MouseClickedListener listener = new MouseClickedListener(frame);
    chartPanel.addChartMouseListener(listener);
    chartPanel.addMouseMotionListener(listener);
    chartPanel.addMouseListener(listener);
}

From source file:grafici.PazientiBarChart.java

/**
 * Creates a new demo instance./*from  w ww.  j  av a2 s.  c o  m*/
 * 
 * @param title
 *            the frame title.
 */
public PazientiBarChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    try {
        this.titolo = title;
        GridData gdThis = new GridData(SWT.FILL);
        gdThis.horizontalAlignment = SWT.FILL;
        gdThis.verticalAlignment = SWT.FILL;
        gdThis.grabExcessHorizontalSpace = true;
        gdThis.grabExcessVerticalSpace = true;
        this.setLayoutData(gdThis);
        this.setLayout(new GridLayout(1, false));
        Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
        GridData gdCmp = new GridData(SWT.FILL);
        gdCmp.horizontalAlignment = SWT.FILL;
        gdCmp.verticalAlignment = SWT.FILL;
        gdCmp.grabExcessHorizontalSpace = true;
        gdCmp.grabExcessVerticalSpace = true;
        cmp.setLayoutData(gdCmp);
        cmp.setLayout(new GridLayout(1, false));

        CategoryDataset dataset = createDataset(tipo);
        JFreeChart chart = createChart(dataset);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setFillZoomRectangle(true);
        // chartPanel.setMouseWheelEnabled(true);
        // chartPanel.setPreferredSize(new Dimension(1000, 700));
        Frame graphFrame = SWT_AWT.new_Frame(cmp);
        graphFrame.add(chartPanel);
        graphFrame.pack();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:grafici.MediciBarChart.java

/**
 * Creates a new demo instance./*  ww  w .  j av  a 2  s . c o  m*/
 * 
 * @param title
 *            the frame title.
 */
public MediciBarChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    try {
        this.titolo = title;
        GridData gdThis = new GridData(SWT.FILL);
        gdThis.horizontalAlignment = SWT.FILL;
        gdThis.verticalAlignment = SWT.FILL;
        gdThis.grabExcessHorizontalSpace = true;
        gdThis.grabExcessVerticalSpace = true;
        this.setLayoutData(gdThis);
        this.setLayout(new GridLayout(1, false));
        Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
        GridData gdCmp = new GridData(SWT.FILL);
        gdCmp.horizontalAlignment = SWT.FILL;
        gdCmp.verticalAlignment = SWT.FILL;
        gdCmp.grabExcessHorizontalSpace = true;
        gdCmp.grabExcessVerticalSpace = true;
        cmp.setLayoutData(gdCmp);
        cmp.setLayout(new GridLayout(1, false));

        CategoryDataset dataset = createDataset(tipo);
        JFreeChart chart = createChart(dataset);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setFillZoomRectangle(true);
        // chartPanel.setMouseWheelEnabled(true);
        // chartPanel.setPreferredSize(new Dimension(1000, 700));
        Frame graphFrame = SWT_AWT.new_Frame(cmp);
        graphFrame.add(chartPanel);
        graphFrame.pack();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:grafici.PrenotazioniBarChart.java

/**
 * Creates a new demo instance.//from   w  w  w . j a  va2  s  . c  om
 * 
 * @param title
 *            the frame title.
 */
public PrenotazioniBarChart(String title, Composite parent, int style, int tipo) {
    super(parent, style);
    try {
        this.titolo = title;
        GridData gdThis = new GridData(SWT.FILL);
        gdThis.horizontalAlignment = SWT.FILL;
        gdThis.verticalAlignment = SWT.FILL;
        gdThis.grabExcessHorizontalSpace = true;
        gdThis.grabExcessVerticalSpace = true;
        this.setLayoutData(gdThis);
        this.setLayout(new GridLayout(1, false));
        Composite cmp = new Composite(this, SWT.FILL | SWT.EMBEDDED);
        GridData gdCmp = new GridData(SWT.FILL);
        gdCmp.horizontalAlignment = SWT.FILL;
        gdCmp.verticalAlignment = SWT.FILL;
        gdCmp.grabExcessHorizontalSpace = true;
        gdCmp.grabExcessVerticalSpace = true;
        cmp.setLayoutData(gdCmp);
        cmp.setLayout(new GridLayout(1, false));

        CategoryDataset dataset = createDataset(tipo);
        JFreeChart chart = createChart(dataset);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setFillZoomRectangle(true);
        // chartPanel.setMouseWheelEnabled(true);
        // chartPanel.setPreferredSize(new Dimension(1000, 700));
        Frame graphFrame = SWT_AWT.new_Frame(cmp);
        graphFrame.add(chartPanel);
        graphFrame.pack();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:peakmlviewer.dialog.PCADialog.java

public PCADialog(MainWnd mainwnd, Shell parent, String title) {
    super(parent, SWT.NONE);

    // save the parent pointer
    this.title = title;
    this.parent = parent;

    this.mainwnd = mainwnd;

    // create the window and set its properties
    shell = new Shell(parent, SWT.EMBEDDED | SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    shell.setSize(500, 300);/*from w ww .  ja  va  2  s  .  c om*/
    shell.setText(title);

    // create the jfreechart
    plot = new XYPlot(collection, new NumberAxis("principal component 1"),
            new NumberAxis("principal component 2"), new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);
    plot.getRenderer().setBaseItemLabelsVisible(true);
    plot.getRenderer().setBaseItemLabelGenerator(new XYItemLabelGenerator() {
        public String generateLabel(XYDataset dataset, int series, int item) {
            return labels[item];
        }
    });

    chart = new JFreeChart("Principle Component Analysis", plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.WHITE);
    chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    // add the components
    // --------------------------------------------------------------------------------
    // This uses the SWT-trick for embedding awt-controls in an SWT-Composit.
    try {
        System.setProperty("sun.awt.noerasebackground", "true");
    } catch (NoSuchMethodError error) {
        ;
    }

    java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(shell);

    // create a new ChartPanel, without the popup-menu (5x false)
    frame.add(new ChartPanel(chart, false, false, false, false, false));
    // --------------------------------------------------------------------------------
}

From source file:peakmlviewer.dialog.peakinformation.Graph.java

public Graph(Composite parent) {
    super(parent, SWT.EMBEDDED);

    setLayout(new FillLayout());

    // create the chart
    linechart = ChartFactory.createLineChart(null, "", "Abundance", dataset_intensity, PlotOrientation.VERTICAL,
            false, // legend
            false, // tooltips
            false // urls
    );/*from w  w  w  .j av a2s  .c  o m*/

    CategoryPlot plot = (CategoryPlot) linechart.getPlot();

    // make the labels for the xaxis 45 degrees
    CategoryAxis xaxis = (CategoryAxis) plot.getDomainAxis();
    xaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // add the mass accuracy yaxis
    NumberAxis yaxis_massacc = new NumberAxis("Mass accuracy (ppm)");
    plot.setRangeAxis(1, yaxis_massacc);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

    // create the mass accuracy dataset
    dataset_ppm = new DefaultCategoryDataset();
    plot.setDataset(1, dataset_ppm);
    plot.mapDatasetToRangeAxis(1, 1);

    // create the renderer for the mass accuracy dataset
    LineAndShapeRenderer renderer_ppm = new LineAndShapeRenderer();
    renderer_ppm.setBaseShapesFilled(true);
    renderer_ppm.setBaseShapesVisible(true);
    renderer_ppm.setBaseStroke(
            new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 1, new float[] { 5, 5 }, 0));
    plot.setRenderer(1, renderer_ppm);

    // setup the renderer for the intensity dataset
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(true);

    // general properties
    linechart.setBackgroundPaint(Color.WHITE);
    linechart.setBorderVisible(false);
    linechart.setAntiAlias(true);

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);

    // add the components
    // --------------------------------------------------------------------------------
    // This uses the SWT-trick for embedding awt-controls in an SWT-Composit.
    try {
        System.setProperty("sun.awt.noerasebackground", "true");
    } catch (NoSuchMethodError error) {
        ;
    }

    java.awt.Frame frame = org.eclipse.swt.awt.SWT_AWT.new_Frame(this);

    // create a new ChartPanel, without the popup-menu (5x false)
    frame.add(new ChartPanel(linechart, false, false, false, false, false));
    // --------------------------------------------------------------------------------
}

From source file:org.ietr.preesm.mapper.ui.BestCostPlotter.java

public void display(Composite parentComposite) {

    Composite composite = new Composite(parentComposite, SWT.EMBEDDED | SWT.FILL);
    parentComposite.setLayout(new FillLayout());
    Frame frame = SWT_AWT.new_Frame(composite);
    frame.add(this.getContentPane());

    MouseClickedListener listener = new MouseClickedListener(frame);
    chartPanel.addChartMouseListener(listener);
    chartPanel.addMouseMotionListener(listener);
    chartPanel.addMouseListener(listener);
}