Example usage for javax.swing JPanel setBackground

List of usage examples for javax.swing JPanel setBackground

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

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

private ConsultaHistoricos(CustomMapView mapView) {
    super("Consulta de Posiciones GPS");
    setResizable(false);// ww  w  .  j av a  2s.  c  o  m
    setAlwaysOnTop(true);
    this.mapView = mapView;
    this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    this.setIconImage(getBasicWindow().getIconImage());

    dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    // explicitly set timezone of input if needed
    dateFormat.setTimeZone(java.util.TimeZone.getTimeZone("Zulu"));

    JPanel dialogo = new JPanel(new BorderLayout());
    dialogo.setBackground(Color.WHITE);
    dialogo.setBorder(new EmptyBorder(10, 10, 10, 10));

    dialogo.add(getCabecera(), BorderLayout.NORTH);
    dialogo.add(getCentral(), BorderLayout.CENTER);
    dialogo.add(getBotones(), BorderLayout.SOUTH);

    add(dialogo);
    setPreferredSize(new Dimension(430, 440));
    pack();
    setLocationRelativeTo(mapView);
    getLimpiar().doClick();

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            closing.actionPerformed(null);
        }
    });
}

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

public void load(JPanel panel_2) {
    startDateJSpinner = (JSpinner) panel_2.getComponent(2);
    endDateJSPinner = (JSpinner) panel_2.getComponent(3);
    // scrollPane.setV
    panel.removeAll();/* ww w. j a  va2 s.co  m*/
    Dimension panelSize = this.getSize();
    add(scrollPane, BorderLayout.CENTER);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    // scrollPane.set trying to replace scroll where it was
    JCheckBox relativeCheckBox = (JCheckBox) panel_2.getComponent(5);
    estimatedTime = System.currentTimeMillis() - startTime;
    logger.info("gathering time: " + estimatedTime);
    startTime = System.currentTimeMillis();
    //   Map<Source, Map<String, MineResult>>
    Map<Source, Map<String, MineResult>> treeMap = new TreeMap<Source, Map<String, MineResult>>(
            mineResultSet.mineResults);
    Iterator mineResultSetIterator = treeMap.entrySet().iterator();
    int ite = 0;
    logger.debug("mineResultSet size: " + mineResultSet.mineResults.size());
    while (mineResultSetIterator.hasNext()) {
        final Map.Entry pairs = (Map.Entry) mineResultSetIterator.next();
        logger.debug("mineResultSet key/source: " + ((Source) pairs.getKey()).getSourceName());
        JCheckBox checkBox = (JCheckBox) panel_1.getComponent(ite++);
        logger.debug("checkbox: " + checkBox.getText() + ", " + checkBox.isSelected());
        if (checkBox.isSelected()) {

            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();
                logger.debug(key);
                final MineResult mr = (MineResult) mrArrayList.get(key);
                Map<String, ExtendedTimeSeries> statMap = mr.getStatTimeseriesMap();
                Map<String, ExtendedTimeSeries> eventMap = mr.getEventTimeseriesMap();
                // logger.info("mineResultSet hash size: "
                // +mr.getTimeseriesMap().size());
                // logger.info("mineResultSet hash content: " +
                // mr.getStatTimeseriesMap());
                logger.debug("mineResultSet mr.getStartDate(): " + mr.getStartDate()
                        + " mineResultSet mr.getEndDate(): " + mr.getEndDate());
                logger.debug("mineResultSet (Date)jsp.getValue(): " + (Date) startDateJSpinner.getValue());
                logger.debug("mineResultSet (Date)jsp2.getValue(): " + (Date) endDateJSPinner.getValue());
                if (mr.getStartDate() != null && mr.getEndDate() != null) {
                    if ((mr.getStartDate().before((Date) endDateJSPinner.getValue()))
                            && (mr.getEndDate().after((Date) startDateJSpinner.getValue()))) {

                        ArrayList<String> mineResultGroup2 = new ArrayList<String>();
                        Set<String> mrss2 = statMap.keySet();
                        mineResultGroup2.addAll(mrss2);
                        Collections.sort(mineResultGroup2, new AlphanumComparator());
                        Iterator statMapIterator = mineResultGroup2.iterator();

                        //            Iterator statMapIterator = statMap.entrySet().iterator();
                        if (!statMap.entrySet().isEmpty() || !eventMap.entrySet().isEmpty()) {
                            JPanel checkboxPanel = new JPanel(new WrapLayout());

                            checkboxPanel.setBackground(Color.white);

                            int count = 1;
                            chart = ChartFactory.createXYAreaChart(// Title
                                    mr.getSourceID() + " " + mr.getGroup(), // +
                                    null, // X-Axis
                                    // label
                                    null, // Y-Axis label
                                    null, // Dataset
                                    PlotOrientation.VERTICAL, false, // Show
                                    // legend
                                    true, // tooltips
                                    false // url
                            );
                            TextTitle my_Chart_title = new TextTitle(mr.getSourceID() + " " + mr.getGroup(),
                                    new Font("Verdana", Font.BOLD, 17));
                            chart.setTitle(my_Chart_title);
                            XYPlot plot = (XYPlot) chart.getPlot();
                            ValueAxis range = plot.getRangeAxis();
                            range.setVisible(false);

                            final DateAxis domainAxis1 = new DateAxis();
                            domainAxis1.setTickLabelsVisible(true);
                            // domainAxis1.setTickMarksVisible(true);

                            logger.debug("getRange: " + domainAxis1.getRange());
                            if (relativeCheckBox.isSelected()) {
                                domainAxis1.setRange((Date) startDateJSpinner.getValue(),
                                        (Date) endDateJSPinner.getValue());
                            } else {
                                Date startDate = mr.getStartDate();
                                Date endDate = mr.getEndDate();
                                if (mr.getStartDate().before((Date) startDateJSpinner.getValue())) {
                                    startDate = (Date) startDateJSpinner.getValue();
                                    logger.debug("setMinimumDate: " + (Date) startDateJSpinner.getValue());
                                }
                                if (mr.getEndDate().after((Date) endDateJSPinner.getValue())) {
                                    endDate = (Date) endDateJSPinner.getValue();
                                    logger.debug("setMaximumDate: " + (Date) endDateJSPinner.getValue());
                                }
                                if (startDate.before(endDate)) {
                                    domainAxis1.setRange(startDate, endDate);
                                }
                            }
                            XYToolTipGenerator tt1 = new XYToolTipGenerator() {
                                public String generateToolTip(XYDataset dataset, int series, int item) {
                                    StringBuffer sb = new StringBuffer();
                                    String htmlStr = "<html>";
                                    Number x;
                                    FastDateFormat sdf = FastDateFormat.getInstance("dd-MMM-yyyy HH:mm:ss");
                                    x = dataset.getX(series, item);
                                    sb.append(htmlStr);
                                    if (x != null) {
                                        sb.append("<p style='color:#000000;'>" + (sdf.format(x)) + "</p>");
                                        sb.append("<p style='color:#000000;'>"
                                                + dataset.getSeriesKey(series).toString() + ": "
                                                + form.format(dataset.getYValue(0, item)) + "</p>");
                                        if (mr.getFileLineForDate(new Date(x.longValue()),
                                                dataset.getSeriesKey(series).toString()) != null) {
                                            sb.append(
                                                    "<p style='color:#0000FF;'>"
                                                            + cd.sourceFileArrayListMap
                                                                    .get(pairs.getKey()).get(mr
                                                                            .getFileLineForDate(
                                                                                    new Date(x.longValue()),
                                                                                    dataset.getSeriesKey(series)
                                                                                            .toString())
                                                                            .getFileId())
                                                                    .getFile().getName()
                                                            + ":"
                                                            + mr.getFileLineForDate(new Date(x.longValue()),
                                                                    dataset.getSeriesKey(series).toString())
                                                                    .getLineNumber()
                                                            + "</p>");

                                        }
                                    }
                                    return sb.toString();
                                }
                            };

                            while (statMapIterator.hasNext()) {

                                TimeSeriesCollection dataset = new TimeSeriesCollection();
                                String me = (String) statMapIterator.next();

                                ExtendedTimeSeries ts = (ExtendedTimeSeries) statMap.get(me);
                                // logger.info(((TimeSeries)
                                // me.getValue()).getMaxY());
                                if (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY() > 0)
                                    dataset.addSeries(ts.getTimeSeries());
                                logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me
                                        + " nb records: " + ((ExtendedTimeSeries) statMap.get(me))
                                                .getTimeSeries().getItemCount());
                                logger.debug("(((TimeSeries) me.getValue()).getMaxY(): "
                                        + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY()));
                                logger.debug("(((TimeSeries) me.getValue()).getMinY(): "
                                        + (((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY()));
                                XYPlot plot1 = chart.getXYPlot();
                                //   LogarithmicAxis axis4 = new LogarithmicAxis(me.toString());
                                NumberAxis axis4 = new NumberAxis(me.toString());
                                axis4.setAutoRange(true);
                                axis4.setAxisLineVisible(true);
                                axis4.setAutoRangeIncludesZero(false);
                                plot1.setDomainCrosshairVisible(true);
                                plot1.setRangeCrosshairVisible(true);
                                axis4.setRange(new Range(
                                        ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMinY(),
                                        ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY()));
                                axis4.setLabelPaint(colors[count]);
                                axis4.setTickLabelPaint(colors[count]);
                                plot1.setRangeAxis(count, axis4);
                                final ValueAxis domainAxis = domainAxis1;
                                domainAxis.setLowerMargin(0.0);
                                domainAxis.setUpperMargin(0.0);
                                plot1.setDomainAxis(domainAxis);
                                plot1.setForegroundAlpha(0.5f);
                                plot1.setDataset(count, dataset);
                                plot1.mapDatasetToRangeAxis(count, count);
                                final XYAreaRenderer renderer = new XYAreaRenderer(); // XYAreaRenderer2
                                // also
                                // nice
                                if ((((ExtendedTimeSeries) statMap.get(me)).getTimeSeries().getMaxY()
                                        - ((ExtendedTimeSeries) statMap.get(me)).getTimeSeries()
                                                .getMinY()) > 0) {

                                    // renderer.setToolTipGenerator(new
                                    // StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,new
                                    // FastDateFormat("d-MMM-yyyy HH:mm:ss"),
                                    // new DecimalFormat("#,##0.00")));
                                }
                                renderer.setSeriesPaint(0, colors[count]);
                                renderer.setSeriesVisible(0, true);
                                renderer.setSeriesToolTipGenerator(0, tt1);
                                plot1.setRenderer(count, renderer);
                                int hits = 0; // ts.getStat()[1]
                                int matchs = 0;
                                if (((ExtendedTimeSeries) statMap.get(me)).getStat() != null) {
                                    hits = ((ExtendedTimeSeries) statMap.get(me)).getStat()[1];
                                    //   matchs= ((ExtendedTimeSeries) statMap.get(me)).getStat()[0];
                                }
                                JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4,
                                        me.toString() + "(" + hits + ")", 0));
                                Boolean selected = true;
                                jcb.setSelected(true);
                                jcb.setBackground(Color.white);
                                jcb.setBorderPainted(true);
                                jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true));
                                jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(),
                                        oldSmallFont.getSize()));
                                checkboxPanel.add(jcb);
                                count++;
                            }
                            Iterator eventMapIterator = eventMap.entrySet().iterator();
                            while (eventMapIterator.hasNext()) {

                                //   HistogramDataset histoDataSet=new HistogramDataset();

                                TimeSeriesCollection dataset = new TimeSeriesCollection();
                                Map.Entry me = (Map.Entry) eventMapIterator.next();
                                // if (dataset.getEndXValue(series, item))
                                if (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY() > 0)
                                    dataset.addSeries(((ExtendedTimeSeries) me.getValue()).getTimeSeries());

                                logger.debug("mineResultSet group: " + mr.getGroup() + ", key: " + me.getKey()
                                        + " nb records: "
                                        + ((ExtendedTimeSeries) me.getValue()).getTimeSeries().getItemCount());
                                logger.debug("mineResultSet hash content: " + mr.getEventTimeseriesMap());
                                logger.debug("(((TimeSeries) me.getValue()).getMaxY(): "
                                        + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMaxY()));
                                logger.debug("(((TimeSeries) me.getValue()).getMinY(): "
                                        + (((ExtendedTimeSeries) me.getValue()).getTimeSeries().getMinY()));
                                XYPlot plot2 = chart.getXYPlot();
                                //   LogarithmicAxis axis4 = new LogarithmicAxis(me.toString());
                                NumberAxis axis4 = new NumberAxis(me.getKey().toString());
                                axis4.setAutoRange(true);
                                // axis4.setInverted(true);
                                axis4.setAxisLineVisible(true);
                                axis4.setAutoRangeIncludesZero(true);

                                // axis4.setRange(new Range(((TimeSeries)
                                // axis4.setRange(new Range(((TimeSeries)
                                // me.getValue()).getMinY(), ((TimeSeries)
                                // me.getValue()).getMaxY()));
                                axis4.setLabelPaint(colors[count]);
                                axis4.setTickLabelPaint(colors[count]);
                                plot2.setRangeAxis(count, axis4);
                                final ValueAxis domainAxis = domainAxis1;

                                // domainAxis.setLowerMargin(0.001);
                                // domainAxis.setUpperMargin(0.0);
                                plot2.setDomainCrosshairVisible(true);
                                plot2.setRangeCrosshairVisible(true);
                                //plot2.setRangeCrosshairLockedOnData(true);
                                plot2.setDomainAxis(domainAxis);
                                plot2.setForegroundAlpha(0.5f);
                                plot2.setDataset(count, dataset);
                                plot2.mapDatasetToRangeAxis(count, count);
                                XYBarRenderer rend = new XYBarRenderer(); // XYErrorRenderer

                                rend.setShadowVisible(false);
                                rend.setDrawBarOutline(true);
                                Stroke stroke = new BasicStroke(5);
                                rend.setBaseStroke(stroke);
                                final XYItemRenderer renderer = rend;
                                renderer.setSeriesToolTipGenerator(0, tt1);
                                // renderer.setItemLabelsVisible(true);
                                renderer.setSeriesPaint(0, colors[count]);
                                renderer.setSeriesVisible(0, true);
                                plot2.setRenderer(count, renderer);
                                int hits = 0;
                                int matchs = 0;

                                if (((ExtendedTimeSeries) me.getValue()).getStat() != null) {
                                    hits = ((ExtendedTimeSeries) me.getValue()).getStat()[1];
                                    //   matchs= ((ExtendedTimeSeries) me.getValue()).getStat()[0];
                                }
                                JCheckBox jcb = new JCheckBox(new VisibleAction(panel, checkboxPanel, axis4,
                                        me.getKey().toString() + "(" + hits + ")", 0));

                                jcb.setSelected(true);
                                jcb.setBackground(Color.white);
                                jcb.setBorderPainted(true);
                                jcb.setBorder(BorderFactory.createLineBorder(colors[count], 1, true));
                                jcb.setFont(new Font("Sans-serif", oldSmallFont.getStyle(),
                                        oldSmallFont.getSize()));
                                checkboxPanel.add(jcb);
                                count++;
                            }

                            JPanel pan = new JPanel();

                            pan.setLayout(new BorderLayout());
                            pan.setPreferredSize(new Dimension(600,
                                    Integer.parseInt((String) Preferences.getPreference("chartSize"))));
                            // pan.setPreferredSize(panelSize);
                            panel.add(pan);
                            final ChartPanel cpanel = new ChartPanel(chart);
                            cpanel.setMinimumDrawWidth(0);
                            cpanel.setMinimumDrawHeight(0);
                            cpanel.setMaximumDrawWidth(1920);
                            cpanel.setMaximumDrawHeight(1200);
                            // cpanel.setInitialDelay(0);
                            cpanel.setDismissDelay(9999999);
                            cpanel.setInitialDelay(50);
                            cpanel.setReshowDelay(200);
                            cpanel.setPreferredSize(new Dimension(600, 350));
                            // cpanel.restoreAutoBounds(); fix the tooltip
                            // missing problem but then relative display is
                            // broken
                            panel.add(new JSeparator(SwingConstants.HORIZONTAL));
                            pan.add(cpanel, BorderLayout.CENTER);
                            // checkboxPanel.setPreferredSize(new Dimension(600,
                            // 0));
                            cpanel.addChartMouseListener(new ChartMouseListener() {

                                public void chartMouseClicked(ChartMouseEvent chartmouseevent) {
                                    // chartmouseevent.getEntity().

                                    ChartEntity entity = chartmouseevent.getEntity();
                                    if (entity instanceof XYItemEntity) {
                                        XYItemEntity item = ((XYItemEntity) entity);
                                        if (item.getDataset() instanceof TimeSeriesCollection) {

                                            TimeSeriesCollection data = (TimeSeriesCollection) item
                                                    .getDataset();
                                            TimeSeries series = data.getSeries(item.getSeriesIndex());
                                            TimeSeriesDataItem dataitem = series.getDataItem(item.getItem());

                                            // logger.info(" Serie: "+series.getKey().toString()
                                            // +
                                            // " Period : "+dataitem.getPeriod().toString());
                                            // mr.getFileForDate(new Date
                                            // (x.longValue())
                                            ;
                                            int x = chartmouseevent.getTrigger().getX();
                                            // logger.info(mr.getFileForDate(dataitem.getPeriod().getEnd()));
                                            int y = chartmouseevent.getTrigger().getY();
                                            String myString = "";
                                            if (dataitem.getPeriod() != null) {
                                                logger.info(dataitem.getPeriod().getEnd());
                                                //                                    myString = mr.getFileForDate(dataitem.getPeriod().getEnd()).toString();
                                                String lineString = ""
                                                        + mr.getFileLineForDate(dataitem.getPeriod().getEnd(),
                                                                item.getDataset()
                                                                        .getSeriesKey(item.getSeriesIndex())
                                                                        .toString())
                                                                .getLineNumber();
                                                String fileString = cd.sourceFileArrayListMap
                                                        .get(pairs.getKey())
                                                        .get(mr.getFileLineForDate(
                                                                dataitem.getPeriod().getEnd(),
                                                                item.getDataset()
                                                                        .getSeriesKey(item.getSeriesIndex())
                                                                        .toString())
                                                                .getFileId())
                                                        .getFile().getAbsolutePath();
                                                String command = Preferences.getPreference("editorCommand");
                                                command = command.replace("$line", lineString);
                                                command = command.replace("$file", fileString);
                                                logger.info(command);
                                                Runtime rt = Runtime.getRuntime();
                                                try {
                                                    rt.exec(command);
                                                } catch (IOException e1) {
                                                    // TODO Auto-generated catch block
                                                    e1.printStackTrace();
                                                }
                                                StringSelection stringSelection = new StringSelection(
                                                        fileString);
                                                Clipboard clpbrd = Toolkit.getDefaultToolkit()
                                                        .getSystemClipboard();
                                                clpbrd.setContents(stringSelection, null);
                                                //      cpanel.getGraphics().drawString("file name copied", x - 5, y - 5);
                                                try {
                                                    Thread.sleep(500);
                                                } catch (InterruptedException e) {
                                                    // TODO Auto-generated catch
                                                    // block
                                                    e.printStackTrace();
                                                }
                                            }

                                            // logger.info(mr.getFileForDate(dataitem.getPeriod().getStart()));
                                        }
                                    }
                                }

                                public void chartMouseMoved(ChartMouseEvent e) {
                                }

                            });

                            pan.add(checkboxPanel, BorderLayout.SOUTH);

                        }
                    }
                } else {
                    logger.debug("mr dates null: " + mr.getGroup() + mr.getSourceID() + mr.getLogFiles());
                }
            }
        }
    }
    // Map=miner.mine(sourceFiles,repo);
    estimatedTime = System.currentTimeMillis() - startTime;

    revalidate();
    logger.info("display time: " + estimatedTime);
}

