Example usage for javax.swing JCheckBox addActionListener

List of usage examples for javax.swing JCheckBox addActionListener

Introduction

In this page you can find the example usage for javax.swing JCheckBox addActionListener.

Prototype

public void addActionListener(ActionListener l) 

Source Link

Document

Adds an ActionListener to the button.

Usage

From source file:org.esa.beam.visat.toolviews.stat.HistogramPanel.java

private JPanel createOptionsPanel() {
    final JLabel numBinsLabel = new JLabel("#Bins:");
    JTextField numBinsField = new JTextField(Integer.toString(NUM_BINS_DEFAULT));
    numBinsField.setPreferredSize(new Dimension(50, numBinsField.getPreferredSize().height));
    final JCheckBox histoLogCheck = new JCheckBox("Log10 scaled bins");

    histoLogCheck.addActionListener(configChangeListener);

    bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_NUM_BINS)
            .setDescription("Set the number of bins in the histogram");
    bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_NUM_BINS)
            .setValueRange(new ValueRange(2.0, 2048.0));
    bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_NUM_BINS).setDefaultValue(NUM_BINS_DEFAULT);
    bindingContext.bind(PROPERTY_NAME_NUM_BINS, numBinsField);

    bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM)
            .setDescription("Use log-10 scaled values for computation of histogram");
    bindingContext.getPropertySet().getDescriptor(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM).setDefaultValue(false);
    bindingContext.bind(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM, histoLogCheck);
    log10HistEnablement = bindingContext.bindEnabledState(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM, true,
            new Enablement.Condition() {
                @Override/*  w ww.j a  v  a2s  .c o m*/
                public boolean evaluate(BindingContext bindingContext) {
                    return getRaster() != null && getRaster().getStx().getMaximum() > 0;
                }
            });

    PropertyChangeListener logChangeListener = new AxisControlChangeListener();

    xAxisRangeControl.getBindingContext().addPropertyChangeListener(logChangeListener);
    xAxisRangeControl.getBindingContext().getPropertySet()
            .addProperty(bindingContext.getPropertySet().getProperty(PROPERTY_NAME_LOGARITHMIC_HISTOGRAM));
    xAxisRangeControl.getBindingContext().getPropertySet()
            .addProperty(bindingContext.getPropertySet().getProperty(PROPERTY_NAME_LOG_SCALED));
    xAxisRangeControl.getBindingContext().getPropertySet().getDescriptor(PROPERTY_NAME_LOG_SCALED)
            .setDescription("Toggle whether to use a logarithmic x-axis");
    log10AxisEnablement = xAxisRangeControl.getBindingContext().bindEnabledState(PROPERTY_NAME_LOG_SCALED, true,
            new Enablement.Condition() {
                @Override
                public boolean evaluate(BindingContext bindingContext) {
                    HistogramPanelModel.HistogramConfig currentConfig = createHistogramConfig();
                    boolean hasStx = model.hasStx(currentConfig);
                    // log10 xAxis is enabled when current histogram exists and is NOT log10 scaled
                    return dataset != null && hasStx && !model.getStx(currentConfig).isLogHistogram();
                }
            });

    JPanel dataSourceOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints dataSourceOptionsConstraints = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, new JLabel(" "), dataSourceOptionsConstraints,
            "gridwidth=2,gridy=0,gridx=0,weightx=0");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, numBinsLabel, dataSourceOptionsConstraints,
            "insets.top=2,insets.left=4,gridwidth=1,gridy=1,gridx=0,weightx=1");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, numBinsField, dataSourceOptionsConstraints,
            "insets.top=0,insets.left=0,insets.right=2,gridwidth=1,gridy=1,gridx=1");
    GridBagUtils.addToPanel(dataSourceOptionsPanel, histoLogCheck, dataSourceOptionsConstraints,
            "insets.right=0,gridwidth=2,gridy=2,gridx=0");

    xAxisRangeControl.getBindingContext().bind(PROPERTY_NAME_LOG_SCALED, new JCheckBox("Log10 scaled"));
    xAxisRangeControl.getBindingContext().addPropertyChangeListener(PROPERTY_NAME_LOG_SCALED,
            new PropertyChangeListener() {
                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    ValueAxis oldAxis = chart.getXYPlot().getDomainAxis();
                    ValueAxis newAxis = StatisticChartStyling.updateScalingOfAxis((Boolean) evt.getNewValue(),
                            oldAxis, true);
                    chart.getXYPlot().setDomainAxis(newAxis);
                }
            });

    JPanel displayOptionsPanel = GridBagUtils.createPanel();
    GridBagConstraints displayOptionsConstraints = GridBagUtils
            .createConstraints("anchor=SOUTH,fill=HORIZONTAL,weightx=1");
    GridBagUtils.addToPanel(displayOptionsPanel, xAxisRangeControl.getPanel(), displayOptionsConstraints,
            "gridy=2");

    JPanel optionsPanel = GridBagUtils.createPanel();
    GridBagConstraints gbc = GridBagUtils
            .createConstraints("anchor=NORTHWEST,fill=HORIZONTAL,insets.top=2,weightx=1");
    GridBagUtils.addToPanel(optionsPanel, dataSourceOptionsPanel, gbc, "gridy=0");
    GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=1,fill=VERTICAL,weighty=1");
    GridBagUtils.addToPanel(optionsPanel, displayOptionsPanel, gbc, "gridy=2,fill=HORIZONTAL,weighty=0");
    GridBagUtils.addToPanel(optionsPanel, new JPanel(), gbc, "gridy=3,fill=VERTICAL,weighty=1");
    GridBagUtils.addToPanel(optionsPanel,
            xAxisRangeControl.getBindingContext().getBinding(PROPERTY_NAME_LOG_SCALED).getComponents()[0], gbc,
            "gridy=4");
    return optionsPanel;
}

