Example usage for javax.swing JPanel setOpaque

List of usage examples for javax.swing JPanel setOpaque

Introduction

In this page you can find the example usage for javax.swing JPanel setOpaque.

Prototype

@BeanProperty(expert = true, description = "The component's opacity")
public void setOpaque(boolean isOpaque) 

Source Link

Document

If true the component paints every pixel within its bounds.

Usage

From source file:es.emergya.ui.gis.popups.ConsultaHistoricos.java

private JPanel getIntervalo() {
    JPanel intervalo = new JPanel(new GridBagLayout());
    intervalo.setOpaque(false);
    intervalo.setBorder(new TitledBorder("Intervalo Temporal de Consulta"));

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;// w ww.ja va 2s .com
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    intervalo.add(new JLabel("Fecha/Hora Inicial"), gbc);
    gbc.gridx++;
    calendarini = new JCalendarCombo();
    calendarini.addActionListener(actionListener);
    calendarini.addDateListener(dateListener);
    intervalo.add(calendarini, gbc);
    gbc.gridx++;
    final Calendar instance = Calendar.getInstance();
    instance.set(Calendar.HOUR, 0);
    instance.set(Calendar.MINUTE, 0);
    instance.set(Calendar.SECOND, 0);
    horaini = initializeSpinner(instance);
    intervalo.add(horaini, gbc);

    gbc.gridx = 0;
    gbc.gridy++;

    intervalo.add(new JLabel("Fecha/Hora Final"), gbc);
    gbc.gridx++;
    calendarfin = new JCalendarCombo();
    calendarfin.addActionListener(actionListener);
    calendarfin.addDateListener(dateListener);
    intervalo.add(calendarfin, gbc);
    gbc.gridx++;
    horafin = initializeSpinner(instance);
    intervalo.add(horafin, gbc);

    gbc.gridx = 0;
    gbc.gridy++;
    gbc.anchor = GridBagConstraints.EAST;
    soloUltimas = new JCheckBox();
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateRecursos();
        }
    });
    soloUltimas.setOpaque(false);
    soloUltimas.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            boolean enabled = !soloUltimas.isSelected();
            calendarini.setEnabled(enabled);
            calendarfin.setEnabled(enabled);
            horaini.setEnabled(enabled);
            horafin.setEnabled(enabled);
        }
    });
    intervalo.add(soloUltimas, gbc);
    gbc.gridx++;
    gbc.anchor = GridBagConstraints.WEST;
    intervalo.add(new JLabel("Consultar Slo Las ltimas Posiciones"), gbc);

    return intervalo;
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JPanel buildPanelFilter(final String topLabel, final int textfieldSize, final Dimension dimension,
        final JList list, final boolean left) {
    JPanel left_filtro = new JPanel(new GridBagLayout());
    left_filtro.setPreferredSize(dimension);
    left_filtro.setOpaque(false);
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;//from w  w  w.j  a  va 2 s.c  o m
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.BASELINE_LEADING;
    left_filtro.add(new JLabel(topLabel, JLabel.LEFT), gbc);

    final JTextField filtro = new JTextField(textfieldSize);
    gbc.gridy++;
    left_filtro.add(filtro, gbc);

    AbstractAction actionStartFilter = new AbstractAction(null, getIcon("Buttons.noFiltrar")) {

        private static final long serialVersionUID = -4737487889360372801L;

        @Override
        public void actionPerformed(ActionEvent e) {
            ((DefaultListModel) list.getModel()).removeAllElements();
            filtro.setText(null);
            if (left) {
                for (Object obj : leftItems) {
                    ((DefaultListModel) list.getModel()).addElement(obj);
                }
            } else {
                for (Object obj : rightItems) {
                    ((DefaultListModel) list.getModel()).addElement(obj);
                }
            }

        }
    };
    AbstractAction actionStopFilter = new AbstractAction(null, getIcon("Buttons.filtrar")) {

        private static final long serialVersionUID = 6570608476764008290L;

        @Override
        public void actionPerformed(ActionEvent e) {
            ((DefaultListModel) list.getModel()).removeAllElements();
            if (left) {
                for (Object obj : leftItems) {
                    if (compare(filtro, obj)) {
                        ((DefaultListModel) list.getModel()).addElement(obj);
                    }
                }
            } else {
                for (Object obj : rightItems) {
                    if (compare(filtro, obj)) {
                        ((DefaultListModel) list.getModel()).addElement(obj);
                    }
                }
            }
        }

        private boolean compare(final JTextField filtro, Object obj) {
            final String elemento = obj.toString().toUpperCase().trim();
            final String text = filtro.getText().toUpperCase().trim();

            final String pattern = text.replace("*", ".*");
            boolean res = Pattern.matches(pattern, elemento);

            return res;// || elemento.indexOf(text) >= 0;
        }
    };
    JButton jButton = new JButton(actionStartFilter);
    JButton jButton2 = new JButton(actionStopFilter);
    jButton.setBorderPainted(false);
    jButton2.setBorderPainted(false);
    jButton.setContentAreaFilled(false);
    jButton2.setContentAreaFilled(false);
    jButton.setPreferredSize(
            new Dimension(jButton.getIcon().getIconWidth(), jButton.getIcon().getIconHeight()));
    jButton2.setPreferredSize(
            new Dimension(jButton2.getIcon().getIconWidth(), jButton2.getIcon().getIconHeight()));

    gbc.gridx++;
    left_filtro.add(jButton2, gbc);
    gbc.gridx++;
    left_filtro.add(jButton, gbc);
    return left_filtro;
}

