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:DialogDemo.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *//* w w w  . ja v a2  s.c om*/
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("DialogDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    DialogDemo newContentPane = new DialogDemo(frame);
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:com.db4o.sync4o.ui.Db4oSyncSourceConfigPanel.java

private static void showTestUI() {

    // Make sure we have nice window decorations.
    JFrame.setDefaultLookAndFeelDecorated(true);

    // Create and set up the window.
    JFrame frame = new JFrame("Db4oSyncSourceConfigPanel Test Harness");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    final Db4oSyncSource source = new Db4oSyncSource();
    Db4oSyncSourceConfigPanel p = new Db4oSyncSourceConfigPanel();
    p.setManagementObject(new SyncSourceManagementObject(source, null, null, null, null));
    p.updateForm();// ww w  .j  av a  2 s.  co  m
    p.setOpaque(true); // content panes must be opaque
    frame.setContentPane(p);

    frame.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent ev) {

            XMLEncoder encoder = null;
            try {
                FileOutputStream s = new FileOutputStream("test.xml");
                encoder = new XMLEncoder(s);
                encoder.setExceptionListener(new ExceptionListener() {
                    public void exceptionThrown(Exception exception) {
                        exception.printStackTrace();
                    }
                });
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                System.exit(-1);
            }
            encoder.writeObject((Object) source);
            encoder.flush();
            encoder.close();

        }

    });

    // Display the window.
    frame.pack();
    frame.setVisible(true);

}

From source file:simulation.AureoZauleckAnsLab2.java

public static JFreeChart createHistogram(ArrayList doubleMatrix, int width, String title, String label) {

    // Generate a one dimensional array of the size w*h of the double matrix
    ArrayList<Double> dataArrayList = new ArrayList<Double>();

    for (int i = 0; i < doubleMatrix.size(); i++) {

        double value = Double.parseDouble(doubleMatrix.get(i).toString());
        if (Double.isNaN(value))
            continue;
        else//from  w  w w  .  j a va 2  s  . co m
            dataArrayList.add(value);
        System.out.println(value);
    }

    double[] data = new double[dataArrayList.size()];

    for (int p = 0; p < dataArrayList.size(); p++)
        data[p] = dataArrayList.get(p);

    // int number = data.length;
    HistogramDataset dataset = new HistogramDataset();

    dataset.setType(HistogramType.FREQUENCY);
    dataset.addSeries("Hist", data, width);
    String plotTitle = title;
    String yAxis = "Frequency";
    String xAxis = label;
    PlotOrientation orientation = PlotOrientation.VERTICAL;

    boolean show = false;
    boolean toolTips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createHistogram(plotTitle, xAxis, yAxis, dataset, orientation, show,
            toolTips, urls);

    chart.setBackgroundPaint(Color.white);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    JFrame l = new JFrame();
    l.setContentPane(chartPanel);
    l.setSize(400, 400);
    l.setVisible(true);

    return chart;
}

From source file:Main.java

void start() {
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.setInitialDelay(0);//from  w  ww .  j  a v a  2  s .com
    ttm.setDismissDelay(10000);

    Main newContentPane = new Main();
    newContentPane.setOpaque(true);

    JFrame frame = new JFrame("Main");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(newContentPane);
    frame.pack();
    frame.setLocation(150, 150);
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    pbar = new JProgressBar();
    pbar.setMinimum(min);//from  w w w.j  a v  a  2 s  . c  om
    pbar.setMaximum(max);
    add(pbar);

    JFrame frame = new JFrame("Progress Bar Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(this);
    frame.pack();
    frame.setVisible(true);

    for (int i = min; i <= max; i++) {
        final int percent = i;
        try {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    updateBar(percent);
                }
            });
            Thread.sleep(100);
        } catch (InterruptedException e) {
        }
    }
}

From source file:bdi4jade.examples.BDI4JADEExamplesApp.java

/**
 * Creates and shows a GUI whose content pane is an
 * {@link BDI4JADEExamplesPanel}.//from ww  w. j av a2 s.  c  om
 */