From source file:de.mprengemann.intellij.plugin.androidicons.dialogs.IconImporter.java

private void updateExportResolutions() {
    final Set<Resolution> resolutions = controller.getExportResolutions();
    for (JCheckBox checkBox : Arrays.asList(LDPICheckBox, MDPICheckBox, HDPICheckBox, XHDPICheckBox,
            XXHDPICheckBox, XXXHDPICheckBox, TVDPICheckBox)) {
        checkBox.removeActionListener(resolutionActionListener);
        final Resolution resolution = ((ResolutionButtonModel) checkBox.getModel()).getResolution();
        checkBox.setSelected(resolutions.contains(resolution));
        checkBox.addActionListener(resolutionActionListener);
    }/*from  w ww .  j a va 2 s .com*/
}

From source file:net.sf.jclal.gui.view.components.chart.ExternalBasicChart.java

/**
 *
 * @return Create the menu that allows load the result from others
 * experiments./*from   w w w  .j a  va  2  s . c o  m*/
 */
private JMenu createMenu() {

    final JMenu fileMenu = new JMenu("Options");

    final JFileChooser f = new JFileChooser();
    f.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

    fileMenu.add("Add report file or directory").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (curveOptions != null) {
                curveOptions.setVisible(false);
                curveOptions = null;
            }
            int action = f.showOpenDialog(fileMenu);

            if (action == JFileChooser.APPROVE_OPTION) {

                loadReportFile(f.getSelectedFile());

            }

        }
    });

    fileMenu.add("Area under learning curve (ALC)").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            if (comboBox.getItemCount() != 0) {

                if (!comboBox.getSelectedItem().toString().isEmpty()) {

                    StringBuilder st = new StringBuilder();

                    st.append("Measure: ").append(comboBox.getSelectedItem()).append("\n\n");

                    for (int query = 0; query < queryNames.size(); query++) {

                        double value = LearningCurveUtility.getArea(evaluationsCollection.get(query),
                                comboBox.getSelectedItem().toString());

                        String valueString = String.format("%.3f", value);

                        st.append(queryNames.get(query)).append(": ").append(valueString).append("\n");

                    }

                    JOptionPane.showMessageDialog(content, st.toString(), "Area under the learning curve",
                            JOptionPane.INFORMATION_MESSAGE);
                }
            }
        }
    });

    fileMenu.add("Clear").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            queryNames = new ArrayList<String>();
            evaluationsCollection = new ArrayList<List<AbstractEvaluation>>();
            comboBox.removeAllItems();
            controlCurveColor = new HashMap<String, Color>();
            colors.clear();
            data = null;
            set.clear();
            curveOptions.setVisible(false);
            curveOptions = null;
            setSeries.clear();
            passiveEvaluation = null;

        }
    });

    fileMenu.add("Curve options").addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {

            data = informationTable();

            if (queryNames.isEmpty()) {
                JOptionPane.showMessageDialog(null, "Please add curves");
                return;
            }
            if (curveOptions == null) {
                curveOptions = new LearningCurvesVisualTable(ExternalBasicChart.this);
            } else {
                curveOptions.setVisible(true);
            }

        }

    });

    final JCheckBox viewPoints = new JCheckBox("View points's shapes");
    viewPoints.setSelected(false);

    viewPoints.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            viewPointsForm = viewPoints.isSelected();
            jComboBoxItemStateChanged();
        }
    });

    fileMenu.add(viewPoints);

    final JCheckBox withOutColor = new JCheckBox("View without color");
    withOutColor.setSelected(false);

    withOutColor.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            viewWithOutColor = withOutColor.isSelected();
            jComboBoxItemStateChanged();
        }
    });

    fileMenu.add(withOutColor);

    return fileMenu;
}

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