From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java

private JPanel buildCentral(final String centered_label, final Object[] left_items, final Object[] right_items,
        final String left_label, final String right_label, final int textfieldSize, final Dimension dimension,
        final Dimension dimension1, final Dimension dimension2, final Dimension dimension3) {
    JPanel central = buildCenter(centered_label);
    GridBagConstraints gbc = new GridBagConstraints();
    buildJList(dimension, left_items, left);
    JScrollPane scrollleft = addScrollPane(dimension, left);
    buildJList(dimension, right_items, right);
    JScrollPane scrollright = addScrollPane(dimension, right);

    gbc.gridx = 0;//  ww  w  . j a v a  2 s  .  c  om
    gbc.insets = new Insets(10, 10, 10, 10);
    JPanel leftPanel = null;
    if (left_items != null) {
        leftPanel = buildLateral(left_label, dimension1, dimension3, scrollleft, left, true);

        leftItems.clear();
        for (Object o : ((DefaultListModel) left.getModel()).toArray()) {
            leftItems.add(o);
        }
        central.add(leftPanel, gbc);

        gbc.gridx++;
        JPanel botones = buildBotones(dimension2, left, right);
        central.add(botones, gbc);

        gbc.gridx++;
        right.setEnabled(true);
        comboTipoCapa.setEnabled(true);
        habilitado.setEnabled(true);
    } else {
        right.setEnabled(false);
    }
    JPanel rightPanel = buildLateral(right_label, dimension1, dimension3, scrollright, right, false);
    rightItems.clear();
    for (Object o : ((DefaultListModel) right.getModel()).toArray()) {
        rightItems.add(o);
    }

    central.add(rightPanel, gbc);

    JPanel resultado = new JPanel(new BorderLayout(10, 5));
    final TitledBorder titledBorder = new TitledBorder(centered_label);
    resultado.setBorder(titledBorder);
    resultado.setOpaque(false);
    resultado.add(central, BorderLayout.CENTER);

    JPanel res = new JPanel(new BorderLayout());
    res.setOpaque(false);
    res.setBorder(new EmptyBorder(0, 15, 0, 15));
    res.add(resultado);
    return res;
}

From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java