public void createAndShowGUI() {
    final JFrame frame = new JFrame();
    frame.setTitle("BDI4JADE Examples");
    frame.setContentPane(agentTestPanel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            frame.setVisible(true);
        }
    });
}

From source file:com.java.reports.ReportGenerator.java

public void showReport(String _name, int width, int height) {

    JFrame jFrame = new JFrame(_name);
    if (chart == null) {
        System.out.println("Please generate chart..");
    }/*from w  w w .j  a v a 2  s.c  o m*/
    jFrame.setContentPane(new ChartPanel(chart));
    jFrame.setSize(width, height);
    RefineryUtilities.centerFrameOnScreen(jFrame);
    jFrame.setVisible(true);
}

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

public void showChart() {
    int width = 600;
    int height = 600;
    JFreeChart chart = createBarChart();
    ChartPanel chartPanel = new ChartPanel(chart, width, height, 16, 16, width * 10, height * 10, true, true,
            true, true, true, true);/*from w ww  .  ja  va2  s  .c  o m*/
    JFrame frame = new JFrame(chart.getTitle().getText());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(chartPanel);
    frame.pack();
    frame.setVisible(true);
}

From source file:org.samjoey.graphing.GraphUtility.java

public static void createGraphs(LinkedList<Game> games) {
    HashMap<String, XYSeriesCollection> datasets = new HashMap<>();
    for (Game game : games) {
        for (String key : game.getVarData().keySet()) {
            if (datasets.containsKey(key)) {
                try {
                    datasets.get(key).addSeries(createSeries(game.getVar(key), "" + game.getId()));
                } catch (Exception e) {
                }/*from  ww w . ja  v a2  s . c  om*/
            } else {
                datasets.put(key, new XYSeriesCollection());
                datasets.get(key).addSeries(createSeries(game.getVar(key), "" + game.getId()));
            }
        }
    }

    for (String key : datasets.keySet()) {
        JFrame f = new JFrame();
        JFreeChart chart = ChartFactory.createXYLineChart(key, // chart title
                "X", // x axis label
                "Y", // y axis label
                datasets.get(key), // data
                PlotOrientation.VERTICAL, false, // include legend
                true, // tooltips
                false // urls
        );
        XYPlot plot = chart.getXYPlot();
        XYItemRenderer rend = plot.getRenderer();
        for (int i = 0; i < games.size(); i++) {
            Game g = games.get(i);
            if (g.getWinner() == 1) {
                rend.setSeriesPaint(i, Color.RED);
            }
            if (g.getWinner() == 2) {
                rend.setSeriesPaint(i, Color.BLACK);
            }
            if (g.getWinner() == 0) {
                rend.setSeriesPaint(i, Color.PINK);
            }
        }
        ChartPanel chartPanel = new ChartPanel(chart);
        f.setContentPane(chartPanel);
        f.pack();
        RefineryUtilities.centerFrameOnScreen(f);
        f.setVisible(true);
    }
}

From source file:GUI.Statistique.java

private ChartPanel calculerBudget() {
    ProduitDAO produitDAO = new ProduitDAO();
    List<Produit> produits = new ArrayList<>();
    produits = produitDAO.findAll();/* w w  w  .  j av  a2  s .  c  o m*/
    CommandeDAO commandeDAO = new CommandeDAO();
    List<Commande> commandes = new ArrayList<>();
    commandes = commandeDAO.findAll();
    DefaultPieDataset dSet = new DefaultPieDataset();
    for (Produit produit : produits) {
        dSet.setValue(produit.getNom(), produit.getNbvente());
        System.out.println(produit.getNbvente());
    }
    JFreeChart chart = ChartFactory.createPieChart3D("liste des produits les plus vendus", dSet, true, true,
            true);
    chart.setBackgroundPaint(Color.yellow);
    chart.getTitle().setPaint(Color.RED);
    PiePlot3D p = (PiePlot3D) chart.getPlot();
    ChartPanel cp = new ChartPanel(chart, true, true, true, true, true);
    JFrame f = new JFrame();
    f.setContentPane(cp);
    f.pack();
    jpBudjet.add(cp);
    return cp;
}