public RecursoDialog(final Recurso rec, final AdminResources adminResources) {
    super();/*  ww  w.j  a v a  2s.  c  om*/
    setAlwaysOnTop(true);
    setSize(600, 400);

    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            if (cambios) {
                int res = JOptionPane.showConfirmDialog(RecursoDialog.this,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION);
                if (res != JOptionPane.CANCEL_OPTION) {
                    e.getWindow().dispose();
                }
            } else {
                e.getWindow().dispose();
            }
        }
    });
    final Recurso r = (rec == null) ? null : RecursoConsultas.get(rec.getId());
    if (r != null) {
        setTitle(i18n.getString("Resources.summary.titleWindow") + " " + r.getIdentificador());
    } else {
        setTitle(i18n.getString("Resources.summary.titleWindow.new"));
    }
    setIconImage(getBasicWindow().getFrame().getIconImage());
    JPanel base = new JPanel();
    base.setBackground(Color.WHITE);
    base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS));

    // Icono del titulo
    JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING));
    title.setOpaque(false);
    JLabel labelTitulo = null;
    if (r != null) {
        labelTitulo = new JLabel(i18n.getString("Resources.summary"),
                LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);

    } else {
        labelTitulo = new JLabel(i18n.getString("Resources.cabecera.nuevo"),
                LogicConstants.getIcon("tittleficha_icon_recurso"), JLabel.LEFT);

    }
    labelTitulo.setFont(LogicConstants.deriveBoldFont(12f));
    title.add(labelTitulo);
    base.add(title);

    // Nombre
    JPanel mid = new JPanel(new SpringLayout());
    mid.setOpaque(false);
    mid.add(new JLabel(i18n.getString("Resources.name"), JLabel.RIGHT));
    final JTextField name = new JTextField(25);
    if (r != null) {
        name.setText(r.getNombre());
    }

    name.getDocument().addDocumentListener(changeListener);
    name.setEditable(r == null);
    mid.add(name);

    // patrullas
    final JLabel labelSquads = new JLabel(i18n.getString("Resources.squad"), JLabel.RIGHT);
    mid.add(labelSquads);
    List<Patrulla> pl = PatrullaConsultas.getAll();
    pl.add(0, null);
    final JComboBox squads = new JComboBox(pl.toArray());
    squads.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXXXXXXXXX");
    squads.addActionListener(changeSelectionListener);
    squads.setOpaque(false);
    labelSquads.setLabelFor(squads);
    if (r != null) {
        squads.setSelectedItem(r.getPatrullas());
    } else {
        squads.setSelectedItem(null);
    }
    squads.setEnabled((r != null && r.getHabilitado() != null) ? r.getHabilitado() : true);
    mid.add(squads);

    // // Identificador
    // mid.setOpaque(false);
    // mid.add(new JLabel(i18n.getString("Resources.identificador"),
    // JLabel.RIGHT));
    // final JTextField identificador = new JTextField("");
    // if (r != null) {
    // identificador.setText(r.getIdentificador());
    // }
    // identificador.getDocument().addDocumentListener(changeListener);
    // identificador.setEditable(r == null);
    // mid.add(identificador);
    // Espacio en blanco
    // mid.add(Box.createHorizontalGlue());
    // mid.add(Box.createHorizontalGlue());

    // Tipo
    final JLabel labelTipoRecursos = new JLabel(i18n.getString("Resources.type"), JLabel.RIGHT);
    mid.add(labelTipoRecursos);
    final JComboBox types = new JComboBox(RecursoConsultas.getTipos());
    labelTipoRecursos.setLabelFor(types);
    types.addActionListener(changeSelectionListener);
    if (r != null) {
        types.setSelectedItem(r.getTipo());
    } else {
        types.setSelectedItem(0);
    }
    // types.setEditable(true);
    types.setEnabled(true);
    mid.add(types);

    // Estado Eurocop
    mid.add(new JLabel(i18n.getString("Resources.status"), JLabel.RIGHT));
    final JTextField status = new JTextField();
    if (r != null && r.getEstadoEurocop() != null) {
        status.setText(r.getEstadoEurocop().getIdentificador());
    }
    status.setEditable(false);
    mid.add(status);

    // Subflota y patrulla
    mid.add(new JLabel(i18n.getString("Resources.subfleet"), JLabel.RIGHT));
    final JComboBox subfleets = new JComboBox(FlotaConsultas.getAllHabilitadas());
    subfleets.addActionListener(changeSelectionListener);
    if (r != null) {
        subfleets.setSelectedItem(r.getFlotas());
    } else {
        subfleets.setSelectedIndex(0);
    }
    subfleets.setEnabled(true);
    subfleets.setOpaque(false);
    mid.add(subfleets);

    // Referencia humana
    mid.add(new JLabel(i18n.getString("Resources.incidences"), JLabel.RIGHT));
    final JTextField rhumana = new JTextField();
    // if (r != null && r.getIncidencias() != null) {
    // rhumana.setText(r.getIncidencias().getReferenciaHumana());
    // }
    rhumana.setEditable(false);
    mid.add(rhumana);

    // dispositivo
    mid.add(new JLabel(i18n.getString("Resources.device"), JLabel.RIGHT));
    final PlainDocument plainDocument = new PlainDocument() {

        private static final long serialVersionUID = 4929271093724956016L;

        @Override
        public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
            if (this.getLength() + str.length() <= LogicConstants.LONGITUD_ISSI) {
                super.insertString(offs, str, a);
            }
        }
    };
    final JTextField issi = new JTextField(plainDocument, "", LogicConstants.LONGITUD_ISSI);
    plainDocument.addDocumentListener(changeListener);
    issi.setEditable(true);
    mid.add(issi);
    mid.add(new JLabel(i18n.getString("Resources.enabled"), JLabel.RIGHT));
    final JCheckBox enabled = new JCheckBox("", true);
    enabled.addActionListener(changeSelectionListener);
    enabled.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            if (enabled.isSelected()) {
                squads.setSelectedIndex(0);
            }
            squads.setEnabled(enabled.isSelected());
        }
    });
    enabled.setEnabled(true);
    enabled.setOpaque(false);
    if (r != null) {
        enabled.setSelected(r.getHabilitado());
    } else {
        enabled.setSelected(true);
    }
    if (r != null && r.getDispositivo() != null) {
        issi.setText(
                StringUtils.leftPad(String.valueOf(r.getDispositivo()), LogicConstants.LONGITUD_ISSI, '0'));
    }

    mid.add(enabled);

    // Fecha ultimo gps
    mid.add(new JLabel(i18n.getString("Resources.lastPosition"), JLabel.RIGHT));
    JTextField lastGPS = new JTextField();
    final Date lastGPSDateForRecurso = HistoricoGPSConsultas.lastGPSDateForRecurso(r);
    if (lastGPSDateForRecurso != null) {
        lastGPS.setText(SimpleDateFormat.getDateTimeInstance().format(lastGPSDateForRecurso));
    }
    lastGPS.setEditable(false);
    mid.add(lastGPS);

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    // informacion adicional
    JPanel infoPanel = new JPanel(new SpringLayout());
    final JTextField info = new JTextField(25);
    info.getDocument().addDocumentListener(changeListener);
    infoPanel.add(new JLabel(i18n.getString("Resources.info")));
    infoPanel.add(info);
    infoPanel.setOpaque(false);
    info.setOpaque(false);
    SpringUtilities.makeCompactGrid(infoPanel, 1, 2, 6, 6, 6, 18);

    if (r != null) {
        info.setText(r.getInfoAdicional());
    } else {
        info.setText("");
    }
    info.setEditable(true);

    // Espacio en blanco
    mid.add(Box.createHorizontalGlue());
    mid.add(Box.createHorizontalGlue());

    SpringUtilities.makeCompactGrid(mid, 5, 4, 6, 6, 6, 18);
    base.add(mid);
    base.add(infoPanel);

    JPanel buttons = new JPanel();
    buttons.setOpaque(false);
    JButton accept = null;
    if (r == null) {
        accept = new JButton("Crear", LogicConstants.getIcon("button_crear"));
    } else {
        accept = new JButton("Guardar", LogicConstants.getIcon("button_save"));
    }
    accept.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                if (cambios || r == null || r.getId() == null) {
                    boolean shithappens = true;
                    if ((r == null || r.getId() == null)) { // Estamos
                        // creando
                        // uno nuevo
                        if (RecursoConsultas.alreadyExists(name.getText())) {
                            shithappens = false;
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.nombreUnico"));
                        } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils
                                .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) {
                            JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT,
                                    "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI));
                            shithappens = false;
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && LogicConstants.isNumeric(issi.getText())
                                && RecursoConsultas.alreadyExists(new Integer(issi.getText()))) {
                            shithappens = false;
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.dispositivoUnico"));
                        }
                    }
                    if (shithappens) {
                        if (name.getText().isEmpty()) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.nombreNulo"));
                        } else if (issi.getText() != null && issi.getText().length() > 0 && StringUtils
                                .trimToEmpty(issi.getText()).length() != LogicConstants.LONGITUD_ISSI) {
                            JOptionPane.showMessageDialog(RecursoDialog.this, i18n.getString(Locale.ROOT,
                                    "admin.recursos.popup.error.faltanCifras", LogicConstants.LONGITUD_ISSI));
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && LogicConstants.isNumeric(issi.getText()) && r != null && r.getId() != null
                                && RecursoConsultas.alreadyExists(new Integer(issi.getText()), r.getId())) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.issiUnico"));
                        } else if (issi.getText() != null && issi.getText().length() > 0
                                && !LogicConstants.isNumeric(issi.getText())) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noNumerico"));
                            // } else if (identificador.getText().isEmpty())
                            // {
                            // JOptionPane
                            // .showMessageDialog(
                            // RecursoDialog.this,
                            // i18n.getString("admin.recursos.popup.error.identificadorNulo"));
                        } else if (subfleets.getSelectedIndex() == -1) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noSubflota"));
                        } else if (types.getSelectedItem() == null
                                || types.getSelectedItem().toString().trim().isEmpty()) {
                            JOptionPane.showMessageDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.error.noTipo"));
                        } else {
                            int i = JOptionPane.showConfirmDialog(RecursoDialog.this,
                                    i18n.getString("admin.recursos.popup.dialogo.guardar.titulo"),
                                    i18n.getString("admin.recursos.popup.dialogo.guardar.guardar"),
                                    JOptionPane.YES_NO_CANCEL_OPTION);

                            if (i == JOptionPane.YES_OPTION) {

                                Recurso recurso = r;

                                if (r == null) {
                                    recurso = new Recurso();
                                }

                                recurso.setInfoAdicional(info.getText());
                                if (issi.getText() != null && issi.getText().length() > 0) {
                                    recurso.setDispositivo(new Integer(issi.getText()));
                                } else {
                                    recurso.setDispositivo(null);
                                }
                                recurso.setFlotas(FlotaConsultas.find(subfleets.getSelectedItem().toString()));
                                if (squads.getSelectedItem() != null && enabled.isSelected()) {
                                    recurso.setPatrullas(
                                            PatrullaConsultas.find(squads.getSelectedItem().toString()));
                                } else {
                                    recurso.setPatrullas(null);
                                }
                                recurso.setNombre(name.getText());
                                recurso.setHabilitado(enabled.isSelected());
                                // recurso.setIdentificador(identificador
                                // .getText());
                                recurso.setTipo(types.getSelectedItem().toString());
                                dispose();

                                RecursoAdmin.saveOrUpdate(recurso);
                                adminResources.refresh(null);

                                PluginEventHandler.fireChange(adminResources);
                            } else if (i == JOptionPane.NO_OPTION) {
                                dispose();
                            }
                        }
                    }
                } else {
                    log.debug("No hay cambios");
                    dispose();
                }

            } catch (Throwable t) {
                log.error("Error guardando un recurso", t);
            }
        }
    });
    buttons.add(accept);

    JButton cancelar = new JButton("Cancelar", LogicConstants.getIcon("button_cancel"));

    cancelar.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (cambios) {
                if (JOptionPane.showConfirmDialog(RecursoDialog.this,
                        "Existen cambios sin guardar. Seguro que desea cerrar la ventana?",
                        "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION) != JOptionPane.CANCEL_OPTION) {
                    dispose();
                }
            } else {
                dispose();
            }
        }
    });

    buttons.add(cancelar);

    base.add(buttons);

    getContentPane().add(base);
    setLocationRelativeTo(null);
    cambios = false;
    if (r == null) {
        cambios = true;
    }

    pack();

    int x;
    int y;

    Container myParent = getBasicWindow().getPluginContainer().getDetachedTab(0);
    Point topLeft = myParent.getLocationOnScreen();
    Dimension parentSize = myParent.getSize();

    Dimension mySize = getSize();

    if (parentSize.width > mySize.width) {
        x = ((parentSize.width - mySize.width) / 2) + topLeft.x;
    } else {
        x = topLeft.x;
    }

    if (parentSize.height > mySize.height) {
        y = ((parentSize.height - mySize.height) / 2) + topLeft.y;
    } else {
        y = topLeft.y;
    }

    setLocation(x, y);
    cambios = false;
}