/**
 * Updates the charts./* w  w w  .  java  2 s .  c o m*/
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
    for (int i = 0; i < listOfChartPanels.size(); i++) {
        JPanel panel = listOfChartPanels.get(i);
        panel.removeAll();
        final ChartPanel chartPanel = new ChartPanel(getModel().getChartOrNull(i)) {

            private static final long serialVersionUID = -6953213567063104487L;

            @Override
            public Dimension getPreferredSize() {
                return DIMENSION_CHART_PANEL_ENLARGED;
            }
        };
        chartPanel.setPopupMenu(null);
        chartPanel.setBackground(COLOR_TRANSPARENT);
        chartPanel.setOpaque(false);
        chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
        panel.add(chartPanel, BorderLayout.CENTER);

        JPanel openChartPanel = new JPanel(new GridBagLayout());
        openChartPanel.setOpaque(false);

        GridBagConstraints gbc = new GridBagConstraints();
        gbc.anchor = GridBagConstraints.CENTER;
        gbc.fill = GridBagConstraints.NONE;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;

        JButton openChartButton = new JButton(OPEN_CHART_ACTION);
        openChartButton.setOpaque(false);
        openChartButton.setContentAreaFilled(false);
        openChartButton.setBorderPainted(false);
        openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
        openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
        openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
        openChartButton.setIcon(null);
        Font font = openChartButton.getFont();
        Map attributes = font.getAttributes();
        attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
        openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

        openChartPanel.add(openChartButton, gbc);

        panel.add(openChartPanel, BorderLayout.SOUTH);
        panel.revalidate();
        panel.repaint();
    }
}

From source file:es.emergya.ui.plugins.AdminPanel.java

public AdminPanel(String t, Icon icon, Option myself, boolean canCreateNew, boolean canDelete) {
    super();/*ww  w.j a va 2 s  .c om*/
    setCanCreateNew(canCreateNew);
    setCanDelete(canDelete);
    setLayout(new SpringLayout());
    this.father = myself;
    setBackground(Color.WHITE);

    // Titulo con icono
    JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    title = new JLabel(t);
    title.setIcon(icon);
    title.setFont(LogicConstants.deriveBoldFont(12f));
    title.setBorder(new EmptyBorder(0, 10, 0, 10));
    titlePanel.add(title);
    titlePanel.setOpaque(false);
    add(titlePanel);
    Dimension d = titlePanel.getSize();
    if (icon != null)
        d.height = icon.getIconHeight();
    titlePanel.setMaximumSize(d);

    // Controles de "nuevo" "seleccionar todos" etc...
    JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEADING));
    controls.setOpaque(false);
    final boolean femenino = t.indexOf("atrulla") != -1 || t.indexOf("apa") != -1 || t.indexOf("lota") != -1
            || t.indexOf("encia") != -1;

    if (getCanCreateNew()) {
        if (femenino) {
            newButton = new JButton("Nueva", getIcon("button_nuevo"));
        } else {
            newButton = new JButton("Nuevo", getIcon("button_nuevo"));
        }
        controls.add(newButton);
    }
    if (getCanDelete()) {
        JButton selectAll = new JButton(((femenino) ? "Seleccionar Todas" : "Seleccionar Todos"),
                getIcon("button_selectall"));
        selectAll.addActionListener(this);
        controls.add(selectAll);
        deselectAll = new JButton(((femenino) ? "Deseleccionar Todas" : "Deseleccionar Todos"),
                getIcon("button_unselectall"));
        deselectAll.addActionListener(this);
        controls.add(deselectAll);
        JButton deleteAll = new JButton(((femenino) ? "Eliminar Seleccionadas" : "Eliminar Seleccionados"),
                getIcon("button_delall"));
        deleteAll.addActionListener(this);
        controls.add(deleteAll);
    }
    d = controls.getSize();
    controls.setMaximumSize(d);
    add(controls);

    // Tabla
    tablePanel = new JPanel(new BorderLayout());
    tablePanel.setOpaque(false);
    add(tablePanel);

    SpringUtilities.makeCompactGrid(this, 3, 1, 0, 0, 0, 0);
}

From source file:forge.gui.ImportDialog.java