From source file:Converter.java

ConversionPanel(Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) {
    if (MULTICOLORED) {
        setOpaque(true);/*from   w  w  w  . j a v a 2s  . c  o  m*/
        setBackground(new Color(0, 255, 255));
    }
    setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(myTitle),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Save arguments in instance variables.
    controller = myController;
    units = myUnits;
    title = myTitle;
    sliderModel = myModel;

    // Create the text field format, and then the text field.
    numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setMaximumFractionDigits(2);
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    formatter.setAllowsInvalid(false);
    formatter.setCommitsOnValidEdit(true);// seems to be a no-op --
    // aha -- it changes the value property but doesn't cause the result to
    // be parsed (that happens on focus loss/return, I think).
    //
    textField = new JFormattedTextField(formatter);
    textField.setColumns(10);
    textField.setValue(new Double(sliderModel.getDoubleValue()));
    textField.addPropertyChangeListener(this);

    // Add the combo box.
    unitChooser = new JComboBox();
    for (int i = 0; i < units.length; i++) { // Populate it.
        unitChooser.addItem(units[i].description);
    }
    unitChooser.setSelectedIndex(0);
    sliderModel.setMultiplier(units[0].multiplier);
    unitChooser.addActionListener(this);

    // Add the slider.
    slider = new JSlider(sliderModel);
    sliderModel.addChangeListener(this);

    // Make the text field/slider group a fixed size
    // to make stacked ConversionPanels nicely aligned.
    JPanel unitGroup = new JPanel() {
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }

        public Dimension getPreferredSize() {
            return new Dimension(150, super.getPreferredSize().height);
        }

        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
        unitGroup.setOpaque(true);
        unitGroup.setBackground(new Color(0, 0, 255));
    }
    unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    unitGroup.add(textField);
    unitGroup.add(slider);

    // Create a subpanel so the combo box isn't too tall
    // and is sufficiently wide.
    JPanel chooserPanel = new JPanel();
    chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
        chooserPanel.setOpaque(true);
        chooserPanel.setBackground(new Color(255, 0, 255));
    }
    chooserPanel.add(unitChooser);
    chooserPanel.add(Box.createHorizontalStrut(100));

    // Put everything together.
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    add(unitGroup);
    add(chooserPanel);
    unitGroup.setAlignmentY(TOP_ALIGNMENT);
    chooserPanel.setAlignmentY(TOP_ALIGNMENT);
}