From source file:cool.pandora.modeller.ui.jpanel.base.SaveBagFrame.java

private JPanel createComponents() {
    final Border border = new EmptyBorder(5, 5, 5, 5);

    final TitlePane titlePane = new TitlePane();
    initStandardCommands();//from w  w w.j  a  va2 s  .  c o m
    final JPanel pageControl = new JPanel(new BorderLayout());
    final JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("SaveBagFrame.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Define the Bag " + "settings")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);
    final JPanel contentPane = new JPanel();

    // TODO: Add bag name field
    // TODO: Add save name file selection button
    final JLabel location = new JLabel("Save in:");
    final JButton browseButton = new JButton(getMessage("bag.button.browse"));
    browseButton.addActionListener(new SaveBagAsHandler());
    browseButton.setEnabled(true);
    browseButton.setToolTipText(getMessage("bag.button.browse.help"));
    final DefaultBag bag = bagView.getBag();
    if (bag != null) {
        bagNameField = new JTextField(bag.getName());
        bagNameField.setCaretPosition(bag.getName().length());
        bagNameField.setEditable(false);
        bagNameField.setEnabled(false);
    }

    // Holey bag control
    final JLabel holeyLabel = new JLabel(bagView.getPropertyMessage("bag.label.isholey"));
    holeyLabel.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));
    final JCheckBox holeyCheckbox = new JCheckBox(bagView.getPropertyMessage("bag.checkbox" + ".isholey"));
    holeyCheckbox.setBorder(border);
    holeyCheckbox.addActionListener(new HoleyBagHandler());
    holeyCheckbox.setToolTipText(bagView.getPropertyMessage("bag.isholey.help"));

    urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label"));
    urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description"));
    urlField = new JTextField("");
    try {
        assert bag != null;
        urlField.setText(bag.getFetch().getBaseURL());
    } catch (Exception e) {
        log.error("Failed to set url label", e);
    }
    urlField.setEnabled(false);

    // TODO: Add format label
    final JLabel serializeLabel;
    serializeLabel = new JLabel(getMessage("bag.label.ispackage"));
    serializeLabel.setToolTipText(getMessage("bag.serializetype.help"));

    // TODO: Add format selection panel
    noneButton = new JRadioButton(getMessage("bag.serializetype.none"));
    noneButton.setEnabled(true);
    final AbstractAction serializeListener = new SerializeBagHandler();
    noneButton.addActionListener(serializeListener);
    noneButton.setToolTipText(getMessage("bag.serializetype.none.help"));

    zipButton = new JRadioButton(getMessage("bag.serializetype.zip"));
    zipButton.setEnabled(true);
    zipButton.addActionListener(serializeListener);
    zipButton.setToolTipText(getMessage("bag.serializetype.zip.help"));

    /*
     * tarButton = new JRadioButton(getMessage("bag.serializetype.tar"));
     * tarButton.setEnabled(true);
     * tarButton.addActionListener(serializeListener);
     * tarButton.setToolTipText(getMessage("bag.serializetype.tar.help"));
     *
     * tarGzButton = new JRadioButton(getMessage("bag.serializetype.targz"));
     * tarGzButton.setEnabled(true);
     * tarGzButton.addActionListener(serializeListener);
     * tarGzButton.setToolTipText(getMessage("bag.serializetype.targz.help"));
     *
     * tarBz2Button = new JRadioButton(getMessage("bag.serializetype.tarbz2"));
     * tarBz2Button.setEnabled(true);
     * tarBz2Button.addActionListener(serializeListener);
     * tarBz2Button.setToolTipText(getMessage("bag.serializetype.tarbz2.help"));
     */

    short mode = 2;
    if (bag != null) {
        mode = bag.getSerialMode();
    }
    if (mode == DefaultBag.NO_MODE) {
        this.noneButton.setEnabled(true);
    } else if (mode == DefaultBag.ZIP_MODE) {
        this.zipButton.setEnabled(true);
    } else {
        this.noneButton.setEnabled(true);
    }

    final ButtonGroup serializeGroup = new ButtonGroup();
    serializeGroup.add(noneButton);
    serializeGroup.add(zipButton);
    // serializeGroup.add(tarButton);
    // serializeGroup.add(tarGzButton);
    // serializeGroup.add(tarBz2Button);
    final JPanel serializeGroupPanel = new JPanel(new FlowLayout());
    serializeGroupPanel.add(serializeLabel);
    serializeGroupPanel.add(noneButton);
    serializeGroupPanel.add(zipButton);
    // serializeGroupPanel.add(tarButton);
    // serializeGroupPanel.add(tarGzButton);
    // serializeGroupPanel.add(tarBz2Button);
    serializeGroupPanel.setBorder(border);
    serializeGroupPanel.setEnabled(true);
    serializeGroupPanel.setToolTipText(bagView.getPropertyMessage("bag.serializetype.help"));

    final JLabel tagLabel = new JLabel(getMessage("bag.label.istag"));
    tagLabel.setToolTipText(getMessage("bag.label.istag.help"));
    final JCheckBox isTagCheckbox = new JCheckBox();
    isTagCheckbox.setBorder(border);
    isTagCheckbox.addActionListener(new TagManifestHandler());
    isTagCheckbox.setToolTipText(getMessage("bag.checkbox.istag.help"));

    final JLabel tagAlgorithmLabel = new JLabel(getMessage("bag.label.tagalgorithm"));
    tagAlgorithmLabel.setToolTipText(getMessage("bag.label.tagalgorithm.help"));
    final ArrayList<String> listModel = new ArrayList<>();
    for (final Algorithm algorithm : Algorithm.values()) {
        listModel.add(algorithm.bagItAlgorithm);
    }
    final JComboBox<String> tagAlgorithmList = new JComboBox<>(listModel.toArray(new String[listModel.size()]));
    tagAlgorithmList.setName(getMessage("bag.tagalgorithmlist"));
    tagAlgorithmList.addActionListener(new TagAlgorithmListHandler());
    tagAlgorithmList.setToolTipText(getMessage("bag.tagalgorithmlist.help"));

    final JLabel payloadLabel = new JLabel(getMessage("bag.label.ispayload"));
    payloadLabel.setToolTipText(getMessage("bag.ispayload.help"));
    final JCheckBox isPayloadCheckbox = new JCheckBox();
    isPayloadCheckbox.setBorder(border);
    isPayloadCheckbox.addActionListener(new PayloadManifestHandler());
    isPayloadCheckbox.setToolTipText(getMessage("bag.ispayload.help"));

    final JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label" + ".payalgorithm"));
    payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help"));
    final JComboBox<String> payAlgorithmList = new JComboBox<String>(
            listModel.toArray(new String[listModel.size()]));
    payAlgorithmList.setName(getMessage("bag.payalgorithmlist"));
    payAlgorithmList.addActionListener(new PayAlgorithmListHandler());
    payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help"));

    //only if bag is not null
    if (bag != null) {
        final String fileName = bag.getName();
        bagNameField = new JTextField(fileName);
        bagNameField.setCaretPosition(fileName.length());

        holeyCheckbox.setSelected(bag.isHoley());
        urlLabel.setEnabled(bag.isHoley());
        isTagCheckbox.setSelected(bag.isBuildTagManifest());
        tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm());
        isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest());
        payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm());
    }

    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints glbc = new GridBagConstraints();
    final JPanel panel = new JPanel(layout);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    int row = 0;

    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(location, glbc);
    panel.add(location);

    buildConstraints(glbc, 2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST);
    glbc.ipadx = 5;
    layout.setConstraints(browseButton, glbc);
    glbc.ipadx = 0;
    panel.add(browseButton);

    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    glbc.ipadx = 5;
    layout.setConstraints(bagNameField, glbc);
    glbc.ipadx = 0;
    panel.add(bagNameField);

    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(holeyLabel, glbc);
    panel.add(holeyLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.WEST, GridBagConstraints.WEST);
    layout.setConstraints(holeyCheckbox, glbc);
    panel.add(holeyCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(urlLabel, glbc);
    panel.add(urlLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(urlField, glbc);
    panel.add(urlField);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(serializeLabel, glbc);
    panel.add(serializeLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    layout.setConstraints(serializeGroupPanel, glbc);
    panel.add(serializeGroupPanel);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagLabel, glbc);
    panel.add(tagLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isTagCheckbox, glbc);
    panel.add(isTagCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(tagAlgorithmLabel, glbc);
    panel.add(tagAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(tagAlgorithmList, glbc);
    panel.add(tagAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payloadLabel, glbc);
    panel.add(payloadLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(isPayloadCheckbox, glbc);
    panel.add(isPayloadCheckbox);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(payAlgorithmLabel, glbc);
    panel.add(payAlgorithmLabel);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(payAlgorithmList, glbc);
    panel.add(payAlgorithmList);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);

    GuiStandardUtils.attachDialogBorder(contentPane);
    pageControl.add(panel);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}

From source file:jchrest.gui.VisualSearchPane.java

private JPanel constructButtons() {

    Box buttons = Box.createVerticalBox();
    JSpinner numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1));

    JPanel labelledSpinner = new JPanel();
    labelledSpinner.setLayout(new GridLayout(1, 2));
    labelledSpinner.add(new JLabel("Number of fixations: "));
    labelledSpinner.add(numFixations);/*from   w ww. ja  v a 2 s .  c  o m*/

    JButton recallButton = new JButton(new RecallAction(numFixations));
    recallButton.setToolTipText("Scan shown scene and display results");

    final JCheckBox showFixations = new JCheckBox("Show fixations", false);
    showFixations.setToolTipText("Show fixations for recalled scene");
    showFixations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            _sceneDisplay.setShowFixations(showFixations.isSelected());
        }
    });

    buttons.add(Box.createRigidArea(new Dimension(0, 20)));
    buttons.add(labelledSpinner);
    buttons.add(recallButton);
    buttons.add(Box.createRigidArea(new Dimension(0, 20)));
    buttons.add(showFixations);
    buttons.add(Box.createRigidArea(new Dimension(0, 20)));

    // TODO: There must be a better solution to this problem!
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(buttons, BorderLayout.NORTH);

    return panel;
}