@SuppressWarnings("serial")
public ImportDialog(final String forcedSrcDir, final Runnable onDialogClose) {
    this.forcedSrcDir = forcedSrcDir;

    _topPanel = new FPanel(new MigLayout("insets dialog, gap 0, center, wrap, fill"));
    _topPanel.setOpaque(false);//from   w w w.j  a va  2s .  com
    _topPanel.setBackgroundTexture(FSkin.getIcon(FSkinProp.BG_TEXTURE));

    isMigration = !StringUtils.isEmpty(forcedSrcDir);

    // header
    _topPanel.add(new FLabel.Builder().text((isMigration ? "Migrate" : "Import") + " profile data").fontSize(15)
            .build(), "center");

    // add some help text if this is for the initial data migration
    if (isMigration) {
        final FPanel blurbPanel = new FPanel(new MigLayout("insets panel, gap 10, fill"));
        blurbPanel.setOpaque(false);
        final JPanel blurbPanelInterior = new JPanel(
                new MigLayout("insets dialog, gap 10, center, wrap, fill"));
        blurbPanelInterior.setOpaque(false);
        blurbPanelInterior.add(new FLabel.Builder().text("<html><b>What's this?</b></html>").build(),
                "growx, w 50:50:");
        blurbPanelInterior.add(new FLabel.Builder()
                .text("<html>Over the last several years, people have had to jump through a lot of hoops to"
                        + " update to the most recent version.  We hope to reduce this workload to a point where a new"
                        + " user will find that it is fairly painless to update.  In order to make this happen, Forge"
                        + " has changed where it stores your data so that it is outside of the program installation directory."
                        + "  This way, when you upgrade, you will no longer need to import your data every time to get things"
                        + " working.  There are other benefits to having user data separate from program data, too, and it"
                        + " lays the groundwork for some cool new features.</html>")
                .build(), "growx, w 50:50:");
        blurbPanelInterior.add(
                new FLabel.Builder().text("<html><b>So where's my data going?</b></html>").build(),
                "growx, w 50:50:");
        blurbPanelInterior.add(new FLabel.Builder().text(
                "<html>Forge will now store your data in the same place as other applications on your system."
                        + "  Specifically, your personal data, like decks, quest progress, and program preferences will be"
                        + " stored in <b>" + ForgeConstants.USER_DIR
                        + "</b> and all downloaded content, such as card pictures,"
                        + " skins, and quest world prices will be under <b>" + ForgeConstants.CACHE_DIR
                        + "</b>.  If, for whatever"
                        + " reason, you need to set different paths, cancel out of this dialog, exit Forge, and find the <b>"
                        + ForgeConstants.PROFILE_TEMPLATE_FILE
                        + "</b> file in the program installation directory.  Copy or rename" + " it to <b>"
                        + ForgeConstants.PROFILE_FILE
                        + "</b> and edit the paths inside it.  Then restart Forge and use"
                        + " this dialog to move your data to the paths that you set.  Keep in mind that if you install a future"
                        + " version of Forge into a different directory, you'll need to copy this file over so Forge will know"
                        + " where to find your data.</html>")
                .build(), "growx, w 50:50:");
        blurbPanelInterior.add(new FLabel.Builder().text(
                "<html><b>Remember, your data won't be available until you complete this step!</b></html>")
                .build(), "growx, w 50:50:");

        final FScrollPane blurbScroller = new FScrollPane(blurbPanelInterior, true,
                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        blurbPanel.add(blurbScroller, "hmin 150, growy, growx, center, gap 0 0 5 5");
        _topPanel.add(blurbPanel, "gap 10 10 20 0, growy, growx, w 50:50:");
    }

    // import source widgets
    final JPanel importSourcePanel = new JPanel(new MigLayout("insets 0, gap 10"));
    importSourcePanel.setOpaque(false);
    importSourcePanel.add(new FLabel.Builder().text("Import from:").build());
    _txfSrc = new FTextField.Builder().readonly().build();
    importSourcePanel.add(_txfSrc, "pushx, growx");
    _btnChooseDir = new FLabel.ButtonBuilder().text("Choose directory...").enabled(!isMigration).build();
    final JFileChooser _fileChooser = new JFileChooser();
    _fileChooser.setMultiSelectionEnabled(false);
    _fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    _btnChooseDir.setCommand(new UiCommand() {
        @Override
        public void run() {
            // bring up a file open dialog and, if the OK button is selected, apply the filename
            // to the import source text field
            if (JFileChooser.APPROVE_OPTION == _fileChooser.showOpenDialog(JOptionPane.getRootFrame())) {
                final File f = _fileChooser.getSelectedFile();
                if (!f.canRead()) {
                    FOptionPane.showErrorDialog("Cannot access selected directory (Permission denied).");
                } else {
                    _txfSrc.setText(f.getAbsolutePath());
                }
            }
        }
    });
    importSourcePanel.add(_btnChooseDir, "h pref+8!, w pref+12!");

    // add change handler to the import source text field that starts up a
    // new analyzer.  it also interacts with the current active analyzer,
    // if any, to make sure it cancels out before the new one is initiated
    _txfSrc.getDocument().addDocumentListener(new DocumentListener() {
        boolean _analyzerActive; // access synchronized on _onAnalyzerDone
        String prevText;

        private final Runnable _onAnalyzerDone = new Runnable() {
            @Override
            public synchronized void run() {
                _analyzerActive = false;
                notify();
            }
        };

        @Override
        public void removeUpdate(final DocumentEvent e) {
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
        }

        @Override
        public void insertUpdate(final DocumentEvent e) {
            // text field is read-only, so the only time this will get updated
            // is when _btnChooseDir does it
            final String text = _txfSrc.getText();
            if (text.equals(prevText)) {
                // only restart the analyzer if the directory has changed
                return;
            }
            prevText = text;

            // cancel any active analyzer
            _cancel = true;

            if (!text.isEmpty()) {
                // ensure we don't get two instances of this function running at the same time
                _btnChooseDir.setEnabled(false);

                // re-disable the start button.  it will be enabled if the previous analyzer has
                // already successfully finished
                _btnStart.setEnabled(false);

                // we have to wait in a background thread since we can't block in the GUI thread
                final SwingWorker<Void, Void> analyzerStarter = new SwingWorker<Void, Void>() {
                    @Override
                    protected Void doInBackground() throws Exception {
                        // wait for active analyzer (if any) to quit
                        synchronized (_onAnalyzerDone) {
                            while (_analyzerActive) {
                                _onAnalyzerDone.wait();
                            }
                        }
                        return null;
                    }

                    // executes in gui event loop thread
                    @Override
                    protected void done() {
                        _cancel = false;
                        synchronized (_onAnalyzerDone) {
                            // this will populate the panel with data selection widgets
                            final _AnalyzerUpdater analyzer = new _AnalyzerUpdater(text, _onAnalyzerDone,
                                    isMigration);
                            analyzer.run();
                            _analyzerActive = true;
                        }
                        if (!isMigration) {
                            // only enable the directory choosing button if this is not a migration dialog
                            // since in that case we're permanently locked to the starting directory
                            _btnChooseDir.setEnabled(true);
                        }
                    }
                };
                analyzerStarter.execute();
            }
        }
    });
    _topPanel.add(importSourcePanel, "gaptop 20, pushx, growx");

    // prepare import selection panel (will be cleared and filled in later by an analyzer)
    _selectionPanel = new JPanel();
    _selectionPanel.setOpaque(false);
    _topPanel.add(_selectionPanel, "growx, growy, gaptop 10");

    // action button widgets
    final Runnable cleanup = new Runnable() {
        @Override
        public void run() {
            SOverlayUtils.hideOverlay();
        }
    };
    _btnStart = new FButton("Start import");
    _btnStart.setEnabled(false);
    _btnCancel = new FButton("Cancel");
    _btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            _cancel = true;
            cleanup.run();
            if (null != onDialogClose) {
                onDialogClose.run();
            }
        }
    });

    final JPanel southPanel = new JPanel(new MigLayout("ax center"));
    southPanel.setOpaque(false);
    southPanel.add(_btnStart, "center, w pref+144!, h pref+12!");
    southPanel.add(_btnCancel, "center, w pref+144!, h pref+12!, gap 72");
    _topPanel.add(southPanel, "growx");
}