From source file:com.juanhg.triangle.TriangleApplet.java

private void autogeneratedCode() {
    JPanel panel_control = new JPanel();
    panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null),
            new BevelBorder(BevelBorder.RAISED, null, null, null, null)));

    JPanel panelInputs = new JPanel();
    panelInputs.setToolTipText("");
    panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelOutputs = new JPanel();
    panelOutputs.setToolTipText("");
    panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelTitleOutputs = new JPanel();
    panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n");
    labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitleOutputs.add(labelOutputData);

    lblO1 = new JLabel("Tensi\u00F3n:");
    lblO1.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblTValue = new JLabel();
    lblTValue.setText("0");
    lblTValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel lblO2 = new JLabel("V:");
    lblO2.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblVValue = new JLabel();
    lblVValue.setText("0");
    lblVValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblO3 = new JLabel("tfinal:");
    lblO3.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblTfValue = new JLabel();
    lblTfValue.setText("0");
    lblTfValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel lblW = new JLabel("W:");
    lblW.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblWValue = new JLabel();
    lblWValue.setText("0");
    lblWValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs);
    gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
            .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
            .addGroup(gl_panelOutputs.createSequentialGroup().addGap(22)
                    .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false)
                            .addComponent(lblO2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(lblO1, GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING, false)
                            .addComponent(lblVValue, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(lblTValue, GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelOutputs.createSequentialGroup()
                                    .addComponent(lblO3, GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(lblTfValue, GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE))
                            .addGroup(gl_panelOutputs.createSequentialGroup()
                                    .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 45,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(lblWValue,
                                            GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()));
    gl_panelOutputs//from   w  w  w  . j  a v  a  2 s  .  com
            .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_panelOutputs.createSequentialGroup()
                            .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.UNRELATED)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                    .addGroup(gl_panelOutputs.createSequentialGroup().addComponent(lblO1)
                                            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(lblO2,
                                                    GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE))
                                    .addGroup(gl_panelOutputs.createSequentialGroup()
                                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE)
                                                    .addComponent(lblTValue)
                                                    .addComponent(lblO3, GroupLayout.PREFERRED_SIZE, 17,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(
                                                            lblTfValue, GroupLayout.PREFERRED_SIZE, 17,
                                                            GroupLayout.PREFERRED_SIZE))
                                            .addPreferredGap(ComponentPlacement.UNRELATED)
                                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                                    .addGroup(gl_panelOutputs
                                                            .createParallelGroup(Alignment.BASELINE)
                                                            .addComponent(lblW, GroupLayout.PREFERRED_SIZE, 17,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(lblWValue, GroupLayout.PREFERRED_SIZE,
                                                                    17, GroupLayout.PREFERRED_SIZE))
                                                    .addComponent(lblVValue, GroupLayout.PREFERRED_SIZE, 17,
                                                            GroupLayout.PREFERRED_SIZE))))
                            .addGap(107)));
    panelOutputs.setLayout(gl_panelOutputs);

    JPanel panelLicense = new JPanel();
    panelLicense.setBorder(new LineBorder(new Color(0, 0, 0)));

    JPanel panel_6 = new JPanel();
    panel_6.setBorder(new LineBorder(new Color(0, 0, 0)));
    GroupLayout gl_panel_control = new GroupLayout(panel_control);
    gl_panel_control.setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panel_control.createSequentialGroup().addContainerGap().addGroup(gl_panel_control
                    .createParallelGroup(Alignment.LEADING)
                    .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE)
                    .addComponent(panel_6, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE)
                    .addComponent(panelLicense, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE).addComponent(
                            panelOutputs, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addContainerGap()));
    gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panel_control.createSequentialGroup().addContainerGap()
                    .addComponent(panelInputs, GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE)
                    .addGap(13)
                    .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 85, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(panelLicense,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(24)));

    btnLaunchSimulation = new JButton("Iniciar");
    btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16));
    btnLaunchSimulation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            btnLaunchSimulationEvent(event);
        }
    });
    GroupLayout gl_panel_6 = new GroupLayout(panel_6);
    gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_6.createSequentialGroup().addContainerGap()
                    .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
                    .addContainerGap()));
    gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_6
                    .createSequentialGroup().addContainerGap().addComponent(btnLaunchSimulation,
                            GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(69, Short.MAX_VALUE)));
    panel_6.setLayout(gl_panel_6);

    JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE");
    panelLicense.add(lblNewLabel);

    JLabel LabelI1 = new JLabel("Roz Est\u00E1tico");
    LabelI1.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel labelI2 = new JLabel("Roz Din\u00E1mico");
    labelI2.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel labelI3 = new JLabel("Masa");
    labelI3.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JPanel panelTitle = new JPanel();
    panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    lblMudValue = new JLabel("0.1");
    lblMudValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblMValue = new JLabel("10");
    lblMValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblMueValue = new JLabel("0.4");
    lblMueValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderMue = new JSlider();
    sliderMue.setMinimum(15);
    sliderMue.setMaximum(80);
    sliderMue.setMinorTickSpacing(1);
    sliderMue.setValue(40);
    sliderMue.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent event) {
            sliderI1Event();
        }
    });

    sliderMud = new JSlider();
    sliderMud.setMinimum(5);
    sliderMud.setMaximum(15);
    sliderMud.setMinorTickSpacing(1);
    sliderMud.setValue(10);
    sliderMud.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI2Event();
        }
    });

    sliderIM = new JSlider();
    sliderIM.setMinimum(1);
    sliderIM.setMaximum(20);
    sliderIM.setValue(10);
    sliderIM.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI3Event();
        }
    });

    JLabel lblI4 = new JLabel("\u00C1ngulo");
    lblI4.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblZValue = new JLabel("45\u00BA");
    lblZValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderZ = new JSlider();
    sliderZ.setMinimum(20);
    sliderZ.setMaximum(60);
    sliderZ.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            sliderI4Event();
        }
    });
    sliderZ.setValue(45);
    sliderZ.setMinorTickSpacing(1);

    btnCilindro = new JButton(new ImageIcon(loadImage(cilindro)));
    btnCilindro.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            type = CILINDRO;
            btnCilindro.setEnabled(false);
            btnEsfera.setEnabled(true);
            btnCubo.setEnabled(true);

            chartTriangle.deleteAnnotation(pulleyAnnotation);
            pulleyAnnotation = chartTriangle.setImageAtPoint(pulleyImage1, xPulley, yPulley);

            updatePanels();
            repaint();
        }
    });

    btnEsfera = new JButton(new ImageIcon(loadImage(esfera)));
    btnEsfera.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            type = ESFERA;
            btnCilindro.setEnabled(true);
            btnEsfera.setEnabled(false);
            btnCubo.setEnabled(true);

            chartTriangle.deleteAnnotation(pulleyAnnotation);
            pulleyAnnotation = chartTriangle.setImageAtPoint(pulleyImage2, xPulley, yPulley);

            updatePanels();
            repaint();
        }
    });

    btnCubo = new JButton(new ImageIcon(loadImage(cubo)));
    btnCubo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            type = CUBO;
            btnCilindro.setEnabled(true);
            btnEsfera.setEnabled(true);
            btnCubo.setEnabled(false);

            chartTriangle.deleteAnnotation(pulleyAnnotation);
            pulleyAnnotation = chartTriangle.setImageAtPoint(pulleyImage3, xPulley, yPulley);

            updatePanels();
            repaint();
        }
    });

    GroupLayout gl_panelInputs = new GroupLayout(panelInputs);
    gl_panelInputs.setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING)
            .addComponent(panelTitle, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
            .addGroup(gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs
                    .createParallelGroup(Alignment.LEADING).addGroup(gl_panelInputs.createSequentialGroup()
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.TRAILING, false)
                                    .addComponent(labelI3, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(LabelI1, Alignment.LEADING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelI2, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 120,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGap(18)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(lblMueValue, GroupLayout.PREFERRED_SIZE, 42,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblMudValue, GroupLayout.PREFERRED_SIZE, 56,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 56,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGap(18)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false)
                                    .addComponent(sliderMue, 0, 0, Short.MAX_VALUE)
                                    .addComponent(sliderMud, 0, 0, Short.MAX_VALUE).addComponent(
                                            sliderIM, GroupLayout.PREFERRED_SIZE, 88,
                                            GroupLayout.PREFERRED_SIZE)))
                    .addGroup(gl_panelInputs.createSequentialGroup()
                            .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 120, GroupLayout.PREFERRED_SIZE)
                            .addGap(18)
                            .addComponent(lblZValue, GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)
                            .addGap(18)
                            .addComponent(sliderZ, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)))
                    .addGap(19))
            .addGroup(Alignment.LEADING, gl_panelInputs.createSequentialGroup().addGap(35)
                    .addComponent(btnCilindro, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE)
                    .addGap(18)
                    .addComponent(btnEsfera, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE)
                    .addGap(18)
                    .addComponent(btnCubo, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(42, Short.MAX_VALUE)));
    gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelInputs.createSequentialGroup()
                    .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGap(18)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(LabelI1).addComponent(lblMueValue, GroupLayout.PREFERRED_SIZE,
                                            17, GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderMue, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(labelI2).addComponent(lblMudValue, GroupLayout.PREFERRED_SIZE,
                                            17, GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderMud, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(11)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelI3)
                            .addComponent(lblMValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
                            .addComponent(sliderIM, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblI4, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblZValue, GroupLayout.PREFERRED_SIZE, 17, GroupLayout.PREFERRED_SIZE)
                            .addComponent(sliderZ, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(36)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                            .addComponent(btnCubo, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnEsfera, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnCilindro, GroupLayout.PREFERRED_SIZE, 61,
                                    GroupLayout.PREFERRED_SIZE))
                    .addContainerGap()));

    JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada");
    lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitle.add(lblDatosDeEntrada);
    panelInputs.setLayout(gl_panelInputs);
    panel_control.setLayout(gl_panel_control);

    JPanel panel_visualizar = new JPanel();
    panel_visualizar.setBackground(Color.WHITE);

    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addContainerGap()
                    .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 696, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(149, Short.MAX_VALUE)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
            .addGroup(groupLayout.createSequentialGroup().addContainerGap()
                    .addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
                            .addComponent(panel_visualizar, Alignment.TRAILING, 0, 0, Short.MAX_VALUE)
                            .addComponent(panel_control, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 568,
                                    Short.MAX_VALUE))
                    .addContainerGap()));

    JPanel panel = new JPanel();

    panelGrafica = new JPanelGrafica();
    GroupLayout gl_panel = new GroupLayout(panel);
    gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(panelGrafica,
            GroupLayout.DEFAULT_SIZE, 686, Short.MAX_VALUE));
    gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addComponent(panelGrafica,
            GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE));
    panel.setLayout(gl_panel);
    GroupLayout gl_panel_visualizar = new GroupLayout(panel_visualizar);
    gl_panel_visualizar.setHorizontalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_visualizar.createSequentialGroup().addContainerGap()
                    .addComponent(panel, GroupLayout.PREFERRED_SIZE, 414, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(272, Short.MAX_VALUE)));
    gl_panel_visualizar.setVerticalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_visualizar.createSequentialGroup().addContainerGap()
                    .addComponent(panel, GroupLayout.DEFAULT_SIZE, 546, Short.MAX_VALUE).addContainerGap()));

    panel_visualizar.setLayout(gl_panel_visualizar);

    getContentPane().setLayout(groupLayout);
}

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