From source file:com.rapidminer.gui.graphs.GraphViewer.java

private JComponent createControlPanel() {
    // === mouse behaviour ===
    if (graphMouse != null) {
        vv.setGraphMouse(graphMouse);//from  w  ww  .  ja  v  a2  s . co m
        vv.addKeyListener(graphMouse.getModeKeyListener());
        graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    }
    transformAction.setEnabled(false);
    pickingAction.setEnabled(true);

    vv.addGraphMouseListener(new GraphMouseListener<V>() {

        @Override
        public void graphClicked(V vertex, MouseEvent arg1) {
        }

        @Override
        public void graphPressed(V arg0, MouseEvent arg1) {
        }

        @Override
        public void graphReleased(V vertex, MouseEvent arg1) {
            if (currentMode.equals(ModalGraphMouse.Mode.TRANSFORMING)) {
                if (graphCreator.getObjectViewer() != null) {
                    vv.getPickedVertexState().clear();
                    vv.getPickedVertexState().pick(vertex, true);
                    graphCreator.getObjectViewer().showObject(graphCreator.getObject(vertex));
                }
            }
        }
    });

    JPanel controls = new JPanel();
    GridBagLayout gbLayout = new GridBagLayout();
    controls.setLayout(gbLayout);
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(4, 4, 4, 4);
    c.weightx = 1;
    c.weighty = 0;

    // zooming
    JToolBar zoomBar = new ExtendedJToolBar();
    zoomBar.setLayout(new FlowLayout(FlowLayout.CENTER));
    zoomBar.add(new ZoomInAction(this, IconSize.SMALL));
    zoomBar.add(new ZoomOutAction(this, IconSize.SMALL));
    zoomBar.setBorder(BorderFactory.createTitledBorder("Zoom"));
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(zoomBar, c);
    controls.add(zoomBar);

    // mode
    JToolBar modeBar = new ExtendedJToolBar();
    modeBar.setLayout(new FlowLayout(FlowLayout.CENTER));
    modeBar.add(transformAction);
    modeBar.add(pickingAction);
    modeBar.setBorder(BorderFactory.createTitledBorder("Mode"));
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(modeBar, c);
    controls.add(modeBar);

    // layout selection
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(layoutSelection, c);
    controls.add(layoutSelection);

    // show node labels
    JCheckBox nodeLabels = new JCheckBox("Node Labels", graphCreator.showVertexLabelsDefault());
    nodeLabels.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            togglePaintVertexLabels();
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(nodeLabels, c);
    controls.add(nodeLabels);

    // show edge labels
    JCheckBox edgeLabels = new JCheckBox("Edge Labels", graphCreator.showEdgeLabelsDefault());
    edgeLabels.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            togglePaintEdgeLabels();
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(edgeLabels, c);
    controls.add(edgeLabels);

    // option components
    for (int i = 0; i < graphCreator.getNumberOfOptionComponents(); i++) {
        JComponent optionComponent = graphCreator.getOptionComponent(this, i);
        if (optionComponent != null) {
            c.gridwidth = GridBagConstraints.REMAINDER;
            gbLayout.setConstraints(optionComponent, c);
            controls.add(optionComponent);
        }
    }

    // save image
    JButton imageButton = new JButton("Save Image...");
    imageButton.setToolTipText("Saves an image of the current graph.");
    imageButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final Component tosave = vv;
            new ExportImageAction(false) {

                private static final long serialVersionUID = 1L;

                @Override
                protected PrintableComponent getPrintableComponent() {
                    return new SimplePrintableComponent(tosave, "Graph");
                }

            }.actionPerformed(e);
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(imageButton, c);
    controls.add(imageButton);

    // help
    JButton help = new JButton("Help");
    help.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(vv, INSTRUCTIONS);
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(help, c);
    controls.add(help);

    JPanel fillPanel = new JPanel();
    c.weighty = 1.0d;
    c.gridwidth = GridBagConstraints.REMAINDER;
    gbLayout.setConstraints(fillPanel, c);
    controls.add(fillPanel);

    return controls;
}

