Example usage for javax.swing JLabel setPreferredSize

List of usage examples for javax.swing JLabel setPreferredSize

Introduction

In this page you can find the example usage for javax.swing JLabel setPreferredSize.

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java

public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration,
        final OpenAnalysisJobActionListener openAnalysisJobActionListener) {
    super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT);
    _file = file;//from   w w w .j a v  a2 s  .  co  m
    _openAnalysisJobActionListener = openAnalysisJobActionListener;

    setLayout(new BorderLayout());
    setBorder(WidgetUtils.BORDER_LIST_ITEM);

    final AnalysisJobMetadata metadata = getMetadata(configuration);
    final String jobName = metadata.getJobName();
    final String jobDescription = metadata.getJobDescription();
    final String datastoreName = metadata.getDatastoreName();

    final boolean isDemoJob = isDemoJob(metadata);

    final DCPanel labelListPanel = new DCPanel();
    labelListPanel.setLayout(new VerticalLayout(4));
    labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0));

    final String title;
    final String filename = file.getName().getBaseName();
    if (Strings.isNullOrEmpty(jobName)) {
        final String extension = FileFilters.ANALYSIS_XML.getExtension();
        if (filename.toLowerCase().endsWith(extension)) {
            title = filename.substring(0, filename.length() - extension.length());
        } else {
            title = filename;
        }
    } else {
        title = jobName;
    }

    final JButton titleButton = new JButton(title);
    titleButton.setFont(WidgetUtils.FONT_HEADER1);
    titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM);
    titleButton.setHorizontalAlignment(SwingConstants.LEFT);
    titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM));
    titleButton.setToolTipText("Open job");
    titleButton.setOpaque(false);
    titleButton.setMargin(new Insets(0, 0, 0, 0));
    titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    titleButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                _openAnalysisJobActionListener.openFile(_file);
            }
        }
    });

    final JButton executeButton = new JButton(executeIcon);
    executeButton.setOpaque(false);
    executeButton.setToolTipText("Execute job directly");
    executeButton.setMargin(new Insets(0, 0, 0, 0));
    executeButton.setBorderPainted(false);
    executeButton.setHorizontalAlignment(SwingConstants.RIGHT);
    executeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE);
                final String question = "Are you sure you want to execute the job\n'" + title + "'?";
                final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?",
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge);
                if (choice == JOptionPane.YES_OPTION) {
                    final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file);
                    if (injector != null) {
                        final ResultWindow resultWindow = injector.getInstance(ResultWindow.class);
                        resultWindow.open();
                        resultWindow.startAnalysis();
                    }
                }
            }
        }
    });

    final DCPanel titlePanel = new DCPanel();
    titlePanel.setLayout(new BorderLayout());
    titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER);
    titlePanel.add(executeButton, BorderLayout.EAST);

    labelListPanel.add(titlePanel);

    if (!Strings.isNullOrEmpty(jobDescription)) {
        String desc = StringUtils.replaceWhitespaces(jobDescription, " ");
        desc = StringUtils.replaceAll(desc, "  ", " ");
        final JLabel label = new JLabel(desc);
        label.setFont(WidgetUtils.FONT_SMALL);
        labelListPanel.add(label);
    }

    final Icon icon;
    {
        if (!StringUtils.isNullOrEmpty(datastoreName)) {
            final JLabel label = new JLabel(" " + datastoreName);
            label.setFont(WidgetUtils.FONT_SMALL);
            labelListPanel.add(label);

            final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName);
            if (isDemoJob) {
                icon = demoBadgeIcon;
            } else {
                icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore);
            }
        } else {
            icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE);
        }
    }

    final JLabel iconLabel = new JLabel(icon);
    iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));

    add(iconLabel, BorderLayout.WEST);
    add(labelListPanel, BorderLayout.CENTER);
}

From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java

/**
 * Create the FlatButton panel - a panel which contains graphical representations of the options available
 * to the user when interacting with the software.
 *//*from w ww  .  j ava 2  s .c  om*/