/**
 * This populates the default view descriptor declared as the startingPageId
 * property in the richclient-application-context.xml file.
 *
 * @return bagViewPanel/*from  w  w w .j a  v a 2 s  .  c  o  m*/
 */
@Override
protected JComponent createControl() {
    bag = new DefaultBag();

    final String userHomeDir = System.getProperty("user.home");
    display("createControl - User Home Path: " + userHomeDir);

    initializeCommands();

    final ApplicationServices services = this.getApplicationServices();

    final Color bgColor = new Color(20, 20, 100);
    topButtonPanel = createTopButtonPanel();
    topButtonPanel.setBackground(bgColor);

    infoInputPane = new InfoFormsPane(this);
    infoInputPane.bagInfoInputPane.enableForms(false);
    final JSplitPane bagPanel = createBagPanel();

    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints glbc = LayoutUtil.buildGridBagConstraints(0, 0, 1, 1, 50, 100,
            GridBagConstraints.BOTH, GridBagConstraints.CENTER);

    layout.setConstraints(bagPanel, glbc);

    final JPanel mainPanel = new JPanel(layout);
    mainPanel.add(bagPanel);

    final JPanel bagViewPanel = new JPanel(new BorderLayout(2, 2));
    bagViewPanel.setBackground(bgColor);
    bagViewPanel.add(mainPanel, BorderLayout.CENTER);
    return bagViewPanel;
}

From source file:it.illinois.adsc.ema.softgrid.monitoring.ui.SPMainFrame.java

private void setupGUI() throws Exception {
    this.getContentPane().setLayout(new GridBagLayout());
    chartPanel = getChartPanel();//from   www . ja v a2  s .c o  m
    this.setPreferredSize(new Dimension(800, 700));

    alertPanel.setPreferredSize(new Dimension(200, 700));
    alertPanel.setMinimumSize(new Dimension(200, 700));
    alertPanel.setMaximumSize(new Dimension(200, 700));

    transientPanel.setPreferredSize(new Dimension(200, 700));
    transientPanel.setMinimumSize(new Dimension(200, 700));
    transientPanel.setMaximumSize(new Dimension(200, 700));

    queryTextArea.setPreferredSize(new Dimension(300, 100));
    queryTextArea.setMinimumSize(new Dimension(300, 100));
    queryTextArea.setMaximumSize(new Dimension(300, 100));

    monitorButton.setPreferredSize(new Dimension(30, 30));
    monitorButton.setMinimumSize(new Dimension(30, 30));
    monitorButton.setMaximumSize(new Dimension(30, 30));
    monitorButton.setToolTipText("Execute and Monitor");

    exitButton.setPreferredSize(new Dimension(30, 30));
    exitButton.setMinimumSize(new Dimension(30, 30));
    exitButton.setMaximumSize(new Dimension(30, 30));
    exitButton.setToolTipText("Close and Exit");

    clearButton.setPreferredSize(new Dimension(30, 30));
    clearButton.setMinimumSize(new Dimension(30, 30));
    clearButton.setMaximumSize(new Dimension(30, 30));
    clearButton.setToolTipText("Reset");

    runButton.setPreferredSize(new Dimension(30, 30));
    runButton.setMinimumSize(new Dimension(30, 30));
    runButton.setMaximumSize(new Dimension(30, 30));
    runButton.setToolTipText("Initialize the server...!");

    alertPanel.setLayout(new VerticalFlowLayout());
    transientPanel.setLayout(new BorderLayout());
    //      System.out.println("new File(\"../MonitorEngine/Images/execute-xxl.png\").exists() = " + new File("../MonitorEngine/Images/execute-xxl.png").exists());
    //      System.out.println("execute-xxl.png = " + new File("execute-xxl.png").exists());
    //      System.out.println("new File().getAbsolutePath() = " + new File("openmuc.jar").getAbsolutePath());
    Image img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("execute-xxl.png")))
            .getImage();
    Image newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH);
    ImageIcon icon = new ImageIcon(newimg);
    monitorButton.setIcon(icon);

    img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("stop-xxl.png")))
            .getImage();
    newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH);
    icon = new ImageIcon(newimg);
    exitButton.setIcon(icon);

    img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("reset-xxl.png")))
            .getImage();
    newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH);
    icon = new ImageIcon(newimg);
    clearButton.setIcon(icon);

    img = new ImageIcon(ImageIO.read(getClass().getClassLoader().getResourceAsStream("start-xxl.png")))
            .getImage();
    newimg = img.getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH);
    icon = new ImageIcon(newimg);
    runButton.setIcon(icon);
    altertScrolPane.getViewport().add(alertPanel, null);
    altertScrolPane.setBorder(BorderFactory.createEtchedBorder());
    logAreaScrollPane.getViewport().add(logTextArea, null);
    logAreaScrollPane.setBorder(BorderFactory.createEtchedBorder());

    JPanel tempQueryPanel = new JPanel();
    JPanel buttonPanel = new JPanel();
    //      tempQueryPanel.setBorder(BorderFactory.createTitledBorder("Monitor Query"));
    tempQueryPanel.setLayout(new GridBagLayout());
    buttonPanel.setLayout(new GridBagLayout());
    buttonPanel.setBorder(BorderFactory.createEtchedBorder());
    buttonPanel.setOpaque(true);
    buttonPanel.setBackground(Color.gray);
    buttonPanel.add(runButton, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(6, 12, 3, 12), 0, 0));
    buttonPanel.add(monitorButton, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(3, 12, 3, 12), 0, 0));
    buttonPanel.add(clearButton, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(3, 12, 3, 12), 0, 0));
    buttonPanel.add(exitButton, new GridBagConstraints(0, 4, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.NONE, new Insets(3, 12, 3, 12), 0, 0));
    //      tempQueryPanel.add(splitPane, new GridBagConstraints(0, 0, 1, 6, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    tempQueryPanel.add(buttonPanel, new GridBagConstraints(0, 0, 1, 1, 0, 1, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
    tempQueryPanel.add(queryScrolPane, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    mainTabbedPane.add(splitPane, "Controller");

    mainTabbedPane.add(ConfigPanel.getInstance(), "Configuration");

    splitPane.setTopComponent(tempQueryPanel);
    splitPane.setDividerLocation(152);
    splitPane.setBottomComponent(resultTabbedPane);
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    this.getContentPane().add(mainTabbedPane, new GridBagConstraints(0, 0, 1, 2, 0.75, 0.25,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 12, 12, 0), 0, 0));
    //      this.getContentPane().add(alertTitile, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(12, 0, 0, 12), 0, 0));
    //      this.getContentPane().add(altertScrolPane, new GridBagConstraints(1, 1, 1, 2, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0, 0, 12, 12), 0, 0));
    //      tempQueryPanel.add(queryScrolPane, new GridBagConstraints(0, 0, 1, 5, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    //      this.getContentPane().add(logAreaScrollPane, new GridBagConstraints(0, 2, 1, 1, 0.75, 0.75, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(12, 12, 12, 0), 0, 0));
    exitButton.addActionListener(this);
    monitorButton.addActionListener(this);
    clearButton.addActionListener(this);
    clearButton.setEnabled(false);
    clearButton.setVisible(false);
    monitorButton.setEnabled(true);
    runButton.addActionListener(this);
    queryTextArea.setContentType("text/html");
    queryTextArea.setText("select overloadrank from virtual");

    messageHandler = new MessageUIHandler(logTextArea, logAreaScrollPane);
    ConfigPanel.getInstance().setupConfigPanel();
}

From source file:com.juanhg.fridge.FridgeApplet.java