From source file:com.view.TradeWindow.java

private void TraderBlockOrdersActionPerformed(java.awt.event.ActionEvent evt) {
    TableModel dtm = (TableModel) TraderIncomingRequestsTable.getModel();
    int nRow = dtm.getRowCount();
    int nCol = dtm.getColumnCount();
    Object[][] tableData = new Object[nRow][nCol];
    ArrayList<SingleOrder> parsedOrders = new ArrayList();
    ControllerBlockOrders control = new ControllerBlockOrders();

    for (int i = 0; i < nRow; i++) {
        for (int j = 0; j < nCol; j++) {
            tableData[i][j] = dtm.getValueAt(i, j);
        }//from  w w w . j  av a2 s.  co m
        SingleOrder o = new SingleOrder();
        o.SingleOrderMakeBlocks(tableData[i]);
        parsedOrders.add(o);
    }
    singleOrderLists = control.MakeBlock(parsedOrders);
    showMessageDialog(null, "Blocks have been successfully completed.");
    //dtm.setRowCount(0);
    TraderPlatformBlockedRequests.setLayout(new BorderLayout());
    int count = 1;
    ArrayList<JScrollPane> paneList = new ArrayList<JScrollPane>();
    for (ArrayList<SingleOrder> b : singleOrderLists) {
        JTable jTable = new JTable();
        jTable.setModel(CTraderBlockOrder.getTableModel(b));
        Dimension d = jTable.getPreferredSize();
        // System.out.println(d);
        int rows = jTable.getRowCount();
        // System.out.println(rows);
        JScrollPane jPane = new JScrollPane();
        jPane.setPreferredSize(new Dimension(d.width, jTable.getRowHeight() * rows + 50));
        jPane.add(jTable);
        jPane.setViewportView(jTable);
        paneList.add(jPane);
        count++;
    }

    test.add(blockOptions);
    int i = 0;
    for (final JScrollPane j : paneList) {
        //   JButton btn = new JButton();
        //  btn.setText("Split Block");
        //     btn.setName(""+i);

        JPanel cPanel = new JPanel();
        /*  btn.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            JViewport viewport = j.getViewport(); 
            final JTable mytable = (JTable)viewport.getView();
            final ArrayList<Integer> index = new ArrayList<Integer>();
            for(int row = 0;row<mytable.getRowCount();row++){
                  if((boolean)mytable.getValueAt(row, 11)){
                     index.add(row);
                  }
            }
             SplitBlockActionPerformed(evt,index,cPanel,test);
         }
          });*/
        JCheckBox check = new JCheckBox();
        JLabel label = new JLabel();
        label.setText("Select Block");
        check.setName("" + i);
        check.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectBlockActionPerformed(evt);
            }
        });
        JPanel splitOptions = new JPanel();
        splitOptions.add(label);
        splitOptions.add(check);
        splitOptions.setName("splitOpt");
        //  splitOptions.add(btn);
        cPanel.setName("cPanel" + i);
        cPanel.add(splitOptions);
        cPanel.add(j);
        cPanel.setLayout(new BoxLayout(cPanel, BoxLayout.Y_AXIS));
        test.add(cPanel);
        cPanelList.add(cPanel);
        i++;
    }

    test.setLayout(new BoxLayout(test, BoxLayout.Y_AXIS));
    JScrollPane p = new JScrollPane(test);
    p.setName("ParentP");
    TraderPlatformBlockedRequests.add(p);
    TraderPlatformBlockedRequests.validate();
    TraderPlatformTabbedPane.setSelectedIndex(TraderPlatformTabbedPane.getSelectedIndex() + 1);

}