From source file:org.rdv.viz.chart.ChartViz.java

/**
 * Get the component to display the channels in the header of the data panel.
 * This overides the super class implementation to deal with x vs. y plots.
 * /*  w  w w .j a v a2  s  . c  o m*/
 * @return  the component displaying the channels for the data panel
 */
@Override
protected JComponent getChannelComponent() {
    if (xyMode) {
        int remoteSeries = dataCollection.getSeriesCount() - localSeries;

        if (channels.size() == 0 && localSeries == 0) {
            return null;
        }

        JPanel titleBar = new JPanel();
        titleBar.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
        titleBar.setOpaque(false);

        if (isShowChannelsInTitle()) {
            Iterator<String> i = channels.iterator();
            while (i.hasNext()) {
                String firstChannel = i.next();
                String series = firstChannel;
                if (i.hasNext()) {
                    series += " vs. " + i.next();
                }
                titleBar.add(new ChannelTitle(series, firstChannel));
            }

            for (int j = remoteSeries; j < remoteSeries + localSeries; j++) {
                String seriesName = (String) dataCollection.getSeriesKey(j);
                titleBar.add(new LocalChannelTitle(seriesName));
            }
        }

        return titleBar;
    } else {
        return super.getChannelComponent();
    }
}

From source file:Interface.Stats.java