private void autogeneratedCode() {
    JPanel panel_control = new JPanel();
    panel_control.setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.RAISED, null, null),
            new BevelBorder(BevelBorder.RAISED, null, null, null, null)));

    JPanel panelInputs = new JPanel();
    panelInputs.setToolTipText("");
    panelInputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelOutputs = new JPanel();
    panelOutputs.setToolTipText("");
    panelOutputs.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));

    JPanel panelTitleOutputs = new JPanel();
    panelTitleOutputs.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    JLabel labelOutputData = new JLabel("Datos de la Simulaci\u00F3n");
    labelOutputData.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitleOutputs.add(labelOutputData);

    lblO1 = new JLabel("Tiempo On:");
    lblO1.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblTValue = new JLabel();
    lblTValue.setText("0");
    lblTValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel lblO2 = new JLabel("Eficiencia:");
    lblO2.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblEValue = new JLabel();
    lblEValue.setText("0");
    lblEValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel lblTiempoOff = new JLabel("Tiempo Off:");
    lblTiempoOff.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblOffValue = new JLabel();
    lblOffValue.setText("0");
    lblOffValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    GroupLayout gl_panelOutputs = new GroupLayout(panelOutputs);
    gl_panelOutputs.setHorizontalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
            .addComponent(panelTitleOutputs, GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)
            .addGroup(gl_panelOutputs.createSequentialGroup().addGap(22)
                    .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 81, GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblO1, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblEValue, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)
                            .addGroup(gl_panelOutputs.createSequentialGroup()
                                    .addComponent(lblTValue, GroupLayout.PREFERRED_SIZE, 52,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addGap(31)
                                    .addComponent(lblTiempoOff, GroupLayout.PREFERRED_SIZE, 77,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addComponent(lblOffValue, GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)))
                    .addContainerGap()));
    gl_panelOutputs//from   ww w.j av  a  2  s  . c  om
            .setVerticalGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_panelOutputs.createSequentialGroup()
                            .addComponent(panelTitleOutputs, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.UNRELATED)
                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(lblOffValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblTiempoOff, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addGroup(gl_panelOutputs.createSequentialGroup()
                                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE)
                                                    .addComponent(lblO1).addComponent(lblTValue))
                                            .addPreferredGap(ComponentPlacement.RELATED)
                                            .addGroup(gl_panelOutputs.createParallelGroup(Alignment.BASELINE)
                                                    .addComponent(lblO2, GroupLayout.PREFERRED_SIZE, 17,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(lblEValue, GroupLayout.PREFERRED_SIZE, 17,
                                                            GroupLayout.PREFERRED_SIZE))))));
    panelOutputs.setLayout(gl_panelOutputs);

    JPanel panelLicense = new JPanel();
    panelLicense.setBorder(new LineBorder(new Color(0, 0, 0)));

    JPanel panel_6 = new JPanel();
    panel_6.setBorder(new LineBorder(new Color(0, 0, 0)));
    GroupLayout gl_panel_control = new GroupLayout(panel_control);
    gl_panel_control
            .setHorizontalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
                    .addGroup(Alignment.LEADING, gl_panel_control.createSequentialGroup().addContainerGap()
                            .addGroup(gl_panel_control.createParallelGroup(Alignment.LEADING)
                                    .addComponent(panelOutputs, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 346, Short.MAX_VALUE)
                                    .addComponent(panel_6, Alignment.TRAILING, GroupLayout.PREFERRED_SIZE, 346,
                                            Short.MAX_VALUE)
                                    .addComponent(panelLicense, GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE))
                            .addContainerGap()));
    gl_panel_control.setVerticalGroup(gl_panel_control.createParallelGroup(Alignment.TRAILING)
            .addGroup(gl_panel_control.createSequentialGroup().addContainerGap()
                    .addComponent(panelInputs, GroupLayout.PREFERRED_SIZE, 305, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panelOutputs, GroupLayout.PREFERRED_SIZE, 100, Short.MAX_VALUE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel_6, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(panelLicense,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(24)));

    btnLaunchSimulation = new JButton("Iniciar");
    btnLaunchSimulation.setFont(new Font("Tahoma", Font.PLAIN, 16));
    btnLaunchSimulation.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            btnLaunchSimulationEvent(event);
        }
    });
    GroupLayout gl_panel_6 = new GroupLayout(panel_6);
    gl_panel_6.setHorizontalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING).addGroup(Alignment.TRAILING,
            gl_panel_6.createSequentialGroup().addContainerGap()
                    .addComponent(btnLaunchSimulation, GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
                    .addContainerGap()));
    gl_panel_6.setVerticalGroup(gl_panel_6.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panel_6
                    .createSequentialGroup().addContainerGap().addComponent(btnLaunchSimulation,
                            GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(69, Short.MAX_VALUE)));
    panel_6.setLayout(gl_panel_6);

    JLabel lblNewLabel = new JLabel("GNU GENERAL PUBLIC LICENSE");
    panelLicense.add(lblNewLabel);

    JLabel LabelI1 = new JLabel("Potencia");
    LabelI1.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel labelI2 = new JLabel("T1");
    labelI2.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JLabel labelI3 = new JLabel("T2");
    labelI3.setFont(new Font("Tahoma", Font.PLAIN, 14));

    JPanel panelTitle = new JPanel();
    panelTitle.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));

    lblT1Value = new JLabel("20");
    lblT1Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblT2Value = new JLabel("-15");
    lblT2Value.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblPValue = new JLabel("700");
    lblPValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderP = new JSlider();
    sliderP.setMinimum(500);
    sliderP.setMaximum(1000);
    sliderP.setMinorTickSpacing(50);
    sliderP.setValue(700);
    sliderP.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent event) {
            sliderI1Event();
        }
    });

    sliderT1 = new JSlider();
    sliderT1.setMinimum(18);
    sliderT1.setMaximum(30);
    sliderT1.setMinorTickSpacing(1);
    sliderT1.setValue(20);
    sliderT1.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI2Event();
        }
    });

    sliderT2 = new JSlider();
    sliderT2.setMinimum(10);
    sliderT2.setMaximum(30);
    sliderT2.setValue(15);
    sliderT2.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            sliderI3Event();
        }
    });

    JLabel lblQo = new JLabel("Qo");
    lblQo.setFont(new Font("Tahoma", Font.PLAIN, 14));

    lblQcValue = new JLabel("25");
    lblQcValue.setFont(new Font("Tahoma", Font.PLAIN, 14));

    sliderQc = new JSlider();
    sliderQc.setMinimum(10);
    sliderQc.setMaximum(50);
    sliderQc.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            sliderI4Event();
        }
    });
    sliderQc.setValue(25);
    sliderQc.setMinorTickSpacing(1);

    btn1 = new JButton("1");
    btn1.setFont(new Font("Tahoma", Font.PLAIN, 21));
    btn1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            btnMilk.setEnabled(false);
            btnFish.setEnabled(false);
            btnMetal.setEnabled(false);
            btn1.setEnabled(false);
            btn2.setEnabled(true);
            sliderQc.setEnabled(true);
            lblQcValue.setText("" + sliderQc.getValue());

        }
    });

    btn2 = new JButton("2");
    btn2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            btnMilk.setEnabled(true);
            btnFish.setEnabled(true);
            btnMetal.setEnabled(true);
            btn1.setEnabled(true);
            btn2.setEnabled(false);
            phase = 2;
            sliderQc.setEnabled(false);
            lblQcValue.setText("-");

        }
    });
    btn2.setFont(new Font("Tahoma", Font.PLAIN, 21));

    fishImage = loadImage(fish);
    btnFish = new JButton(new ImageIcon(fishImage));
    btnFish.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            btnFishFunction();
        }
    });

    milkImage = loadImage(milk);
    btnMilk = new JButton(new ImageIcon(milkImage));
    btnMilk.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            btnMilkFunction();
        }
    });

    metalImage = loadImage(metal);
    btnMetal = new JButton(new ImageIcon(metalImage));
    btnMetal.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            btnMetalFunction();
        }
    });

    GroupLayout gl_panelInputs = new GroupLayout(panelInputs);
    gl_panelInputs
            .setHorizontalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                    .addComponent(panelTitle, GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
                    .addGroup(gl_panelInputs.createSequentialGroup().addGap(38).addGroup(gl_panelInputs
                            .createParallelGroup(Alignment.LEADING).addGroup(
                                    gl_panelInputs.createSequentialGroup().addGap(36)
                                            .addComponent(btn1, GroupLayout.PREFERRED_SIZE, 80,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(ComponentPlacement.UNRELATED)
                                            .addComponent(btn2, GroupLayout.PREFERRED_SIZE, 80,
                                                    GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_panelInputs.createSequentialGroup().addGroup(gl_panelInputs
                                    .createParallelGroup(Alignment.LEADING, false)
                                    .addComponent(lblQo, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(labelI3, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                            Short.MAX_VALUE)
                                    .addComponent(labelI2, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                            Short.MAX_VALUE)
                                    .addComponent(LabelI1, GroupLayout.DEFAULT_SIZE, 66, Short.MAX_VALUE))
                                    .addGap(18)
                                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false)
                                            .addGroup(gl_panelInputs.createSequentialGroup()
                                                    .addGroup(gl_panelInputs
                                                            .createParallelGroup(Alignment.LEADING)
                                                            .addComponent(lblPValue, GroupLayout.PREFERRED_SIZE,
                                                                    42, GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(lblT1Value,
                                                                    GroupLayout.PREFERRED_SIZE, 56,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(lblT2Value,
                                                                    GroupLayout.PREFERRED_SIZE, 56,
                                                                    GroupLayout.PREFERRED_SIZE))
                                                    .addGap(18)
                                                    .addGroup(gl_panelInputs
                                                            .createParallelGroup(Alignment.LEADING, false)
                                                            .addComponent(sliderT1, 0, 0, Short.MAX_VALUE)
                                                            .addComponent(sliderP, GroupLayout.DEFAULT_SIZE,
                                                                    134, Short.MAX_VALUE)
                                                            .addComponent(sliderT2, 0, 0, Short.MAX_VALUE)))
                                            .addGroup(gl_panelInputs.createSequentialGroup()
                                                    .addComponent(lblQcValue, GroupLayout.PREFERRED_SIZE, 56,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addGap(18)
                                                    .addComponent(sliderQc, 0, 0, Short.MAX_VALUE)))))
                            .addContainerGap(14, Short.MAX_VALUE))
                    .addGroup(Alignment.TRAILING, gl_panelInputs.createSequentialGroup()
                            .addContainerGap(28, Short.MAX_VALUE)
                            .addComponent(btnFish, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addComponent(btnMilk, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addComponent(btnMetal, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE)
                            .addGap(25)));
    gl_panelInputs.setVerticalGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_panelInputs.createSequentialGroup()
                    .addComponent(panelTitle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGap(18)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(LabelI1).addComponent(lblPValue, GroupLayout.PREFERRED_SIZE,
                                            17, GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderP, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(labelI2).addComponent(lblT1Value, GroupLayout.PREFERRED_SIZE,
                                            17, GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderT1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(11)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING).addComponent(labelI3)
                            .addComponent(lblT2Value, GroupLayout.PREFERRED_SIZE, 17,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(sliderT2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(lblQo, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblQcValue, GroupLayout.PREFERRED_SIZE, 17,
                                            GroupLayout.PREFERRED_SIZE))
                            .addComponent(sliderQc, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(18)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                            .addComponent(btn1, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE)
                            .addComponent(btn2, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING, false)
                            .addGroup(gl_panelInputs.createParallelGroup(Alignment.LEADING)
                                    .addComponent(btnMetal, GroupLayout.PREFERRED_SIZE, 72,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(btnMilk, GroupLayout.PREFERRED_SIZE, 72,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_panelInputs.createSequentialGroup().addGap(1).addComponent(btnFish,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addContainerGap(12, Short.MAX_VALUE)));

    JLabel lblDatosDeEntrada = new JLabel("Datos de Entrada");
    lblDatosDeEntrada.setFont(new Font("Tahoma", Font.PLAIN, 14));
    panelTitle.add(lblDatosDeEntrada);
    panelInputs.setLayout(gl_panelInputs);
    panel_control.setLayout(gl_panel_control);

    JPanel panel_visualizar = new JPanel();
    panel_visualizar.setBackground(Color.WHITE);

    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addContainerGap()
                    .addComponent(panel_control, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(panel_visualizar, GroupLayout.PREFERRED_SIZE, 398, GroupLayout.PREFERRED_SIZE)
                    .addGap(452)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout
            .createSequentialGroup()
            .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
                    .addGroup(Alignment.LEADING,
                            groupLayout.createSequentialGroup().addGap(12).addComponent(panel_visualizar,
                                    GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE))
                    .addGroup(groupLayout.createSequentialGroup().addContainerGap().addComponent(panel_control,
                            GroupLayout.PREFERRED_SIZE, 568, GroupLayout.PREFERRED_SIZE)))
            .addContainerGap()));

    JPanel panel = new JPanel();

    panelGrafica = new JPanelGrafica();
    GroupLayout gl_panel = new GroupLayout(panel);
    gl_panel.setHorizontalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGap(0, 384, Short.MAX_VALUE)
            .addComponent(panelGrafica, GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE));
    gl_panel.setVerticalGroup(gl_panel.createParallelGroup(Alignment.LEADING).addGap(0, 241, Short.MAX_VALUE)
            .addComponent(panelGrafica, GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE));
    panel.setLayout(gl_panel);
    GroupLayout gl_panel_visualizar = new GroupLayout(panel_visualizar);
    gl_panel_visualizar.setHorizontalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING)
            .addComponent(panel, GroupLayout.DEFAULT_SIZE, 398, Short.MAX_VALUE));
    gl_panel_visualizar.setVerticalGroup(gl_panel_visualizar.createParallelGroup(Alignment.LEADING)
            .addComponent(panel, GroupLayout.DEFAULT_SIZE, 567, Short.MAX_VALUE));

    panel_visualizar.setLayout(gl_panel_visualizar);

    getContentPane().setLayout(groupLayout);
}

From source file:net.sf.taverna.t2.workbench.ui.impl.UserRegistrationForm.java

private void initComponents() {
    JPanel mainPanel = new JPanel(new GridBagLayout());

    // Base font for all components on the form
    Font baseFont = new JLabel("base font").getFont().deriveFont(11f);

    // Title panel
    JPanel titlePanel = new JPanel(new FlowLayout(LEFT));
    titlePanel.setBackground(WHITE);
    // titlePanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    JLabel titleLabel = new JLabel(WELCOME);
    titleLabel.setFont(baseFont.deriveFont(BOLD, 13.5f));
    // titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10));
    JLabel titleIcon = new JLabel(tavernaCogs32x32Icon);
    // titleIcon.setBorder(new EmptyBorder(10, 10, 10, 10));
    DialogTextArea titleMessage = new DialogTextArea(PLEASE_FILL_IN_THIS_REGISTRATION_FORM);
    titleMessage.setMargin(new Insets(0, 20, 0, 10));
    titleMessage.setFont(baseFont);/*from   ww w.  j  a  va 2  s .c  o m*/
    titleMessage.setEditable(false);
    titleMessage.setFocusable(false);
    // titlePanel.setBorder( new EmptyBorder(10, 10, 0, 10));
    JPanel messagePanel = new JPanel(new BorderLayout());
    messagePanel.add(titleLabel, NORTH);
    messagePanel.add(titleMessage, CENTER);
    messagePanel.setBackground(WHITE);
    titlePanel.add(titleIcon);
    titlePanel.add(messagePanel);
    addDivider(titlePanel, BOTTOM, true);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    // gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(titlePanel, gbc);

    // Registration messages
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    // gbc.insets = new Insets(5, 0, 0, 10);
    DialogTextArea registrationMessage1 = new DialogTextArea(WHY_REGISTER);
    registrationMessage1.setMargin(new Insets(0, 10, 0, 0));
    registrationMessage1.setFont(baseFont);
    registrationMessage1.setEditable(false);
    registrationMessage1.setFocusable(false);
    registrationMessage1.setBackground(getBackground());

    DialogTextArea registrationMessage2 = new DialogTextArea(WE_DO);
    registrationMessage2.setMargin(new Insets(0, 10, 0, 10));
    registrationMessage2.setFont(baseFont);
    registrationMessage2.setEditable(false);
    registrationMessage2.setFocusable(false);
    registrationMessage2.setBackground(getBackground());
    JPanel registrationMessagePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    registrationMessagePanel.add(registrationMessage1);
    registrationMessagePanel.add(registrationMessage2);
    addDivider(registrationMessagePanel, BOTTOM, true);
    mainPanel.add(registrationMessagePanel, gbc);

    // Mandatory label
    // JLabel mandatoryLabel = new JLabel("* Mandatory fields");
    // mandatoryLabel.setFont(baseFont);
    // gbc.weightx = 0.0;
    // gbc.weighty = 0.0;
    // gbc.gridx = 0;
    // gbc.gridy = 3;
    // gbc.fill = NONE;
    // gbc.anchor = GridBagConstraints.EAST;
    // gbc.gridwidth = 2;
    // gbc.insets = new Insets(0, 10, 0, 20);
    // mainPanel.add(mandatoryLabel, gbc);

    // First name
    JLabel firstNameLabel = new JLabel(FIRST_NAME);
    firstNameLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0, 10, 0, 10);
    mainPanel.add(firstNameLabel, gbc);

    firstNameTextField = new JTextField();
    firstNameTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        firstNameTextField.setText(previousRegistrationData.getFirstName());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(firstNameTextField, gbc);

    // Last name
    JLabel lastNameLabel = new JLabel(LAST_NAME);
    lastNameLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(0, 10, 0, 10);
    mainPanel.add(lastNameLabel, gbc);

    lastNameTextField = new JTextField();
    lastNameTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        lastNameTextField.setText(previousRegistrationData.getLastName());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(lastNameTextField, gbc);

    // Email address
    JLabel emailLabel = new JLabel(EMAIL_ADDRESS);
    emailLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(emailLabel, gbc);

    emailTextField = new JTextField();
    emailTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        emailTextField.setText(previousRegistrationData.getEmailAddress());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(emailTextField, gbc);

    // Keep me informed
    keepMeInformedCheckBox = new JCheckBox(KEEP_ME_INFORMED);
    keepMeInformedCheckBox.setFont(baseFont);
    if (previousRegistrationData != null)
        keepMeInformedCheckBox.setSelected(previousRegistrationData.getKeepMeInformed());
    keepMeInformedCheckBox.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                keepMeInformedCheckBox.setSelected(!keepMeInformedCheckBox.isSelected());
            }
        }
    });
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(keepMeInformedCheckBox, gbc);

    // Institution name
    JLabel institutionLabel = new JLabel(INSTITUTION_COMPANY_NAME);
    institutionLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 8;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(institutionLabel, gbc);

    institutionOrCompanyTextField = new JTextField();
    institutionOrCompanyTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        institutionOrCompanyTextField.setText(previousRegistrationData.getInstitutionOrCompanyName());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(institutionOrCompanyTextField, gbc);

    // Industry type
    JLabel industryLabel = new JLabel(" Industry type:");
    industryLabel.setFont(baseFont);
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 9;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(industryLabel, gbc);

    industryTypeTextField = new JComboBox<>(industryTypes);
    industryTypeTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        industryTypeTextField.setSelectedItem(previousRegistrationData.getIndustry());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 9;
    gbc.fill = HORIZONTAL;
    gbc.anchor = WEST;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(industryTypeTextField, gbc);

    // Field of investigation
    JTextArea fieldLabel = new JTextArea(FIELD_OF_INVESTIGATION);
    fieldLabel.setFont(baseFont);
    fieldLabel.setEditable(false);
    fieldLabel.setFocusable(false);
    fieldLabel.setBackground(getBackground());
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 10;
    gbc.fill = NONE;
    gbc.anchor = LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(fieldLabel, gbc);

    fieldTextField = new JTextField();
    fieldTextField.setFont(baseFont);
    if (previousRegistrationData != null)
        fieldTextField.setText(previousRegistrationData.getField());
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 10;
    gbc.fill = HORIZONTAL;
    gbc.anchor = FIRST_LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(fieldTextField, gbc);

    // Purpose of using Taverna
    JTextArea purposeLabel = new JTextArea(WHY_YOU_INTEND_TO_USE_TAVERNA);
    purposeLabel.setFont(baseFont);
    purposeLabel.setEditable(false);
    purposeLabel.setFocusable(false);
    purposeLabel.setBackground(getBackground());
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 11;
    gbc.fill = NONE;
    gbc.anchor = LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(purposeLabel, gbc);

    purposeTextArea = new JTextArea(4, 30);
    purposeTextArea.setFont(baseFont);
    purposeTextArea.setLineWrap(true);
    purposeTextArea.setAutoscrolls(true);
    if (previousRegistrationData != null)
        purposeTextArea.setText(previousRegistrationData.getPurposeOfUsingTaverna());
    purposeTextArea.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_TAB) {
                if (evt.getModifiers() > 0)
                    purposeTextArea.transferFocusBackward();
                else
                    purposeTextArea.transferFocus();
                evt.consume();
            }
        }
    });
    JScrollPane purposeScrollPane = new JScrollPane(purposeTextArea);
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 1;
    gbc.gridy = 11;
    gbc.fill = HORIZONTAL;
    gbc.anchor = FIRST_LINE_START;
    gbc.gridwidth = 1;
    gbc.insets = new Insets(5, 10, 0, 10);
    mainPanel.add(purposeScrollPane, gbc);

    // Terms and conditions
    termsAndConditionsCheckBox = new JCheckBox(I_AGREE_TO_THE_TERMS_AND_CONDITIONS);
    termsAndConditionsCheckBox.setFont(baseFont);
    termsAndConditionsCheckBox.setBorder(null);
    termsAndConditionsCheckBox.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                termsAndConditionsCheckBox.setSelected(!termsAndConditionsCheckBox.isSelected());
            }
        }
    });
    // gbc.weightx = 0.0;
    // gbc.weighty = 0.0;
    // gbc.gridx = 0;
    // gbc.gridy = 12;
    // gbc.fill = NONE;
    // gbc.anchor = WEST;
    // gbc.gridwidth = 2;
    // gbc.insets = new Insets(10, 10, 0, 0);
    // mainPanel.add(termsAndConditionsCheckBox, gbc);

    // Terms and conditions link
    JEditorPane termsAndConditionsURL = new JEditorPane();
    termsAndConditionsURL.setEditable(false);
    termsAndConditionsURL.setBackground(getBackground());
    termsAndConditionsURL.setFocusable(false);
    HTMLEditorKit kit = new HTMLEditorKit();
    termsAndConditionsURL.setEditorKit(kit);
    StyleSheet styleSheet = kit.getStyleSheet();
    // styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}");
    // // base font looks bigger when rendered as HTML
    styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:9px;}");
    Document doc = kit.createDefaultDocument();
    termsAndConditionsURL.setDocument(doc);
    termsAndConditionsURL.setText("<html><body><a href=\"" + TERMS_AND_CONDITIONS_URL + "\">"
            + TERMS_AND_CONDITIONS_URL + "</a></body></html>");
    termsAndConditionsURL.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent he) {
            if (he.getEventType() == ACTIVATED)
                followHyperlinkToTandCs();
        }
    });
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 13;
    gbc.fill = NONE;
    gbc.anchor = WEST;
    gbc.gridwidth = 2;
    gbc.insets = new Insets(5, 10, 0, 10);
    JPanel termsAndConditionsPanel = new JPanel(new FlowLayout(LEFT));
    termsAndConditionsPanel.add(termsAndConditionsCheckBox);
    termsAndConditionsPanel.add(termsAndConditionsURL);
    mainPanel.add(termsAndConditionsPanel, gbc);

    // Button panel
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JButton registerButton = new JButton("Register");
    registerButton.setFont(baseFont);
    registerButton.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                register();
            }
        }
    });
    registerButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            register();
        }
    });
    JButton doNotRegisterButton = new JButton("Do not ask me again");
    doNotRegisterButton.setFont(baseFont);
    doNotRegisterButton.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                doNotRegister();
            }
        }
    });
    doNotRegisterButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doNotRegister();
        }
    });
    JButton remindMeLaterButton = new JButton("Remind me later"); // in 2 weeks
    remindMeLaterButton.setFont(baseFont);
    remindMeLaterButton.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent evt) {
            if (evt.getKeyCode() == VK_ENTER) {
                evt.consume();
                remindMeLater();
            }
        }
    });
    remindMeLaterButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            remindMeLater();
        }
    });
    buttonPanel.add(registerButton);
    buttonPanel.add(remindMeLaterButton);
    buttonPanel.add(doNotRegisterButton);
    addDivider(buttonPanel, TOP, true);
    gbc.gridx = 0;
    gbc.gridy = 14;
    gbc.fill = HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(5, 10, 0, 10);
    gbc.gridwidth = 2;
    mainPanel.add(buttonPanel, gbc);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(mainPanel, CENTER);

    pack();
    setResizable(false);
    // Center the dialog on the screen (we do not have the parent)
    Dimension dimension = getToolkit().getScreenSize();
    Rectangle abounds = getBounds();
    setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2);
    setSize(getPreferredSize());
}