From source file:com.diversityarrays.kdxplore.scatterplot.ScatterPlotPanel.java

@SuppressWarnings("unused")
private JPanel getControlPanel() {

    List<String> pList = Arrays.asList(Msg.CBOX_MEAN(), Msg.CBOX_MEDIAN(), Msg.CBOX_OUTLIERS());
    JPanel cPanel = new JPanel();
    for (String s : pList) {
        ActionListener checkBoxActionListener = new ActionListener() {
            @Override/*from   w ww.j  a v  a2s .c  o m*/
            public void actionPerformed(ActionEvent e) {
                redoGenerateChart(s, false);
            }
        };
        JCheckBox jcb = new JCheckBox(s);
        jcb.setSelected(true);
        jcb.addActionListener(checkBoxActionListener);
        parameters.put(s, jcb);
        cPanel.add(jcb, BorderLayout.CENTER);
    }

    return cPanel;
}

From source file:logdruid.ui.chart.GraphPanel.java

public void loadGroupCheckbox(final JPanel panel_2) {
    panel_1.removeAll();//from w  w  w. ja v a  2 s  .co  m
    //Iterator mineResultSetIterator = mineResultSet.mineResults.entrySet().iterator();

    Map<Source, Map<String, MineResult>> treeMap = new TreeMap<Source, Map<String, MineResult>>(
            mineResultSet.mineResults);
    Iterator mineResultSetIterator = treeMap.entrySet().iterator();

    logger.debug("mineResultSet size: " + mineResultSet.mineResults.size());
    while (mineResultSetIterator.hasNext()) {

        int groupCount = 0;
        int totalGroupCount = 0;
        Map.Entry pairs = (Map.Entry) mineResultSetIterator.next();
        Map mrArrayList = (Map<String, MineResult>) pairs.getValue();
        ArrayList<String> mineResultGroup = new ArrayList<String>();
        Set<String> mrss = mrArrayList.keySet();
        mineResultGroup.addAll(mrss);
        Collections.sort(mineResultGroup, new AlphanumComparator());

        Iterator mrArrayListIterator = mineResultGroup.iterator();
        while (mrArrayListIterator.hasNext()) {
            String key = (String) mrArrayListIterator.next();
            final MineResult mr = (MineResult) mrArrayList.get(key);
            Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap();
            Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap();
            if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) {
                if (mr.getStartDate() != null && mr.getEndDate() != null) {
                    if ((mr.getStartDate().before((Date) endDateJSPinner.getValue()))
                            && (mr.getEndDate().after((Date) startDateJSpinner.getValue()))) {
                        groupCount++;
                    }
                }
            }
        }
        Iterator mrArrayListIterator2 = mineResultGroup.iterator();
        while (mrArrayListIterator2.hasNext()) {
            String key = (String) mrArrayListIterator2.next();
            final MineResult mr = (MineResult) mrArrayList.get(key);
            Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap();
            Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap();
            if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) {
                if (mr.getStartDate() != null && mr.getEndDate() != null) {
                    if ((mr.getStartDate().before((Date) maximumDate))
                            && (mr.getEndDate().after((Date) minimumDate))) {
                        totalGroupCount++;
                    }
                }
            }
        }
        boolean selected = true;
        if (groupCheckBox.containsKey(((Source) pairs.getKey()).getSourceName())) {
            selected = groupCheckBox.get(((Source) pairs.getKey()).getSourceName());
        } else {
            groupCheckBox.put(((Source) pairs.getKey()).getSourceName(), selected);

        }

        JCheckBox chckbxGroup = new JCheckBox(
                ((Source) pairs.getKey()).getSourceName() + "(" + groupCount + "/" + totalGroupCount + ")");
        chckbxGroup.setFont(new Font("Dialog", Font.BOLD, 11));
        chckbxGroup.setSelected(selected);
        panel_1.add(chckbxGroup);
        chckbxGroup.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JCheckBox chkBox = ((JCheckBox) e.getSource());
                groupCheckBox.put(
                        (String) chkBox.getText().substring(0, ((String) chkBox.getText()).indexOf("(")),
                        !groupCheckBox.get((String) chkBox.getText().substring(0,
                                ((String) chkBox.getText()).indexOf("("))));
                loadGroupCheckbox(panel_2);
                load(panel_2);
                //logger.info("checkBox:"+ chkBox.getText()+","+chkBox.isSelected()+","+groupCheckBox);
                //logger.info("checkBox2:"+((String)chkBox.getText())+", "+((String)chkBox.getText()).indexOf("(")+", "+groupCheckBox.get((String)chkBox.getText().substring(0, ((String)chkBox.getText()).indexOf("(")))); 
            }
        });
    }
}