/**
 *
 * @param f /*  www  . j  a  v  a 2  s  . c om*/
 */
private Stats(JFrame f) {
    // On initialise les boutons
    JButton valider = new JButton("Valider");
    JButton retour = new JButton("Retour");
    JComboBox combo = new JComboBox();

    // On initialise et remplit la combobox
    combo.setPreferredSize(new Dimension(400, 30));
    combo.addItem("Nombre de patient par service");
    combo.addItem("Salaire moyen des employs");
    combo.addItem("Nombre d'intervention par mdecin");

    // On initialise les JLabels
    JLabel texte = new JLabel("Veuillez selectionner la requete  envoyer");

    // On change le bouton de forme
    valider.setPreferredSize(new Dimension(200, 30));
    valider.setOpaque(false);
    retour.setPreferredSize(new Dimension(200, 30));
    retour.setOpaque(false);

    // On initialise les Jpanels
    p1 = new JPanel();
    p1.setPreferredSize(new Dimension(600, 100));
    p1.add(texte);
    p1.setOpaque(false);

    p2 = new JPanel();
    p2.add(combo);
    p2.setOpaque(false);

    p4 = new JPanel();
    p4.add(retour);
    p4.add(valider);
    p4.setOpaque(false);

    // Gestion des boutons
    retour.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Accueil.getFenetre(f);
        }
    });

    valider.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            if (combo.getSelectedItem().equals("Nombre de patient par service")) {

                System.out.println(
                        "Nb de patients en REA : " + Connexion.getInstance().nb_malade_services("\"REA\""));
                System.out.println(
                        "Nb de patients en ORL : " + Connexion.getInstance().nb_malade_services("\"ORL\""));
                System.out.println(
                        "Nb de patients en CHG : " + Connexion.getInstance().nb_malade_services("\"CHG\""));

                //      new Camembert(f, Connexion.getInstance().nb_malade_services("\"REA\""), Connexion.getInstance().nb_malade_services("\"ORL\""), Connexion.getInstance().nb_malade_services("\"CHG\""));
                JPanel panel_camemb = Camembert.cCamembert(f,
                        Connexion.getInstance().nb_malade_services("\"REA\""),
                        Connexion.getInstance().nb_malade_services("\"ORL\""),
                        Connexion.getInstance().nb_malade_services("\"CHG\""));
                ;

                f.setContentPane(new ImagePanel(new ImageIcon("fond66.jpg").getImage())); // Met l'image en background
                f.add(p1);
                f.add(p2);
                f.add(p4);
                f.add(panel_camemb);

                f.setVisible(true);

            } else if (combo.getSelectedItem().equals("Salaire moyen des employs")) {
                JLabel jf_doc, jf_inf, jf_emp;
                JTextField jtf_doc, jtf_inf, jtf_emp;
                JPanel p5, p6, p7;

                // On initialise les JF
                jf_doc = new JLabel("Salaire moyen des docteurs");
                jf_inf = new JLabel("Salaire moyen des infirmiers");
                jf_emp = new JLabel("Salaire moyen de tous les employs");

                // On initialise les JTF
                jtf_doc = new JTextField();
                jtf_doc.setPreferredSize(new Dimension(200, 30));
                jtf_doc.setText(Float.toString(Connexion.getInstance().moyenne_salaired()) + " ");

                jtf_inf = new JTextField();
                jtf_inf.setPreferredSize(new Dimension(200, 30));
                jtf_inf.setText(Float.toString((Connexion.getInstance().moyenne_salairei())) + " ");

                jtf_emp = new JTextField();
                jtf_emp.setPreferredSize(new Dimension(160, 30));
                jtf_emp.setText(Float.toString((Connexion.getInstance().moyenne_salaire())) + " ");

                // On cre les JPanels
                p5 = new JPanel();
                p5.add(jf_doc);
                p5.add(jtf_doc);
                p5.setOpaque(false);

                p6 = new JPanel();
                p6.add(jf_inf);
                p6.add(jtf_inf);
                p6.setOpaque(false);

                p7 = new JPanel();
                p7.add(jf_emp);
                p7.add(jtf_emp);
                p7.setOpaque(false);

                f.setContentPane(new ImagePanel(new ImageIcon("fond66.jpg").getImage())); // Met l'image en background
                f.add(p1);
                f.add(p2);
                f.add(p4);
                f.add(p5);
                f.add(p6);
                f.add(p7);

                f.setVisible(true);
                f.setSize(new Dimension(600, 600));
            } else if (combo.getSelectedItem().equals("Nombre d'intervention par mdecin")) {
                ArrayList liste = null;
                try {
                    // ICI !!!!!!!!!!
                    liste = Connexion.getInstance().reporting(
                            "SELECT e.nom , COUNT(d.no_docteur) FROM hospitalisation h, docteur d , employe e WHERE (h.no_docteur= d.no_docteur) AND e.no_employe = d.no_docteur  GROUP BY e.nom");
                } catch (SQLException ex) {
                    Logger.getLogger(Stats.class.getName()).log(Level.SEVERE, null, ex);
                }
                if (liste != null) {
                    JPanel panel_camemb = Camembert.cCamembert(f, liste);

                    f.setContentPane(new ImagePanel(new ImageIcon("fond66.jpg").getImage())); // Met l'image en background
                    f.add(p1);
                    f.add(p2);
                    f.add(p4);
                    f.add(panel_camemb);

                    f.setVisible(true);
                }

            }
        }
    });
}