private void createButtonPanel() {

    spreadsheetFunctionPanel = new JPanel();
    spreadsheetFunctionPanel.setLayout(new BoxLayout(spreadsheetFunctionPanel, BoxLayout.LINE_AXIS));
    spreadsheetFunctionPanel.setBackground(UIHelper.BG_COLOR);

    addRow = new JLabel(addRowButton);
    addRow.setToolTipText("<html><b>add row</b>" + "<p>add a new row to the table</p></html>");
    addRow.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            addRow.setIcon(addRowButton);
            showMultipleRowsGUI();
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            addRow.setIcon(addRowButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addRow.setIcon(addRowButton);
        }
    });

    deleteRow = new JLabel(deleteRowButton);
    deleteRow.setToolTipText("<html><b>remove row</b>" + "<p>remove selected row from table</p></html>");
    deleteRow.setEnabled(false);
    deleteRow.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            deleteRow.setIcon(deleteRowButton);
            if (table.getSelectedRow() != -1) {
                if (!(table.getSelectedRowCount() > 1)) {
                    spreadsheetFunctions.deleteRow(table.getSelectedRow());
                } else {
                    spreadsheetFunctions.deleteRow(table.getSelectedRows());
                }

            }
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            deleteRow.setIcon(deleteRowButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            deleteRow.setIcon(deleteRowButton);
        }
    });

    deleteColumn = new JLabel(deleteColumnButton);
    deleteColumn
            .setToolTipText("<html><b>remove column</b>" + "<p>remove selected column from table</p></html>");
    deleteColumn.setEnabled(false);
    deleteColumn.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            deleteColumn.setIcon(deleteColumnButton);
            if (!(table.getSelectedColumns().length > 1)) {
                spreadsheetFunctions.deleteColumn(table.getSelectedColumn());
            } else {
                showColumnErrorMessage();
            }
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            deleteColumn.setIcon(deleteColumnButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            deleteColumn.setIcon(deleteColumnButton);
        }
    });

    multipleSort = new JLabel(multipleSortButton);
    multipleSort.setToolTipText(
            "<html><b>multiple sort</b>" + "<p>perform a multiple sort on the table</p></html>");
    multipleSort.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            multipleSort.setIcon(multipleSortButton);
            showMultipleColumnSortGUI();
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            multipleSort.setIcon(multipleSortButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            multipleSort.setIcon(multipleSortButton);
        }
    });

    copyColDown = new JLabel(copyColDownButton);
    copyColDown.setToolTipText("<html><b>copy column downwards</b>"
            + "<p>duplicate selected column and copy it from the current</p>"
            + "<p>position down to the final row in the table</p></html>");
    copyColDown.setEnabled(false);
    copyColDown.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent mouseEvent) {
            copyColDown.setIcon(copyColDownButton);
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            copyColDown.setIcon(copyColDownButtonOver);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            copyColDown.setIcon(copyColDownButton);

            final int row = table.getSelectedRow();
            final int col = table.getSelectedColumn();

            if (row != -1 && col != -1) {
                JOptionPane copyColDownConfirmationPane = new JOptionPane(
                        "<html><b>Confirm Copy of Column...</b><p>Are you sure you wish to copy "
                                + "this column downwards?</p><p>This Action can not be undone!</p></html>",
                        JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);

                copyColDownConfirmationPane.setIcon(copyColumnDownWarningIcon);
                UIHelper.applyOptionPaneBackground(copyColDownConfirmationPane, UIHelper.BG_COLOR);

                copyColDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent event) {
                        if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                            int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString());
                            parentFrame.hideSheet();
                            if (lastOptionAnswer == JOptionPane.YES_OPTION) {
                                spreadsheetFunctions.copyColumnDownwards(row, col);
                            }
                        }
                    }
                });
                parentFrame.showJDialogAsSheet(
                        copyColDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Column?"));
            }
        }
    });

    copyRowDown = new JLabel(copyRowDownButton);
    copyRowDown.setToolTipText(
            "<html><b>copy row downwards</b>" + "<p>duplicate selected row and copy it from the current</p>"
                    + "<p>position down to the final row</p></html>");
    copyRowDown.setEnabled(false);
    copyRowDown.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent mouseEvent) {
            copyRowDown.setIcon(copyRowDownButton);
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            copyRowDown.setIcon(copyRowDownButtonOver);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            copyRowDown.setIcon(copyRowDownButton);

            final int row = table.getSelectedRow();

            JOptionPane copyRowDownConfirmationPane = new JOptionPane(
                    "<html><b>Confirm Copy of Row...</b><p>Are you sure you wish to copy "
                            + "this row downwards?</p><p>This Action can not be undone!</p>",
                    JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);

            copyRowDownConfirmationPane.setIcon(copyRowDownWarningIcon);

            UIHelper.applyOptionPaneBackground(copyRowDownConfirmationPane, UIHelper.BG_COLOR);

            copyRowDownConfirmationPane.addPropertyChangeListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent event) {
                    if (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) {
                        int lastOptionAnswer = Integer.valueOf(event.getNewValue().toString());
                        parentFrame.hideSheet();
                        if (lastOptionAnswer == JOptionPane.YES_OPTION) {
                            spreadsheetFunctions.copyRowDownwards(row);
                        }
                    }
                }
            });
            parentFrame.showJDialogAsSheet(
                    copyRowDownConfirmationPane.createDialog(Spreadsheet.this, "Copy Row Down?"));
        }
    });

    addProtocol = new JLabel(addProtocolButton);
    addProtocol.setToolTipText(
            "<html><b>add a protocol column</b>" + "<p>Add a protocol column to the table</p></html>");
    addProtocol.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            addProtocol.setIcon(addProtocolButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addProtocol.setIcon(addProtocolButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addProtocol.setIcon(addProtocolButton);
            if (addProtocol.isEnabled()) {
                FieldObject fo = new FieldObject(table.getColumnCount(), "Protocol REF",
                        "Protocol used for experiment", DataTypes.LIST, "", false, false, false);

                fo.setFieldList(studyDataEntryEnvironment.getProtocolNames());

                spreadsheetFunctions.addFieldToReferenceObject(fo);

                spreadsheetFunctions.addColumnAfterPosition("Protocol REF", null, fo.isRequired(), -1);
            }
        }
    });

    addFactor = new JLabel(addFactorButton);
    addFactor.setToolTipText(
            "<html><b>add a factor column</b>" + "<p>Add a factor column to the table</p></html>");
    addFactor.addMouseListener(new MouseAdapter() {
        public void mouseEntered(MouseEvent mouseEvent) {
            addFactor.setIcon(addFactorButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addFactor.setIcon(addFactorButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addFactor.setIcon(addFactorButton);
            if (addFactor.isEnabled()) {
                showAddColumnsGUI(AddColumnGUI.ADD_FACTOR_COLUMN);
            }
        }
    });

    addCharacteristic = new JLabel(addCharacteristicButton);
    addCharacteristic.setToolTipText("<html><b>add a characteristic column</b>"
            + "<p>Add a characteristic column to the table</p></html>");
    addCharacteristic.addMouseListener(new MouseAdapter() {
        public void mouseEntered(MouseEvent mouseEvent) {
            addCharacteristic.setIcon(addCharacteristicButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addCharacteristic.setIcon(addCharacteristicButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addCharacteristic.setIcon(addCharacteristicButton);
            if (addCharacteristic.isEnabled()) {
                showAddColumnsGUI(AddColumnGUI.ADD_CHARACTERISTIC_COLUMN);
            }
        }
    });

    addParameter = new JLabel(addParameterButton);
    addParameter.setToolTipText(
            "<html><b>add a parameter column</b>" + "<p>Add a parameter column to the table</p></html>");
    addParameter.addMouseListener(new MouseAdapter() {
        public void mouseEntered(MouseEvent mouseEvent) {
            addParameter.setIcon(addParameterButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            addParameter.setIcon(addParameterButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            addParameter.setIcon(addParameterButton);
            if (addParameter.isEnabled()) {
                showAddColumnsGUI(AddColumnGUI.ADD_PARAMETER_COLUMN);
            }
        }
    });

    undo = new JLabel(undoButton);
    undo.setToolTipText("<html><b>undo previous action<b></html>");
    undo.setEnabled(undoManager.canUndo());
    undo.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            undo.setIcon(undoButton);
            undoManager.undo();

            if (highlightActive) {
                setRowsToDefaultColor();
            }
            table.addNotify();
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            undo.setIcon(undoButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            undo.setIcon(undoButton);
        }
    });

    redo = new JLabel(redoButton);
    redo.setToolTipText("<html><b>redo action<b></html>");
    redo.setEnabled(undoManager.canRedo());
    redo.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent mouseEvent) {
            redo.setIcon(redoButton);
            undoManager.redo();

            if (highlightActive) {
                setRowsToDefaultColor();
            }
            table.addNotify();

        }

        public void mouseEntered(MouseEvent mouseEvent) {
            redo.setIcon(redoButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            redo.setIcon(redoButton);
        }
    });

    transpose = new JLabel(transposeIcon);
    transpose.setToolTipText("<html>View a transposed version of this spreadsheet</html>");
    transpose.addMouseListener(new MouseAdapter() {

        public void mouseExited(MouseEvent mouseEvent) {
            transpose.setIcon(transposeIcon);
        }

        public void mouseEntered(MouseEvent mouseEvent) {
            transpose.setIcon(transposeIconOver);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            showTransposeSpreadsheetGUI();
        }
    });

    addButtons();

    if (studyDataEntryEnvironment != null) {
        JPanel labelContainer = new JPanel(new GridLayout(1, 1));
        labelContainer.setBackground(UIHelper.BG_COLOR);

        JLabel lab = UIHelper.createLabel(spreadsheetTitle, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR,
                JLabel.RIGHT);
        lab.setBackground(UIHelper.BG_COLOR);
        lab.setVerticalAlignment(JLabel.CENTER);
        lab.setPreferredSize(new Dimension(200, 30));

        labelContainer.add(lab);

        spreadsheetFunctionPanel.add(labelContainer);
        spreadsheetFunctionPanel.add(Box.createHorizontalStrut(10));
    }

    add(spreadsheetFunctionPanel, BorderLayout.NORTH);
}

From source file:org.isatools.isacreator.wizard.GeneralCreationAlgorithm.java

public JPanel instantiatePanel() {
    final JPanel generalQuestionCont = new JPanel();
    generalQuestionCont.setLayout(new BoxLayout(generalQuestionCont, BoxLayout.PAGE_AXIS));
    generalQuestionCont.setBackground(UIHelper.BG_COLOR);

    JLabel info = new JLabel("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>"
            + assay.getTechnologyType() + "</b></html>", JLabel.LEFT);
    UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false);

    if (assay.getTechnologyType().equals("")) {
        info.setText("<html><b>" + assay.getMeasurementEndpoint() + "</html>");
    }/*from  w w  w . j a v a2  s  . c  om*/

    info.setPreferredSize(new Dimension(300, 40));

    JPanel infoPanel = new JPanel(new GridLayout(1, 1));
    infoPanel.setBackground(UIHelper.BG_COLOR);

    infoPanel.add(info);

    generalQuestionCont.add(infoPanel);

    JPanel labelPanel = new JPanel(new GridLayout(1, 2));
    labelPanel.setBackground(UIHelper.BG_COLOR);

    labelCapture = new LabelCapture("Label");
    labelCapture.setVisible(false);

    labelUsed = new JCheckBox("Label used?", false);
    UIHelper.renderComponent(labelUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR);

    labelUsed.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            labelCapture.setVisible(labelUsed.isSelected());

        }
    });

    labelPanel.add(labelUsed);
    labelPanel.add(labelCapture);

    generalQuestionCont.add(labelPanel);

    final JPanel extractPanel = new JPanel(new GridLayout(2, 2));
    extractPanel.setBackground(UIHelper.BG_COLOR);

    extractDetails.clear();

    JLabel extractsUsedLab = UIHelper.createLabel("Sample(s) used *");
    extractsUsedLab.setHorizontalAlignment(JLabel.LEFT);
    extractsUsedLab.setVerticalAlignment(JLabel.TOP);

    final JPanel extractNameContainer = new JPanel();
    extractNameContainer.setLayout(new BoxLayout(extractNameContainer, BoxLayout.PAGE_AXIS));
    extractNameContainer.setBackground(UIHelper.BG_COLOR);

    extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1),
            ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment());

    extractDetails.add(extract);
    extractNameContainer.add(extract);

    JLabel addButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT);
    UIHelper.renderComponent(addButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    addButton.setVerticalAlignment(JLabel.TOP);
    addButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1),
                    ApplicationManager.getUserInterfaceForISASection(study).getDataEntryEnvironment());
            extractDetails.add(extract);
            extractNameContainer.add(extract);

            extractNameContainer.revalidate();
            generalQuestionCont.revalidate();
        }

    });

    addButton.setToolTipText(
            "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>");

    JLabel removeButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT);
    removeButton.setVerticalAlignment(JLabel.TOP);
    UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    removeButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            if (extractDetails.size() > 1) {
                extract = extractDetails.get(extractDetails.size() - 1);
                extractDetails.remove(extract);
                extractNameContainer.remove(extract);
                generalQuestionCont.revalidate();
            }
        }

    });
    removeButton.setToolTipText(
            "<html><b>remove previously added sample</b><p>remove the sample field last added</p></html>");

    extractPanel.add(extractsUsedLab);
    extractPanel.add(extractNameContainer);

    JPanel buttonContainer = new JPanel(new GridLayout(1, 2));
    buttonContainer.setBackground(UIHelper.BG_COLOR);

    buttonContainer.add(addButton);
    buttonContainer.add(removeButton);

    extractPanel.add(new JLabel());
    extractPanel.add(buttonContainer);

    generalQuestionCont.add(extractPanel);

    generalQuestionCont.add(Box.createVerticalStrut(5));
    generalQuestionCont.add(Box.createHorizontalGlue());

    generalQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9),
            assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR));

    return generalQuestionCont;
}