From source file:edu.ku.brc.specify.utilapps.ERDVisualizer.java

public ERDVisualizer() {
    boolean showTreeHierarchy = false;

    Locale.setDefault(currLang);//  w  w  w .  ja  va2s  . c  om
    UIRegistry.setResourceLocale(currLang);

    Vector<DBTableInfo> tables = DBTableIdMgr.getInstance().getTables();
    Collections.sort(tables);

    SchemaLocalizerXMLHelper schemaXMLHelper = new SchemaLocalizerXMLHelper(SpLocaleContainer.CORE_SCHEMA,
            DBTableIdMgr.getInstance());
    schemaXMLHelper.load(true);
    schemaXMLHelper.setTitlesIntoSchema();

    ERDTable.setDisplayType(showTreeHierarchy ? ERDTable.DisplayType.Title : ERDTable.DisplayType.All);

    tblTracker = new TableTracker();

    String schemDirName = adjustFileNameForLocale("schema%s");

    final File localSchemaDir = new File(schemDirName);
    if (!localSchemaDir.exists()) {
        localSchemaDir.mkdir();
    } else {
        try {
            FileUtils.cleanDirectory(localSchemaDir);

        } catch (Exception ex) {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ERDVisualizer.class, ex);
            ex.printStackTrace();
        }
    }

    this.schemaDir = localSchemaDir;

    JPanel p = new JPanel(new BorderLayout());
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    p.add(mainPanel = new ERDPanel(tblTracker), BorderLayout.CENTER);
    setContentPane(new JScrollPane(p));
    p.setBackground(Color.WHITE);
    mainPanel.setBackground(Color.WHITE);

    try {
        File templateFile = new File(
                UIRegistry.getDefaultWorkingPath() + File.separator + "site/template.html");
        mapTemplate = FileUtils.readFileToString(templateFile);

    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ERDVisualizer.class, ex);
        ex.printStackTrace();
    }

    if (StringUtils.isEmpty(mapTemplate)) {
        System.err.println("The template file is empty!");
    }

    try {
        File srcDir = new File(UIRegistry.getDefaultWorkingPath() + File.separator + "site");
        for (File f : srcDir.listFiles()) {
            if (!f.getName().startsWith(".")) {
                File dst = new File(UIRegistry.getDefaultWorkingPath() + File.separator + schemDirName
                        + File.separator + f.getName());
                if (!FilenameUtils.getExtension(f.getName()).toLowerCase().equals("html")) {
                    FileUtils.copyFile(f, dst);
                }
            }
        }
    } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ERDVisualizer.class, ex);
        ex.printStackTrace();
    }

    // Choose what to display

    if (!showTreeHierarchy) {
        advance();

        int period = isDoShadow() ? 10000 : 1000;
        int delay = isDoShadow() ? 5000 : 1000;
        timer = new Timer();

        if (true)

        {
            timer.scheduleAtFixedRate(new TimerTask() {
                public void run() {
                    advance();
                }
            }, period, delay);
        }
    } else {
        ERDTable.setDisplayType(ERDTable.DisplayType.Title);

        //this.tblTracker.setFont(this.tblTracker.getFont().deriveFont((float)10.0));
        ERDTable root = null;

        boolean doCollectionSchema = true;

        if (doCollectionSchema) {
            root = tblTracker.getTable("Discipline");

            //                                                skip,  processKids, alwaysAKid, processAnyRel, okWhenParent
            tblTracker.addNodeInfo("Agent", false, true, true, false, null);
            tblTracker.addNodeInfo("Determination", false, true, true, true, null);
            tblTracker.addNodeInfo("ConservDescription", false, true, true, true, null);

            tblTracker.addNodeInfo("Attachment", true, true, true, false, null);
            tblTracker.addNodeInfo("AttributeDef", true, true, true, false, null);
            tblTracker.addNodeInfo("SpAppResourceDir", true, true, true, false, null);
            tblTracker.addNodeInfo("SpLocaleContainer", true, true, true, false, null);
            tblTracker.addNodeInfo("DeaccessionPreparation", true, true, true, false, null);
            tblTracker.addNodeInfo("OtherIdentifier", true, true, true, false, null);
            tblTracker.addNodeInfo("CollectionRelationship", true, true, true, false, null);
            tblTracker.addNodeInfo("ProjectCollectionObject", true, true, true, false, null);
            tblTracker.addNodeInfo("CollectionObjectAttr", true, true, true, false, null);
            tblTracker.addNodeInfo("CollectionObjectAttachment", true, true, true, false, null);
            tblTracker.addNodeInfo("ConservDescriptionAttachment", true, true, true, false, null);
            tblTracker.addNodeInfo("ConservEventAttachment", true, true, true, false, null);

            // No Kids
            tblTracker.addNodeInfo("Discipline", false, false, true, false, null);
            tblTracker.addNodeInfo("Collection", false, false, true, false, null);
            tblTracker.addNodeInfo("Taxon", false, false, true, false, null);
            tblTracker.addNodeInfo("TaxonCitation", false, false, true, false, null);
            //                tblTracker.addNodeInfo("DeterminationCitation",  false, false, true,  false, null);
            tblTracker.addNodeInfo("ReferenceWork", false, false, true, false, null);
            tblTracker.addNodeInfo("Journal", false, false, true, false, null);
            tblTracker.addNodeInfo("CollectingEvent", false, false, true, false, null);
            tblTracker.addNodeInfo("Locality", false, false, true, false, null);
            tblTracker.addNodeInfo("Geography", false, false, true, false, null);
            tblTracker.addNodeInfo("PaleoContext", false, false, true, false, null);
            tblTracker.addNodeInfo("LithoStrat", false, false, true, false, null);
            tblTracker.addNodeInfo("GeologicTimePeriod", false, false, true, false, null);
            tblTracker.addNodeInfo("CollectionObjectCitation", false, false, true, false, null);
            tblTracker.addNodeInfo("Accession", false, false, true, false, null);
            tblTracker.addNodeInfo("AccessionAuthorization", false, false, true, false, null);
            tblTracker.addNodeInfo("AccessionAgent", false, false, true, false, null);
            tblTracker.addNodeInfo("Agent", false, false, true, false, null);
            tblTracker.addNodeInfo("Preparation", false, false, true, false, null);
            tblTracker.addNodeInfo("PrepType", false, false, true, false, null);
            tblTracker.addNodeInfo("RepositoryAgreement", false, false, true, false, null);
            tblTracker.addNodeInfo("ConservEvent", false, false, true, false, null);

            tblTracker.addNodeInfo("DNASequence", false, false, true, false, null);
            tblTracker.addNodeInfo("TreatmentEvent", false, false, true, false, null);
            tblTracker.addNodeInfo("Ipm", false, false, true, false, null);
            tblTracker.addNodeInfo("FieldNotebook", false, false, true, false, null);
            tblTracker.addNodeInfo("FieldNotebookPageSet", false, false, true, false, null);
            tblTracker.addNodeInfo("FieldNotebookPage", false, false, true, false, null);

            NodeInfo det = tblTracker.getNodeInfo("Determination");
            det.addKid(tblTracker.getTable("Taxon"));
            //                det.addKid(tblTracker.getTable("DeterminationStatus"));

            NodeInfo ni = tblTracker.getNodeInfo("Taxon");
            ni.addKid(tblTracker.getTable("TaxonCitation"));

            ni = tblTracker.getNodeInfo("Discipline");
            ni.addKid(tblTracker.getTable("Collection"));

            ni = tblTracker.getNodeInfo("Collection");
            ni.addKid(tblTracker.getTable("FieldNotebook"));
            ni.addKid(tblTracker.getTable("CollectionObject"));

            ni = tblTracker.getNodeInfo("CollectionObjectCitation");
            ni.addKid(tblTracker.getTable("ReferenceWork"));

            ni = tblTracker.getNodeInfo("TaxonCitation");
            ni.addKid(tblTracker.getTable("ReferenceWork"));

            ni = tblTracker.getNodeInfo("ReferenceWork");
            ni.setOkToDuplicate(true);
            ni.addKid(tblTracker.getTable("Journal"));

            ni = tblTracker.getNodeInfo("GeologicTimePeriod");
            ni.setOkToDuplicate(true);

            ni = tblTracker.getNodeInfo("Journal");
            ni.setOkToDuplicate(true);

            ni = tblTracker.getNodeInfo("CollectingEvent");
            ni.addKid(tblTracker.getTable("Locality"));

            ni = tblTracker.getNodeInfo("CollectionObject");
            ni.addKid(tblTracker.getTable("CollectingEvent"));
            ni.addKid(tblTracker.getTable("PaleoContext"));
            ni.addKid(tblTracker.getTable("Accession"));
            ni.addKid(tblTracker.getTable("DNASequence"));
            ni.addKid(tblTracker.getTable("TreatmentEvent"));
            ni.addKid(tblTracker.getTable("Ipm"));

            ni = tblTracker.getNodeInfo("Locality");
            ni.addKid(tblTracker.getTable("Geography"));

            ni = tblTracker.getNodeInfo("PaleoContext");
            ni.addKid(tblTracker.getTable("LithoStrat"));
            ni.addKid(tblTracker.getTable("GeologicTimePeriod"));

            ni = tblTracker.getNodeInfo("DeterminationCitation");
            ni.addKid(tblTracker.getTable("ReferenceWork"));

            ni = tblTracker.getNodeInfo("Preparation");
            ni.addKid(tblTracker.getTable("PrepType"));

            ni = tblTracker.getNodeInfo("Accession");
            ni.addKid(tblTracker.getTable("AccessionAuthorization"));
            ni.addKid(tblTracker.getTable("AccessionAgent"));
            ni.addKid(tblTracker.getTable("RepositoryAgreement"));
            //ni.addKid(tblTracker.getTable("Attachment"));
            //protected RepositoryAgreement repositoryAgreement;

            ni = tblTracker.getNodeInfo("ConservEvent");
            ni.addKid(tblTracker.getTable("ConservRecommendation"));

            ni = tblTracker.getNodeInfo("FieldNotebook");
            ni.addKid(tblTracker.getTable("FieldNotebookPageSet"));

            ni = tblTracker.getNodeInfo("FieldNotebookPageSet");
            ni.addKid(tblTracker.getTable("FieldNotebookPage"));

        } else {
            root = tblTracker.getTable("SpAppResourceDir");

            //                                           skip,  processKids, alwaysAKid, processAnyRel, okWhenParent
            //tblTracker.addNodeInfo("Agent",              false, true,        true,       false,         null);

            // No Kids
            tblTracker.addNodeInfo("SpAppResourceData", false, false, true, false, null);
            tblTracker.addNodeInfo("Collection", false, false, true, false, null);
            tblTracker.addNodeInfo("Discipline", false, false, true, false, null);
            tblTracker.addNodeInfo("SpecifyUser", false, false, true, false, null);
            tblTracker.addNodeInfo("SpAppResource", false, false, true, false, null);
            tblTracker.addNodeInfo("SpViewSetObj", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIViewSet", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIView", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIViewDef", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIAltView", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIColumn", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIRow", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUICell", false, false, true, false, null);

            NodeInfo ni = tblTracker.getNodeInfo("SpAppResourceDir");
            ni.addKid(tblTracker.getTable("SpAppResource"));
            ni.addKid(tblTracker.getTable("SpViewSetObj"));
            //ni.addKid(tblTracker.getTable("Collection"));
            //ni.addKid(tblTracker.getTable("Discipline"));
            //ni.addKid(tblTracker.getTable("SpecifyUser"));

            ni = tblTracker.getNodeInfo("SpAppResource");
            ni.addKid(tblTracker.getTable("SpAppResourceData"));

            ni = tblTracker.getNodeInfo("SpViewSetObj");
            ni.addKid(tblTracker.getTable("SpAppResourceData"));
            ni.addKid(tblTracker.getTable("SpUIViewSet"));

            ni = tblTracker.getNodeInfo("SpUIViewSet");
            ni.addKid(tblTracker.getTable("SpUIView"));
            ni.addKid(tblTracker.getTable("SpUIViewDef"));

            ni = tblTracker.getNodeInfo("SpUIView");
            ni.addKid(tblTracker.getTable("SpUIAltView"));

            ni = tblTracker.getNodeInfo("SpUIViewDef");
            ni.addKid(tblTracker.getTable("SpUIColumn"));
            ni.addKid(tblTracker.getTable("SpUIRow"));

            ni = tblTracker.getNodeInfo("SpUIRow");
            ni.addKid(tblTracker.getTable("SpUICell"));
            //ni.addKid(tblTracker.getTable("SpUIViewDef"));

            //ni = tblTracker.getNodeInfo("SpUIAltView");
            //ni.addKid(tblTracker.getTable("SpUIView"));
            //ni.addKid(tblTracker.getTable("SpUIViewDef"));

            ni = tblTracker.getNodeInfo("SpAppResourceData");
            ni.setOkToDuplicate(true);

            if (false) {
                NodeInfo det = tblTracker.getNodeInfo("Determination");
                det.addKid(tblTracker.getTable("Taxon"));
                //                    det.addKid(tblTracker.getTable("DeterminationStatus"));

                ni = tblTracker.getNodeInfo("Taxon");
                ni.addKid(tblTracker.getTable("TaxonCitation"));

                ni = tblTracker.getNodeInfo("CollectionObjectCitation");
                ni.addKid(tblTracker.getTable("ReferenceWork"));

                ni = tblTracker.getNodeInfo("TaxonCitation");
                ni.addKid(tblTracker.getTable("ReferenceWork"));

                ni = tblTracker.getNodeInfo("ReferenceWork");
                ni.setOkToDuplicate(true);
                ni.addKid(tblTracker.getTable("Journal"));

                ni = tblTracker.getNodeInfo("GeologicTimePeriod");
                ni.setOkToDuplicate(true);

                ni = tblTracker.getNodeInfo("Journal");
                ni.setOkToDuplicate(true);

                ni = tblTracker.getNodeInfo("CollectingEvent");
                ni.addKid(tblTracker.getTable("Locality"));

                ni = tblTracker.getNodeInfo("CollectionObject");
                ni.addKid(tblTracker.getTable("CollectingEvent"));
                ni.addKid(tblTracker.getTable("PaleoContext"));
                ni.addKid(tblTracker.getTable("Accession"));

                ni = tblTracker.getNodeInfo("Locality");
                ni.addKid(tblTracker.getTable("Geography"));

                ni = tblTracker.getNodeInfo("PaleoContext");
                ni.addKid(tblTracker.getTable("LithoStrat"));
                ni.addKid(tblTracker.getTable("GeologicTimePeriod"));

                ni = tblTracker.getNodeInfo("DeterminationCitation");
                ni.addKid(tblTracker.getTable("ReferenceWork"));

                ni = tblTracker.getNodeInfo("Preparation");
                ni.addKid(tblTracker.getTable("PrepType"));

                ni = tblTracker.getNodeInfo("Accession");
                ni.addKid(tblTracker.getTable("AccessionAuthorization"));
                ni.addKid(tblTracker.getTable("AccessionAgent"));
                ni.addKid(tblTracker.getTable("RepositoryAgreement"));
            }

        }

        if (false) {
            NodeInfo ni = tblTracker.getNodeInfo("Agent");
            ni.setOkToDuplicate(true);

            String[] toAddAgent = { "CollectionObject", "Accession", "Determination", "Preparation", };
            for (String name : toAddAgent) {
                ni = tblTracker.getNodeInfo(name);
                ni.addKid(tblTracker.getTable("Agent"));
            }
        }

        processAsTree(root, 0);
        mainPanel.addTree(root);

        final SwingWorker worker = new SwingWorker() {
            public Object construct() {
                try {
                    Thread.sleep(3000);

                } catch (Exception ex) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ERDVisualizer.class, ex);
                    ex.printStackTrace();
                }
                return null;
            }

            //Runs on the event-dispatching thread.
            public void finished() {
                generate();
                System.out.println("Done.");
            }
        };
        worker.start();
    }

    createIndexFile();
}