From source file:com.xilinx.kintex7.MainScreen.java

private Container createContentPane() {
    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.setOpaque(true);

    mainPanel = new JPanel(new BorderLayout());

    mainPanel.setBounds(0, 0, minWidth, minHeight);
    testPanel = new JPanel(new BorderLayout());

    testPanel.add(testAndStats(), BorderLayout.CENTER);

    mainPanel.add(testPanel, BorderLayout.LINE_START);

    //Make the center component big, since that's the
    //typical usage of BorderLayout.
    tabs = new JTabbedPane();

    mainPanel.add(tabs, BorderLayout.CENTER);

    tabs.add("System Monitor", pciInfo());
    tabs.add("Performance Plots", plotPanel());

    mainPanel.setOpaque(true);/*from ww  w. j av a  2  s  .c  o  m*/

    try {
        imagePanel = new ImageBackgroundPanel(blockDiagram, false);
    } catch (Exception e) {
    }
    /*imagePanel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createTitledBorder("Design Block Diagram"),
                BorderFactory.createEmptyBorder(5,5,5,5)));*/
    imagePanel.setBackground(Color.WHITE);
    imagePanel.setSize(minWidth, minHeight);

    imagePanel.setLocation(0, 0);
    imagePanel.setOpaque(true);

    final JLayeredPane layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(new Dimension(minWidth, minHeight));
    layeredPane.add(mainPanel, JLayeredPane.DEFAULT_LAYER, 0);
    layeredPane.add(imagePanel, JLayeredPane.DEFAULT_LAYER, 0);
    layeredPane.addComponentListener(new ComponentListener() {

        @Override
        public void componentResized(ComponentEvent ce) {
            mainPanel.setBounds(0, 0, Math.max(minWidth, layeredPane.getWidth()),
                    Math.max(minHeight, layeredPane.getHeight()));
            if (layeredPane.getWidth() > 1024) {
                tplotPanel.setPreferredSize(new Dimension(300, 100));
            } else {
                tplotPanel.setPreferredSize(new Dimension(200, 100));
            }
            imagePanel.setSize(mainPanel.getWidth(), mainPanel.getHeight());
            imagePanel.setLocation(0, 0);
            mainPanel.repaint();
        }

        @Override
        public void componentMoved(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void componentShown(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void componentHidden(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    // on top, but invisible initially
    imagePanel.setVisible(false);

    JPanel bpanel = new JPanel(new BorderLayout());

    final JButton button = new JButton(
            "<html><b>B<br>L<br>O<br>C<br>K<br> <br>D<br>I<br>A<br>G<br>R<br>A<br>M<br></b></html>");
    button.setToolTipText("Click here to see the block diagram");
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            adjustSelectionPanel();
        }
    });

    bpanel.add(button, BorderLayout.CENTER);

    contentPane.add(layeredPane, BorderLayout.CENTER);
    contentPane.add(button, BorderLayout.EAST);
    JLabel mLabel = new JLabel(modeText, JLabel.CENTER);
    mLabel.setFont(new Font(modeText, Font.BOLD, 15));
    contentPane.add(mLabel, BorderLayout.PAGE_START);
    return contentPane;
}

From source file:levelBuilder.DialogMaker.java

/**
 * Provides instructions for using the program.
 *//*from  w w w  .  ja va 2  s. c o m*/
private static void instructionsWindow() {
    JFrame frame = new JFrame("Instructions");
    JPanel panel = new JPanel(new GridLayout(0, 1, 0, 0));

    panel.add(new JLabel("DO NOT USE THE RIGHT CLICK MENU.", SwingConstants.LEFT));
    panel.add(new JLabel("DO NOT REMOVE NODES OR VERTICES WITH THIS GUI. EDIT THE XML FILE INSTEAD.",
            SwingConstants.LEFT));
    panel.add(new JLabel("", SwingConstants.LEFT));
    panel.add(
            new JLabel("The 'Check' button runs various checks to make sure the graph does not contain errors.",
                    SwingConstants.LEFT));
    panel.add(new JLabel("", SwingConstants.LEFT));
    panel.add(new JLabel("Transforming mode:", SwingConstants.LEFT));
    panel.add(new JLabel("Shift + click + drag to rotate", SwingConstants.LEFT));
    panel.add(new JLabel("Scroll to zoom", SwingConstants.LEFT));
    panel.add(new JLabel("Command + click + drag to to weird stretchy thing", SwingConstants.LEFT));
    panel.add(new JLabel("", SwingConstants.LEFT));
    panel.add(new JLabel("Picking mode:", SwingConstants.LEFT));
    panel.add(new JLabel("Click + drag to select multiple nodes", SwingConstants.LEFT));
    panel.add(new JLabel("Click + drag moves node or group of nodes", SwingConstants.LEFT));
    panel.add(new JLabel("Only in picking mode can you see different strategies", SwingConstants.LEFT));
    panel.add(new JLabel("New strategies will also only appear after refocusing on the main window",
            SwingConstants.LEFT));
    panel.add(new JLabel("", SwingConstants.LEFT));
    panel.add(new JLabel("Editing mode:", SwingConstants.LEFT));
    panel.add(new JLabel("Click + drag from one node to another creates an edge", SwingConstants.LEFT));
    panel.add(new JLabel("After drawing a new edge you have to click the 'new edge' button",
            SwingConstants.LEFT));
    panel.add(new JLabel("Click to add a new node", SwingConstants.LEFT));

    panel.setOpaque(true);
    frame.setContentPane(panel);
    frame.pack();
    frame.setLocation(windowWidth, verticalWindowPlacement);
    frame.setVisible(true);

    verticalWindowPlacement += frame.getBounds().height;
}