From source file:org.isatools.isacreator.wizard.MicroarrayCreationAlgorithm.java

private JPanel instantiatePanel() {
    final JPanel microArrayQuestionCont = new JPanel();
    microArrayQuestionCont.setLayout(new BoxLayout(microArrayQuestionCont, BoxLayout.PAGE_AXIS));
    microArrayQuestionCont.setOpaque(false);

    StringBuilder text = new StringBuilder("<html><b>" + assay.getMeasurementEndpoint() + "</b> using <b>"
            + assay.getTechnologyType() + "</b>");

    if (!StringUtils.isEmpty(assay.getAssayPlatform())) {
        text.append(" on <b>").append(assay.getAssayPlatform()).append("</b>");
    }//from   w w  w  .  j  av  a 2  s  .c  o  m

    JLabel info = new JLabel(text.append("</html>").toString(), JLabel.LEFT);

    UIHelper.renderComponent(info, UIHelper.VER_12_PLAIN, UIHelper.GREY_COLOR, false);
    info.setPreferredSize(new Dimension(300, 40));

    JPanel infoPanel = new JPanel(new GridLayout(1, 1));
    infoPanel.setOpaque(false);

    infoPanel.add(info);

    microArrayQuestionCont.add(infoPanel);

    // create reference sample used checkbox

    JPanel labelPanel = new JPanel(new GridLayout(2, 2));
    labelPanel.setBackground(UIHelper.BG_COLOR);

    final DataEntryForm studyUISection = ApplicationManager.getUserInterfaceForISASection(study);
    System.out.println("Study user interface is null? " + (studyUISection == null));
    System.out
            .println("Study user interface dep is null? " + (studyUISection.getDataEntryEnvironment() == null));

    label1Capture = new LabelCapture("Label (e.g. Cy3)");
    label2Capture = new LabelCapture("Label (e.g. Cy5)");
    label2Capture.setVisible(false);

    // create dye swap check box
    dyeSwapUsed = new JCheckBox("dye-swap performed?", false);
    UIHelper.renderComponent(dyeSwapUsed, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    dyeSwapUsed.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            label2Capture.setVisible(dyeSwapUsed.isSelected());

        }
    });

    labelPanel.add(UIHelper.createLabel("Label(s) used"));
    labelPanel.add(label1Capture);
    labelPanel.add(dyeSwapUsed);
    labelPanel.add(label2Capture);

    microArrayQuestionCont.add(labelPanel);

    final JPanel extractPanel = new JPanel(new GridLayout(2, 2));
    extractPanel.setOpaque(false);

    extractDetails.clear();

    JLabel extractsUsedLab = UIHelper.createLabel("sample(s) used *");
    extractsUsedLab.setHorizontalAlignment(JLabel.LEFT);
    extractsUsedLab.setVerticalAlignment(JLabel.TOP);

    final JPanel extractNameContainer = new JPanel();
    extractNameContainer.setLayout(new BoxLayout(extractNameContainer, BoxLayout.PAGE_AXIS));
    extractNameContainer.setOpaque(false);

    extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1),
            studyUISection.getDataEntryEnvironment());

    extractDetails.add(extract);
    extractNameContainer.add(extract);

    JLabel addExtractButton = new JLabel("add sample", addRecordIcon, JLabel.RIGHT);
    UIHelper.renderComponent(addExtractButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    addExtractButton.setVerticalAlignment(JLabel.TOP);
    addExtractButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            extract = new ExtractDetailsCapture("Sample " + (extractDetails.size() + 1),
                    studyUISection.getDataEntryEnvironment());
            extractDetails.add(extract);
            extractNameContainer.add(extract);

            extractNameContainer.revalidate();
            microArrayQuestionCont.revalidate();
        }
    });

    addExtractButton.setToolTipText(
            "<html><b>add new sample</b><p>add another sample (e.g. Liver, Heart, Urine, Blood)</p></html>");

    JLabel removeExtractButton = new JLabel("remove sample", removeIcon, JLabel.RIGHT);
    removeExtractButton.setVerticalAlignment(JLabel.TOP);
    UIHelper.renderComponent(removeExtractButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    removeExtractButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            if (extractDetails.size() > 1) {
                extract = extractDetails.get(extractDetails.size() - 1);
                extractDetails.remove(extract);
                extractNameContainer.remove(extract);
                microArrayQuestionCont.revalidate();
            }
        }
    });
    removeExtractButton.setToolTipText(
            "<html><b>remove previously added sample</b><p>remove the array design field last added</p></html>");

    extractPanel.add(extractsUsedLab);
    extractPanel.add(extractNameContainer);

    JPanel extractButtonContainer = new JPanel(new GridLayout(1, 2));
    extractButtonContainer.setOpaque(false);

    extractButtonContainer.add(addExtractButton);
    extractButtonContainer.add(removeExtractButton);

    extractPanel.add(new JLabel());
    extractPanel.add(extractButtonContainer);

    microArrayQuestionCont.add(extractPanel);

    // ask for array designs used...
    // create array designs panel
    final JPanel arrayDesignPanel = new JPanel(new GridLayout(2, 2));
    arrayDesignPanel.setOpaque(false);

    arrayDesignsUsed.clear();

    JLabel arrayDesignLab = UIHelper.createLabel("array design(s) used *");
    arrayDesignLab.setVerticalAlignment(JLabel.TOP);
    // the array designs container must adjust to an unknown number of fields. therefore, a JPanel with a BoxLayout
    // will be used since it is flexible!
    final JPanel arrayDesignsContainer = new JPanel();
    arrayDesignsContainer.setLayout(new BoxLayout(arrayDesignsContainer, BoxLayout.PAGE_AXIS));
    arrayDesignsContainer.setOpaque(false);

    newArrayDesign = new AutoFilterCombo(arrayDesigns, true);

    UIHelper.renderComponent(newArrayDesign, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);
    newArrayDesign.setPreferredSize(new Dimension(70, 30));

    arrayDesignsContainer.add(newArrayDesign);
    arrayDesignsUsed.add(newArrayDesign);

    JLabel addButton = new JLabel("add design", addRecordIcon, JLabel.RIGHT);

    UIHelper.renderComponent(addButton, UIHelper.VER_10_PLAIN, UIHelper.DARK_GREEN_COLOR, false);
    addButton.setVerticalAlignment(JLabel.TOP);
    addButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            newArrayDesign = new AutoFilterCombo(arrayDesigns, true);
            UIHelper.renderComponent(newArrayDesign, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);
            newArrayDesign.setPreferredSize(new Dimension(70, 30));
            arrayDesignsUsed.add(newArrayDesign);
            arrayDesignsContainer.add(newArrayDesign);
            arrayDesignsContainer.revalidate();
            microArrayQuestionCont.revalidate();
        }

    });
    addButton.setToolTipText("<html><b>add new array design</b><p>add another array design</p></html>");

    JLabel removeButton = new JLabel("remove design", removeIcon, JLabel.RIGHT);
    removeButton.setVerticalAlignment(JLabel.TOP);
    UIHelper.renderComponent(removeButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    removeButton.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            if (arrayDesignsUsed.size() > 1) {
                newArrayDesign = arrayDesignsUsed.get(arrayDesignsUsed.size() - 1);
                arrayDesignsUsed.remove(newArrayDesign);
                arrayDesignsContainer.remove(newArrayDesign);
                arrayDesignPanel.revalidate();
                microArrayQuestionCont.validate();
            }
        }

    });
    removeButton.setToolTipText(
            "<html><b>remove previously added array design</b><p>remove the array design field last added</p></html>");

    arrayDesignPanel.add(arrayDesignLab);
    arrayDesignPanel.add(arrayDesignsContainer);

    JPanel buttonContainer = new JPanel(new GridLayout(1, 2));
    buttonContainer.setOpaque(false);

    buttonContainer.add(addButton);
    buttonContainer.add(removeButton);

    arrayDesignPanel.add(new JLabel());
    arrayDesignPanel.add(buttonContainer);

    microArrayQuestionCont.add(arrayDesignPanel);

    microArrayQuestionCont.add(Box.createVerticalStrut(5));
    microArrayQuestionCont.add(Box.createHorizontalGlue());

    microArrayQuestionCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 9),
            assay.getAssayReference(), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR));

    return microArrayQuestionCont;
}