From source file:com.sshtools.sshterm.SshTermSessionPanel.java

/**
 *
 *
 * @param application/*from  w  w w . j a  v  a  2  s.c o m*/
 *
 * @throws SshToolsApplicationException
 */
public void init(SshToolsApplication application) throws SshToolsApplicationException {
    super.init(application);

    //  Additional connection tabs
    additionalTabs = new SshToolsConnectionTab[] { new SshTermTerminalTab() };

    //  Printing page format
    try {
        if (System.getSecurityManager() != null) {
            AccessController.checkPermission(new RuntimePermission("queuePrintJob"));
        }

        try {
            PrinterJob job = PrinterJob.getPrinterJob();

            if (job == null) {
                throw new IOException("Could not get print page format.");
            }

            pageFormat = job.defaultPage();

            if (PreferencesStore.preferenceExists(PREF_PAGE_FORMAT_ORIENTATION)) {
                pageFormat.setOrientation(
                        PreferencesStore.getInt(PREF_PAGE_FORMAT_ORIENTATION, PageFormat.LANDSCAPE));

                Paper paper = new Paper();
                paper.setImageableArea(PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_X, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_Y, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_IMAGEABLE_H, 0));
                paper.setSize(PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_W, 0),
                        PreferencesStore.getDouble(PREF_PAGE_FORMAT_SIZE_H, 0));
                pageFormat.setPaper(paper);
            }
        } catch (Exception e) {
            showExceptionMessage("Error", e.getMessage());
        }
    } catch (AccessControlException ace) {
        ace.printStackTrace();
    }

    enableEvents(VDU_EVENTS);

    // Set up the actions
    initActions();

    // Create the status bar
    statusBar = new StatusBar();

    dataListener = new DataNotificationListener(statusBar);

    // Create our terminal emulation object
    try {
        emulation = createEmulation();
    } catch (IOException ioe) {
        throw new SshToolsApplicationException(ioe);
    }

    emulation.addTerminalListener(this);

    // Set a scrollbar for the terminal - doesn't seem to be as simple as this
    scrollBar = new JScrollBar(JScrollBar.VERTICAL);
    emulation.setBufferSize(1000);

    // Create our swing terminal and add it to the main frame
    terminal = new TerminalPanel(emulation) {

        public void processEvent(AWTEvent evt) {
            /** We can't add a MouseWheelListener because it was not available in 1.3, so direct processing of events is necessary */
            if (evt instanceof MouseEvent && evt.getID() == 507) {
                try {
                    Method m = evt.getClass().getMethod("getWheelRotation", new Class[] {});
                    SshTermSessionPanel.this.scrollBar.setValue(SshTermSessionPanel.this.scrollBar.getValue()
                            + (SshTermSessionPanel.this.scrollBar.getUnitIncrement()
                                    * ((Integer) m.invoke(evt, new Object[] {})).intValue()
                                    * PreferencesStore.getInt(PREF_MOUSE_WHEEL_INCREMENT, 1)));

                } catch (Throwable t) {
                }
            } else {
                super.processEvent(evt);
            }
        }

        public void copyNotify() {
            copyAction.actionPerformed(null);
        }

    };
    terminal.requestFocus();
    terminal.setScrollbar(scrollBar);
    terminal.addMouseMotionListener(this);

    //terminal.addMouseWheelListener(this);
    // Center panel with terminal and scrollbar
    JPanel center = new JPanel(new BorderLayout());
    center.setBackground(Color.red);
    center.add(terminal, BorderLayout.CENTER);
    center.add(scrollBar, BorderLayout.EAST);

    // Show the context menu on mouse button 3 (right click)
    terminal.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            if ((evt.getModifiers() & MouseEvent.BUTTON3_MASK) > 0) {
                getContextMenu().setLabel(getApplication().getApplicationName());
                getContextMenu().show(terminal, evt.getX(), evt.getY());
            } else if ((evt.getModifiers() & MouseEvent.BUTTON2_MASK) > 0) {
                pasteAction.actionPerformed(null);
            }
        }
    });

    //
    //        JPanel top = new JPanel(new BorderLayout());
    //        top.add(getJMenuBar(), BorderLayout.NORTH);
    //        top.add(north, BorderLayout.SOUTH);
    setLayout(new BorderLayout());
    add(center, BorderLayout.CENTER);

    //        add(top, BorderLayout.NORTH);
    // Make sure that the swing terminal has focus
    terminal.requestFocus();
}