From source file:org.isatools.isacreatorconfigurator.configui.FieldInterface.java

private void instantiateFields(String initFieldName) {
    // OVERALL CONTAINER
    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
    container.setBackground(UIHelper.BG_COLOR);

    JLabel fieldDefinitionLab = new JLabel(fieldDefinitionHeader, JLabel.CENTER);
    container.add(fieldDefinitionLab);//from   w w w .j  a  v  a2  s.  c o  m

    container.add(Box.createVerticalStrut(5));

    // FIELD LABEL & INPUT BOX CONTAINER
    JPanel fieldCont = new JPanel(new GridLayout(1, 2));
    fieldCont.setBackground(UIHelper.BG_COLOR);

    fieldName = new RoundedJTextField(15);
    fieldName.setText(initFieldName);
    fieldName.setEditable(false);
    UIHelper.renderComponent(fieldName, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JLabel fieldNameLab = UIHelper.createLabel("Field Name: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    fieldCont.add(fieldNameLab);
    fieldCont.add(fieldName);
    container.add(fieldCont);

    JPanel descCont = new JPanel(new GridLayout(1, 2));
    descCont.setBackground(UIHelper.BG_COLOR);
    description = new RoundedJTextArea();
    description.setLineWrap(true);
    description.setWrapStyleWord(true);
    UIHelper.renderComponent(description, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane descScroll = new JScrollPane(description, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    descScroll.setBackground(UIHelper.BG_COLOR);
    descScroll.setPreferredSize(new Dimension(150, 65));
    descScroll.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(descScroll);

    JLabel descLab = UIHelper.createLabel("Description: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    descLab.setVerticalAlignment(JLabel.TOP);
    descCont.add(descLab);
    descCont.add(descScroll);
    container.add(descCont);

    // add datatype information
    JPanel datatypeCont = new JPanel(new GridLayout(1, 2));
    datatypeCont.setBackground(UIHelper.BG_COLOR);

    DataTypes[] allowedDataTypes = initFieldName.equals(UNIT_STR) ? new DataTypes[] { DataTypes.ONTOLOGY_TERM }
            : DataTypes.values();

    datatype = new JComboBox(allowedDataTypes);
    datatype.addActionListener(this);
    UIHelper.renderComponent(datatype, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR);

    JLabel dataTypeLab = UIHelper.createLabel("Datatype:", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    datatypeCont.add(dataTypeLab);
    datatypeCont.add(datatype);
    container.add(datatypeCont);

    defaultValContStd = new JPanel(new GridLayout(1, 2));
    defaultValContStd.setBackground(UIHelper.BG_COLOR);

    defaultValCont = Box.createHorizontalBox();
    defaultValCont.setPreferredSize(new Dimension(150, 25));

    defaultValStd = new RoundedFormattedTextField(null, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR,
            UIHelper.DARK_GREEN_COLOR);
    defaultValCont.setPreferredSize(new Dimension(120, 25));
    defaultValStd.setFormatterFactory(new DefaultFormatterFactory(
            new RegExFormatter(".*", defaultValStd, false, UIHelper.DARK_GREEN_COLOR, UIHelper.RED_COLOR,
                    UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR)));
    defaultValStd.setForeground(UIHelper.DARK_GREEN_COLOR);
    defaultValStd.setFont(UIHelper.VER_11_PLAIN);

    defaultValCont.add(defaultValStd);

    defaultValLabStd = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);

    defaultValContStd.add(defaultValLabStd);
    defaultValContStd.add(defaultValCont);
    container.add(defaultValContStd);

    defaultValContBool = new JPanel(new GridLayout(1, 2));
    defaultValContBool.setBackground(UIHelper.BG_COLOR);
    defaultValContBool.setVisible(false);

    listDataSourceCont = new JPanel(new GridLayout(2, 1));
    listDataSourceCont.setBackground(UIHelper.BG_COLOR);
    listDataSourceCont.setVisible(false);

    JLabel listValLab = UIHelper.createLabel("Please enter comma separated list of values:",
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    listDataSourceCont.add(listValLab);

    listValues = new RoundedJTextArea("SampleVal1, SampleVal2, SampleVal3", 3, 5);
    listValues.setLineWrap(true);
    listValues.setWrapStyleWord(true);
    UIHelper.renderComponent(listValues, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane listScroll = new JScrollPane(listValues, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    listScroll.setBackground(UIHelper.BG_COLOR);
    listScroll.getViewport().setBackground(UIHelper.BG_COLOR);

    listDataSourceCont.add(listScroll);
    container.add(listDataSourceCont);

    IAppWidgetFactory.makeIAppScrollPane(listScroll);

    sourceEntryPanel = new JPanel(new BorderLayout());
    sourceEntryPanel.setSize(new Dimension(125, 190));
    sourceEntryPanel.setOpaque(false);
    sourceEntryPanel.setVisible(false);

    preferredOntologySource = new JPanel();
    preferredOntologySource.setLayout(new BoxLayout(preferredOntologySource, BoxLayout.PAGE_AXIS));
    preferredOntologySource.setVisible(false);
    recommendOntologySource = new JCheckBox("Use recommended ontology source?", false);

    UIHelper.renderComponent(recommendOntologySource, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    recommendOntologySource.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (recommendOntologySource.isSelected()) {
                sourceEntryPanel.setVisible(true);
            } else {
                sourceEntryPanel.setVisible(false);
            }
        }
    });

    JPanel useOntologySourceCont = new JPanel(new GridLayout(1, 1));
    useOntologySourceCont.add(recommendOntologySource);

    preferredOntologySource.add(useOntologySourceCont);

    JPanel infoCont = new JPanel(new GridLayout(1, 1));
    JLabel infoLab = UIHelper.createLabel(
            "<html>click on the <strong>configure ontologies</strong> button to open the ontology configurator to edit the list of ontologies and search areas within an ontology</html>",
            UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);
    infoLab.setPreferredSize(new Dimension(100, 40));
    infoCont.add(infoLab);

    sourceEntryPanel.add(infoCont, BorderLayout.NORTH);

    JLabel preferredOntologiesLab = new JLabel(preferredOntologiesSidePanelIcon);
    preferredOntologiesLab.setVerticalAlignment(SwingConstants.TOP);

    sourceEntryPanel.add(preferredOntologiesLab, BorderLayout.WEST);

    ontologiesToUseModel = new DefaultTableModel(new String[0][2], ontologyColumnHeaders) {
        @Override
        public boolean isCellEditable(int i, int i1) {
            return false;
        }
    };
    ontologiesToUse = new JTable(ontologiesToUseModel);
    ontologiesToUse.getTableHeader().setBackground(UIHelper.BG_COLOR);

    try {
        ontologiesToUse.setDefaultRenderer(Class.forName("java.lang.Object"),
                new CustomSpreadsheetCellRenderer());
    } catch (ClassNotFoundException e) {
        // empty
    }

    renderTableHeader();

    JScrollPane ontologiesToUseScroller = new JScrollPane(ontologiesToUse,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    ontologiesToUseScroller.setBorder(new EmptyBorder(0, 0, 0, 0));
    ontologiesToUseScroller.setPreferredSize(new Dimension(100, 80));
    ontologiesToUseScroller.setBackground(UIHelper.BG_COLOR);
    ontologiesToUseScroller.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(ontologiesToUseScroller);

    sourceEntryPanel.add(ontologiesToUseScroller);

    JPanel buttonCont = new JPanel(new BorderLayout());
    final JLabel openConfigButton = new JLabel(ontologyConfigIcon);
    openConfigButton.setVerticalAlignment(SwingConstants.TOP);
    openConfigButton.setHorizontalAlignment(SwingConstants.RIGHT);

    MouseAdapter showOntologyConfigurator = new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            openConfigButton.setIcon(ontologyConfigIconOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            openConfigButton.setIcon(ontologyConfigIcon);
        }

        public void mousePressed(MouseEvent mouseEvent) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    if (openConfigButton.isEnabled()) {
                        openConfigButton.setIcon(ontologyConfigIcon);
                        ontologyConfig = new OntologyConfigUI(ontologiesToQuery, selectedOntologies);
                        ontologyConfig.addPropertyChangeListener("ontologySelected",
                                new PropertyChangeListener() {
                                    public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                                        selectedOntologies = (ListOrderedMap<String, RecommendedOntology>) propertyChangeEvent
                                                .getNewValue();
                                        updateTable();
                                    }
                                });
                        showPopupInCenter(ontologyConfig);
                    }
                }
            });
        }

    };

    openConfigButton.addMouseListener(showOntologyConfigurator);

    buttonCont.add(openConfigButton, BorderLayout.EAST);

    sourceEntryPanel.add(buttonCont, BorderLayout.SOUTH);
    preferredOntologySource.add(sourceEntryPanel);
    container.add(preferredOntologySource);

    String[] contents = new String[] { "true", "false" };
    defaultValBool = new

    JComboBox(contents);

    UIHelper.renderComponent(defaultValBool, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR,
            UIHelper.BG_COLOR);

    JLabel defaultValLabBool = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_12_BOLD,
            UIHelper.DARK_GREEN_COLOR);

    defaultValContBool.add(defaultValLabBool);
    defaultValContBool.add(defaultValBool);
    container.add(defaultValContBool);

    // RegExp data entry
    isInputFormatted = new JCheckBox("Is the input formatted?", false);
    isInputFormatted.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    isInputFormatted.setHorizontalAlignment(SwingConstants.LEFT);

    UIHelper.renderComponent(isInputFormatted, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    isInputFormatted.addActionListener(this);
    container.add(UIHelper.wrapComponentInPanel(isInputFormatted));

    inputFormatCont = new JPanel();

    inputFormatCont.setLayout(new BoxLayout(inputFormatCont, BoxLayout.LINE_AXIS));
    inputFormatCont.setVisible(false);
    inputFormatCont.setBackground(UIHelper.BG_COLOR);
    inputFormat = new RoundedJTextField(10);
    inputFormat.setText(".*");
    inputFormat.setSize(new Dimension(150, 19));

    inputFormat.setPreferredSize(new Dimension(160, 25));
    inputFormat.setToolTipText("Field expects a regular expression describing the input format.");
    UIHelper.renderComponent(inputFormat, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JLabel inputFormatLab = UIHelper.createLabel("Input format:", UIHelper.VER_11_BOLD,
            UIHelper.DARK_GREEN_COLOR);
    inputFormatLab.setVerticalAlignment(SwingConstants.TOP);

    inputFormatCont.add(inputFormatLab);
    inputFormatCont.add(inputFormat);
    JLabel checkRegExp = new JLabel(checkRegExIcon, JLabel.RIGHT);
    checkRegExp.setOpaque(false);
    checkRegExp.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            String regexToCheck = inputFormat.getText();

            final CheckRegExGUI regexChecker = new CheckRegExGUI(regexToCheck);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    regexChecker.createGUI();
                }
            });
            regexChecker.addPropertyChangeListener("close", new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    main.getApplicationContainer().hideSheet();
                }
            });
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    main.getApplicationContainer().showJDialogAsSheet(regexChecker);
                }
            });
        }

    }

    );
    inputFormatCont.add(checkRegExp);
    container.add(inputFormatCont);

    usesTemplateForWizard = new JCheckBox("Requires template for wizard?", false);
    usesTemplateForWizard.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    usesTemplateForWizard.setHorizontalAlignment(SwingConstants.LEFT);

    UIHelper.renderComponent(usesTemplateForWizard, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    usesTemplateForWizard.addActionListener(this);
    container.add(UIHelper.wrapComponentInPanel(usesTemplateForWizard));

    wizardTemplatePanel = new JPanel(new GridLayout(1, 2));
    wizardTemplatePanel.setVisible(false);
    wizardTemplatePanel.setBackground(UIHelper.BG_COLOR);

    wizardTemplate = new RoundedJTextArea();
    wizardTemplate.setToolTipText("A template for the wizard to auto-create the data...");
    wizardTemplate.setLineWrap(true);
    wizardTemplate.setWrapStyleWord(true);
    UIHelper.renderComponent(wizardTemplate, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane wizScroll = new JScrollPane(wizardTemplate, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    wizScroll.getViewport().setBackground(UIHelper.BG_COLOR);
    wizScroll.setPreferredSize(new Dimension(70, 60));

    IAppWidgetFactory.makeIAppScrollPane(wizScroll);

    JLabel wizardTemplateLab = UIHelper.createLabel("Template definition:", UIHelper.VER_11_BOLD,
            UIHelper.DARK_GREEN_COLOR);
    wizardTemplateLab.setVerticalAlignment(JLabel.TOP);

    wizardTemplatePanel.add(wizardTemplateLab);
    wizardTemplatePanel.add(wizScroll);

    container.add(wizardTemplatePanel);

    JPanel checkCont = new JPanel(new GridLayout(3, 2));
    checkCont.setBackground(UIHelper.BG_COLOR);
    checkCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 4),
            "Behavioural Attributes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR));

    required = new JCheckBox("Required ", true);

    UIHelper.renderComponent(required, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(required);

    acceptsMultipleValues = new JCheckBox("Allow multiple instances", false);

    UIHelper.renderComponent(acceptsMultipleValues, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(acceptsMultipleValues);
    acceptsFileLocations = new JCheckBox("Accepts file locations", false);

    acceptsFileLocations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            acceptsMultipleValues.setSelected(false);
            acceptsMultipleValues.setEnabled(!acceptsFileLocations.isSelected());
        }
    });

    UIHelper.renderComponent(acceptsFileLocations, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(acceptsFileLocations);

    hidden = new JCheckBox("hidden?", false);

    UIHelper.renderComponent(hidden, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(hidden);

    forceOntologySelection = new JCheckBox("Force ontology selection", false);
    UIHelper.renderComponent(forceOntologySelection, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    checkCont.add(forceOntologySelection);

    container.add(checkCont);

    JScrollPane contScroll = new JScrollPane(container, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    contScroll.setBorder(null);
    contScroll.setAutoscrolls(true);

    IAppWidgetFactory.makeIAppScrollPane(contScroll);

    add(contScroll, BorderLayout.NORTH);
}

From source file:org.monome.pages.MIDIFadersPage.java

public JPanel getPanel() {
    if (this.panel != null) {
        return this.panel;
    }/*  w  w w. jav a  2 s .c om*/
    JPanel panel = new JPanel();
    AnchorLayout panelLayout = new AnchorLayout();
    panel.setLayout(panelLayout);
    panel.setPreferredSize(new java.awt.Dimension(319, 148));
    panel.add(getAddMidiOutButton(), new AnchorConstraint(706, 963, 875, 521, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getUpdatePrefsButton(), new AnchorConstraint(706, 487, 875, 20, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getDelayTF(), new AnchorConstraint(347, 371, 489, 268, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getDelayLabel(), new AnchorConstraint(347, 268, 489, 20, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));

    this.getUpdatePrefsButton().addActionListener(this);
    this.getAddMidiOutButton().addActionListener(this);

    pageNameLBL = new JLabel("Page " + (this.index + 1) + ":  MIDI Faders");
    panel.add(pageNameLBL, new AnchorConstraint(0, 800, 82, 0, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getChannelL(), new AnchorConstraint(347, 710, 489, 500, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getChannelTF(), new AnchorConstraint(354, 813, 483, 710, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getCcOffsetLabel(), new AnchorConstraint(489, 268, 638, 20, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getCcOffsetTF(), new AnchorConstraint(503, 371, 625, 268, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));

    JLabel midiout = new JLabel("MIDI Out: " + this.midiDeviceName);
    panel.add(midiout, new AnchorConstraint(179, 894, 307, 20, AnchorConstraint.ANCHOR_REL,
            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    midiout.setPreferredSize(new java.awt.Dimension(279, 19));
    pageNameLBL.setPreferredSize(new java.awt.Dimension(272, 20));

    this.panel = panel;
    return panel;
}

From source file:org.monome.pages.MIDISequencerPagePoly.java

public JPanel getPanel() {
    if (this.panel != null) {
        return this.panel;
    }//  ww  w.j  a va 2 s  .  c o  m

    JPanel panel = new JPanel();
    AnchorLayout panelLayout = new AnchorLayout();
    panel.setLayout(panelLayout);
    panel.setPreferredSize(new java.awt.Dimension(490, 175));
    panel.add(getBankSizeTF(), new AnchorConstraint(717, 603, 837, 543, AnchorConstraint.ANCHOR_REL,

            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getBankSizeLabel(), new AnchorConstraint(734, 519, 814, 380, AnchorConstraint.ANCHOR_REL,

            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getJPanel1(), new AnchorConstraint(117, 947, 700, 15, AnchorConstraint.ANCHOR_REL,

            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));

    pageNameLBL = new JLabel("Page " + (this.index + 1) + ": MIDI Sequencer Poly");
    panel.add(pageNameLBL, new AnchorConstraint(0, 382, 82, 0, AnchorConstraint.ANCHOR_REL,

            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getUpdatePrefsButton(), new AnchorConstraint(717, 345, 837, 1,

            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL,

            AnchorConstraint.ANCHOR_REL));
    panel.add(getAddMidiOutButton(), new AnchorConstraint(865, 345, 985, 1,

            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL,

            AnchorConstraint.ANCHOR_REL));
    panel.add(getChannelL(), new AnchorConstraint(865, 519, 945, 380, AnchorConstraint.ANCHOR_REL,

            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    panel.add(getChannelTF(), new AnchorConstraint(848, 603, 968, 543, AnchorConstraint.ANCHOR_REL,

            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));

    JLabel midiout = new JLabel("MIDI Out: " + this.midiDeviceName);
    panel.add(midiout, new AnchorConstraint(0, 786, 82, 419, AnchorConstraint.ANCHOR_REL,

            AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
    midiout.setPreferredSize(new java.awt.Dimension(180, 14));

    this.getAddMidiOutButton().addActionListener(this);
    this.getUpdatePrefsButton().addActionListener(this);
    this.panel = panel;
    return panel;
}

From source file:org.nuclos.client.dbtransfer.DBTransferImport.java

private boolean setupPreviewPanel(List<PreviewPart> previewParts) {
    boolean blnTransferWithWarnings = false;
    jpnPreviewHeader.removeAll();//from www.ja v  a  2  s. c  o  m
    jpnPreviewFooter.removeAll();

    // setup parameter scroll pane
    jpnPreviewContent.removeAll();

    double[] rowContraints = new double[previewParts.size()];
    for (int i = 0; i < previewParts.size(); i++)
        rowContraints[i] = TableLayout.PREFERRED;
    final int iWidthBeginnigSpace = 3;
    final int iWidthSeparator = 6;

    final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate();
    JLabel lbPreviewHeaderEntity = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.step1.11", "Entit\u00e4t"));
    JLabel lbPreviewHeaderTable = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.step1.12", "Tabellenname"));
    JLabel lbPreviewHeaderRecords = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.step1.4", "Datens\u00e4tze"));
    lbPreviewHeaderRecords.setToolTipText(
            localeDelegate.getMessage("dbtransfer.import.step1.5", "Anzahl der betroffenen Datens\u00e4tze"));
    utils.initJPanel(jpnPreviewContent,
            new double[] { iWidthBeginnigSpace, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED,
                    iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED,
                    TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED },
            rowContraints);

    int iWidthEntityLabelSize = 0;
    int iWidthTableLabelSize = 0;
    int iWidthRecordsLabelSize = 0;

    int iCountNew = 0;
    int iCountDeleted = 0;
    int iCountChanged = 0;

    int iRow = 0;
    for (final PreviewPart pp : previewParts) {
        String tooltip = "";
        JLabel lbEntity = new JLabel(pp.getEntity());
        JLabel lbTable = new JLabel(pp.getTable());
        JLabel lbRecords = new JLabel(String.valueOf(pp.getDataRecords()));
        lbRecords.setHorizontalAlignment(SwingConstants.RIGHT);
        if (lbEntity.getPreferredSize().width < lbPreviewHeaderEntity.getPreferredSize().width)
            lbEntity.setPreferredSize(lbPreviewHeaderEntity.getPreferredSize());
        if (lbTable.getPreferredSize().width < lbPreviewHeaderTable.getPreferredSize().width)
            lbTable.setPreferredSize(lbPreviewHeaderTable.getPreferredSize());
        if (lbRecords.getPreferredSize().width < lbPreviewHeaderRecords.getPreferredSize().width)
            lbRecords.setPreferredSize(lbPreviewHeaderRecords.getPreferredSize());
        iWidthEntityLabelSize = iWidthEntityLabelSize < lbEntity.getPreferredSize().width
                ? lbEntity.getPreferredSize().width
                : iWidthEntityLabelSize;
        iWidthTableLabelSize = iWidthTableLabelSize < lbTable.getPreferredSize().width
                ? lbTable.getPreferredSize().width
                : iWidthTableLabelSize;
        iWidthRecordsLabelSize = iWidthRecordsLabelSize < lbRecords.getPreferredSize().width
                ? lbRecords.getPreferredSize().width
                : iWidthRecordsLabelSize;

        Icon icoStatement = null;
        switch (pp.getType()) {
        case PreviewPart.NEW:
            tooltip = localeDelegate.getMessage("dbtransfer.import.step1.6",
                    "Entit\u00e4t wird hinzugef\u00fcgt");
            icoStatement = ParameterEditor.COMPARE_ICON_NEW;
            iCountNew++;
            break;
        case PreviewPart.CHANGE:
            tooltip = localeDelegate.getMessage("dbtransfer.import.step1.7", "Entit\u00e4t wird ge\u00e4ndert");
            icoStatement = ParameterEditor.COMPARE_ICON_VALUE_CHANGED;
            iCountChanged++;
            break;
        case PreviewPart.DELETE:
            tooltip = localeDelegate.getMessage("dbtransfer.import.step1.8", "Entit\u00e4t wird gel\u00f6scht");
            icoStatement = ParameterEditor.COMPARE_ICON_DELETED;
            iCountDeleted++;
            break;
        }

        JLabel lbIcon = new JLabel(icoStatement);
        JLabel lbStatemnts = new JLabel("<html><u>"
                + localeDelegate.getMessage("dbtransfer.import.step1.9", "Script anzeigen") + "...</u></html>");
        lbStatemnts.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        lbStatemnts.addMouseListener(new MouseListener() {
            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseClicked(MouseEvent e) {
                String statements = "";
                for (String statement : pp.getStatements()) {
                    statements = statements + statement + ";\n\n";
                }
                JTextArea txtArea = new JTextArea(statements);

                txtArea.setEditable(false);
                txtArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
                JScrollPane scroll = new JScrollPane(txtArea);
                scroll.getVerticalScrollBar().setUnitIncrement(20);
                scroll.setPreferredSize(new Dimension(600, 300));
                scroll.setBorder(BorderFactory.createEmptyBorder());
                MainFrameTab overlayFrame = new MainFrameTab(
                        localeDelegate.getMessage("dbtransfer.import.step1.10", "Script f\u00fcr") + " "
                                + pp.getEntity() + " (" + pp.getTable() + ")");
                overlayFrame.setLayeredComponent(scroll);
                ifrm.add(overlayFrame);
            }
        });

        lbIcon.setToolTipText(tooltip);
        lbStatemnts.setToolTipText(tooltip);
        lbEntity.setToolTipText(tooltip);
        lbTable.setToolTipText(tooltip);

        jpnPreviewContent.add(lbEntity, "1," + iRow + ",l,c");
        jpnPreviewContent.add(lbTable, "3," + iRow + ",l,c");
        jpnPreviewContent.add(lbRecords, "5," + iRow + ",r,c");
        jpnPreviewContent.add(lbIcon, "7," + iRow + ",l,c");
        jpnPreviewContent.add(lbStatemnts, "8," + iRow + ",l,c");
        if (pp.getWarning() > 0) {
            lbIcon.setIcon(Icons.getInstance().getIconPriorityCancel16());
            blnTransferWithWarnings = true;
        }
        iRow++;
    }

    jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "2,0,2," + (iRow - 1));
    jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "4,0,4," + (iRow - 1));
    jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "6,0,6," + (iRow - 1));

    // setup preview header   
    utils.initJPanel(jpnPreviewHeader,
            new double[] { iWidthBeginnigSpace, iWidthEntityLabelSize, iWidthSeparator, iWidthTableLabelSize,
                    iWidthSeparator, iWidthRecordsLabelSize, iWidthSeparator, TableLayout.PREFERRED,
                    iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED },
            new double[] { TableLayout.PREFERRED });

    if (previewParts.isEmpty()) {
        jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.18",
                "Keine Struktur\u00e4nderungen am Datenbankschema.")), "0,0,8,0");
        return blnTransferWithWarnings;
    }

    jpnPreviewHeader.add(lbPreviewHeaderEntity, "1,0");
    jpnPreviewHeader.add(lbPreviewHeaderTable, "3,0");
    jpnPreviewHeader.add(lbPreviewHeaderRecords, "5,0");

    jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.13", "\u00c4nderung")),
            "7,0");

    // setup preview footer
    utils.initJPanel(jpnPreviewFooter, new double[] { TableLayout.FILL, TableLayout.PREFERRED,
            TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED },
            new double[] { TableLayout.PREFERRED });

    final JLabel lbCompare = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.step1.14", "\u00c4nderungen") + ":");
    final JLabel lbCompareNew = new JLabel(iCountNew + "");
    final JLabel lbCompareDeleted = new JLabel(iCountDeleted + "");
    final JLabel lbCompareValueChanged = new JLabel(iCountChanged + "");

    lbCompareNew.setIcon(ParameterEditor.COMPARE_ICON_NEW);
    lbCompareDeleted.setIcon(ParameterEditor.COMPARE_ICON_DELETED);
    lbCompareValueChanged.setIcon(ParameterEditor.COMPARE_ICON_VALUE_CHANGED);

    lbCompareNew.setToolTipText(localeDelegate.getMessage("dbtransfer.import.step1.15", "Neue Entit\u00e4ten"));
    lbCompareDeleted.setToolTipText(
            localeDelegate.getMessage("dbtransfer.import.step1.17", "Gel\u00f6schte Entit\u00e4ten"));
    lbCompareValueChanged.setToolTipText(
            localeDelegate.getMessage("dbtransfer.import.step1.16", "Ge\u00e4nderte Entit\u00e4ten"));

    jpnPreviewFooter.add(lbCompare, "1,0,r,c");
    jpnPreviewFooter.add(lbCompareNew, "2,0,r,c");
    jpnPreviewFooter.add(lbCompareValueChanged, "3,0,r,c");
    jpnPreviewFooter.add(lbCompareDeleted, "4,0,r,c");

    return blnTransferWithWarnings;
}

From source file:org.nuclos.client.ui.JInfoTabbedPane.java

private void setTabComponent(String text, int index) {
    JLabel tabComponent = new JLabel(text);
    int height = tabComponent.getFontMetrics(tabComponent.getFont()).getHeight();
    int width = tabComponent.getFontMetrics(tabComponent.getFont()).stringWidth(text + " (>999)");
    tabComponent.setPreferredSize(new Dimension(width, height));
    tabComponent.setHorizontalAlignment(SwingConstants.CENTER);
    setTabComponentAt(index, tabComponent);
}

From source file:org.nuxeo.launcher.gui.NuxeoFrame.java

protected JComponent buildFooter() {
    JLabel label = new JLabel(NuxeoLauncherGUI.getMessage("footer.label", new DateTime().toString("Y")));
    label.setForeground(Color.WHITE);
    label.setPreferredSize(new Dimension(470, 16));
    label.setFont(new Font(label.getFont().getName(), label.getFont().getStyle(), 9));
    label.setHorizontalAlignment(SwingConstants.CENTER);
    return label;
}