Example usage for javax.swing JLabel setBorder

List of usage examples for javax.swing JLabel setBorder

Introduction

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

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

private Container initContainer() {
    JPanel containerPanel = new JPanel(new CardLayout());
    JLabel loadingModelLabel = new JLabel("Loading model...");
    loadingModelLabel.setHorizontalAlignment(SwingConstants.CENTER);
    containerPanel.add(loadingModelLabel, LOADING_MODEL_ID);
    tabbedPane = new JTabbedPane();
    containerPanel.add(tabbedPane, PARAMETERS_PANEL_ID);

    // create two number of turns field
    numberOfTurnsField = new JFormattedTextField();
    numberOfTurnsField.setFocusLostBehavior(JFormattedTextField.COMMIT);
    numberOfTurnsField.setInputVerifier(new InputVerifier() {

        @Override/*from ww w.j av a  2s .  co m*/
        public boolean verify(final JComponent input) {
            if (!checkNumberOfTurnsField(true)) {
                final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                final Point locationOnScreen = numberOfTurnsField.getLocationOnScreen();
                final JLabel message = new JLabel("Please specify a (possibly floating point) number!");
                message.setBorder(new LineBorder(Color.RED, 2, true));
                if (errorPopup != null)
                    errorPopup.hide();
                errorPopup = popupFactory.getPopup(numberOfTurnsField, message, locationOnScreen.x - 10,
                        locationOnScreen.y - 30);

                errorPopup.show();

                return false;
            } else {
                if (errorPopup != null) {
                    errorPopup.hide();
                    errorPopup = null;
                }
                return true;
            }
        }
    });
    numberOfTurnsField.setText(String.valueOf(Dashboard.NUMBER_OF_TURNS));
    numberOfTurnsField
            .setToolTipText("The turn when the simulation should stop specified as an integer value.");
    numberOfTurnsField.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            wizard.clickDefaultButton();
        }
    });

    numberOfTurnsFieldPSW = new JFormattedTextField();
    numberOfTurnsFieldPSW.setFocusLostBehavior(JFormattedTextField.COMMIT);
    numberOfTurnsFieldPSW.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(final JComponent input) {
            if (!checkNumberOfTurnsField(false)) {
                final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                final Point locationOnScreen = numberOfTurnsFieldPSW.getLocationOnScreen();
                final JLabel message = new JLabel("Please specify a (possibly floating point) number!");
                message.setBorder(new LineBorder(Color.RED, 2, true));
                if (errorPopup != null)
                    errorPopup.hide();
                errorPopup = popupFactory.getPopup(numberOfTurnsFieldPSW, message, locationOnScreen.x - 10,
                        locationOnScreen.y - 30);

                errorPopup.show();

                return false;
            } else {
                if (errorPopup != null) {
                    errorPopup.hide();
                    errorPopup = null;
                }
                return true;
            }
        }
    });
    numberOfTurnsFieldPSW.setText(String.valueOf(Dashboard.NUMBER_OF_TURNS));
    numberOfTurnsFieldPSW
            .setToolTipText("The turn when the simulation should stop specified as an integer value.");
    numberOfTurnsFieldPSW.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            wizard.clickDefaultButton();
        }
    });

    // create two number of time-steps to ignore field
    numberTimestepsIgnored = new JFormattedTextField();
    numberTimestepsIgnored.setFocusLostBehavior(JFormattedTextField.COMMIT);
    numberTimestepsIgnored.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(final JComponent input) {
            if (!checkNumberTimestepsIgnored(true)) {
                final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                final Point locationOnScreen = numberTimestepsIgnored.getLocationOnScreen();
                final JLabel message = new JLabel("Please specify an integer number!");
                message.setBorder(new LineBorder(Color.RED, 2, true));
                if (errorPopup != null)
                    errorPopup.hide();
                errorPopup = popupFactory.getPopup(numberTimestepsIgnored, message, locationOnScreen.x - 10,
                        locationOnScreen.y - 30);

                errorPopup.show();

                return false;
            } else {
                if (errorPopup != null) {
                    errorPopup.hide();
                    errorPopup = null;
                }
                return true;
            }
        }
    });
    numberTimestepsIgnored.setText(String.valueOf(Dashboard.NUMBER_OF_TIMESTEPS_TO_IGNORE));
    numberTimestepsIgnored.setToolTipText(
            "The turn when the simulation should start charting specified as an integer value.");
    numberTimestepsIgnored.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            wizard.clickDefaultButton();
        }
    });

    numberTimestepsIgnoredPSW = new JFormattedTextField();
    numberTimestepsIgnoredPSW.setFocusLostBehavior(JFormattedTextField.COMMIT);
    numberTimestepsIgnoredPSW.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(final JComponent input) {
            if (!checkNumberTimestepsIgnored(false)) {
                final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                final Point locationOnScreen = numberTimestepsIgnoredPSW.getLocationOnScreen();
                final JLabel message = new JLabel("Please specify an integer number!");
                message.setBorder(new LineBorder(Color.RED, 2, true));
                if (errorPopup != null)
                    errorPopup.hide();
                errorPopup = popupFactory.getPopup(numberTimestepsIgnoredPSW, message, locationOnScreen.x - 10,
                        locationOnScreen.y - 30);

                errorPopup.show();

                return false;
            } else {
                if (errorPopup != null) {
                    errorPopup.hide();
                    errorPopup = null;
                }
                return true;
            }
        }
    });
    numberTimestepsIgnoredPSW.setText(String.valueOf(Dashboard.NUMBER_OF_TIMESTEPS_TO_IGNORE));
    numberTimestepsIgnoredPSW.setToolTipText(
            "The turn when the simulation should start charting specified as an integer value.");
    numberTimestepsIgnoredPSW.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            wizard.clickDefaultButton();
        }
    });

    onLineChartsCheckBox = new JCheckBox();
    //      onLineChartsCheckBoxPSW = new JCheckBox();
    advancedChartsCheckBox = new JCheckBox();
    advancedChartsCheckBox.setSelected(true);

    // create the scroll pane for the simple parameter setting page
    JLabel label = null;
    label = new JLabel(new ImageIcon(new ImageIcon(getClass().getResource(DECORATION_IMAGE)).getImage()
            .getScaledInstance(DECORATION_IMAGE_WIDTH, -1, Image.SCALE_SMOOTH)));
    Style.registerCssClasses(label, Dashboard.CSS_CLASS_COMMON_PANEL);
    parametersScrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    parametersScrollPane.setBorder(null);
    parametersScrollPane.setViewportBorder(null);

    breadcrumb = new Breadcrumb();
    Style.registerCssClasses(breadcrumb, CSS_ID_BREADCRUMB);

    singleRunParametersPanel = new ScrollableJPanel(new SizeProvider() {

        @Override
        public int getHeight() {
            Component component = tabbedPane.getSelectedComponent();
            if (component == null) {
                return 0;
            }
            JScrollBar scrollBar = parametersScrollPane.getHorizontalScrollBar();
            return component.getSize().height - breadcrumb.getHeight()
                    - (scrollBar.isVisible() ? scrollBar.getPreferredSize().height : 0);
        }

        @Override
        public int getWidth() {
            final int hScrollBarWidth = parametersScrollPane.getHorizontalScrollBar().getPreferredSize().width;
            final int width = dashboard.getSize().width - Page_Parameters.DECORATION_IMAGE_WIDTH
                    - hScrollBarWidth;
            return width;
        }
    });
    BoxLayout boxLayout = new BoxLayout(singleRunParametersPanel, BoxLayout.X_AXIS);
    singleRunParametersPanel.setLayout(boxLayout);
    parametersScrollPane.setViewportView(singleRunParametersPanel);

    JPanel breadcrumbPanel = new JPanel(new BorderLayout());
    breadcrumbPanel.add(breadcrumb, BorderLayout.NORTH);
    breadcrumbPanel.add(parametersScrollPane, BorderLayout.CENTER);

    final JPanel simpleForm = FormsUtils.build("p ~ p:g", "01 t:p", label, breadcrumbPanel).getPanel();
    Style.registerCssClasses(simpleForm, Dashboard.CSS_CLASS_COMMON_PANEL);

    tabbedPane.add("Single run", simpleForm);

    // create the form for the parameter sweep setting page
    tabbedPane.add("Parameter sweep", createParamsweepGUI());

    gaSearchHandler = new GASearchHandler(currentModelHandler);
    gaSearchPanel = new GASearchPanel(gaSearchHandler, this);
    tabbedPane.add("Genetic Algorithm Search", gaSearchPanel);

    return containerPanel;
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

@SuppressWarnings("unchecked")
private List<ParameterInfo> createAndDisplayAParameterPanel(
        final List<ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?>> batchParameters, final String title,
        final SubmodelInfo parent, final boolean submodelSelectionWithoutNotify,
        final IModelHandler currentModelHandler) {
    final List<ParameterMetaData> metadata = new LinkedList<ParameterMetaData>(),
            unknownFields = new ArrayList<ParameterMetaData>();
    for (final ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?> record : batchParameters) {
        final String parameterName = record.getName(), fieldName = StringUtils.uncapitalize(parameterName);
        Class<?> modelComponentType = parent == null ? currentModelHandler.getModelClass()
                : parent.getActualType();
        while (true) {
            try {
                final Field field = modelComponentType.getDeclaredField(fieldName);
                final ParameterMetaData datum = new ParameterMetaData();
                for (final Annotation element : field.getAnnotations()) {
                    if (element.annotationType().getName() != Layout.class.getName()) // Proxies
                        continue;
                    final Class<? extends Annotation> type = element.annotationType();
                    datum.verboseDescription = (String) type.getMethod("VerboseDescription").invoke(element);
                    datum.banner = (String) type.getMethod("Title").invoke(element);
                    datum.fieldName = (String) " " + type.getMethod("FieldName").invoke(element);
                    datum.imageFileName = (String) type.getMethod("Image").invoke(element);
                    datum.layoutOrder = (Double) type.getMethod("Order").invoke(element);
                }// w w  w  .  j  ava 2 s  . c  o m
                datum.parameter = record;
                if (datum.fieldName.trim().isEmpty())
                    datum.fieldName = parameterName.replaceAll("([A-Z])", " $1");
                metadata.add(datum);
                break;
            } catch (final SecurityException e) {
            } catch (final NoSuchFieldException e) {
            } catch (final IllegalArgumentException e) {
            } catch (final IllegalAccessException e) {
            } catch (final InvocationTargetException e) {
            } catch (final NoSuchMethodException e) {
            }
            modelComponentType = modelComponentType.getSuperclass();
            if (modelComponentType == null) {
                ParameterMetaData.createAndRegisterUnknown(fieldName, record, unknownFields);
                break;
            }
        }
    }
    Collections.sort(metadata);
    for (int i = unknownFields.size() - 1; i >= 0; --i)
        metadata.add(0, unknownFields.get(i));

    // initialize single run form
    final DefaultFormBuilder formBuilder = FormsUtils.build("p ~ p:g", "");
    appendMinimumWidthHintToPresentation(formBuilder, 550);

    if (parent == null) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                numberOfTurnsField.grabFocus();
            }
        });

        appendBannerToPresentation(formBuilder, "General Parameters");
        appendTextToPresentation(formBuilder, "Global parameters affecting the entire simulation");

        formBuilder.append(NUMBER_OF_TURNS_LABEL_TEXT, numberOfTurnsField);
        formBuilder.append(NUMBER_OF_TIMESTEPS_TO_IGNORE_LABEL_TEXT, numberTimestepsIgnored);

        appendCheckBoxFieldToPresentation(formBuilder, UPDATE_CHARTS_LABEL_TEXT, onLineChartsCheckBox);
        appendCheckBoxFieldToPresentation(formBuilder, DISPLAY_ADVANCED_CHARTS_LABEL_TEXT,
                advancedChartsCheckBox);
    }

    appendBannerToPresentation(formBuilder, title);

    final DefaultMutableTreeNode parentNode = (parent == null) ? parameterValueComponentTree
            : findParameterInfoNode(parent, false);

    final List<ParameterInfo> info = new ArrayList<ParameterInfo>();

    // Search for a @ConfigurationComponent annotation
    {
        String headerText = "", imagePath = "";
        final Class<?> parentType = parent == null ? currentModelHandler.getModelClass()
                : parent.getActualType();
        for (final Annotation element : parentType.getAnnotations()) { // Proxies
            if (element.annotationType().getName() != ConfigurationComponent.class.getName())
                continue;
            boolean doBreak = false;
            try {
                try {
                    headerText = (String) element.annotationType().getMethod("Description").invoke(element);
                    if (headerText.startsWith("#")) {
                        headerText = (String) parent.getActualType().getMethod(headerText.substring(1))
                                .invoke(parent.getInstance());
                    }
                    doBreak = true;
                } catch (IllegalArgumentException e) {
                } catch (SecurityException e) {
                } catch (IllegalAccessException e) {
                } catch (InvocationTargetException e) {
                } catch (NoSuchMethodException e) {
                }
            } catch (final Exception e) {
            }
            try {
                imagePath = (String) element.annotationType().getMethod("ImagePath").invoke(element);
                doBreak = true;
            } catch (IllegalArgumentException e) {
            } catch (SecurityException e) {
            } catch (IllegalAccessException e) {
            } catch (InvocationTargetException e) {
            } catch (NoSuchMethodException e) {
            }
            if (doBreak)
                break;
        }
        if (!headerText.isEmpty())
            appendHeaderTextToPresentation(formBuilder, headerText);
        if (!imagePath.isEmpty())
            appendImageToPresentation(formBuilder, imagePath);
    }

    if (metadata.isEmpty()) {
        // No fields to display.
        appendTextToPresentation(formBuilder, "No configuration is required for this module.");
    } else {
        for (final ParameterMetaData record : metadata) {
            final ai.aitia.meme.paramsweep.batch.param.ParameterInfo<?> batchParameterInfo = record.parameter;

            if (!record.banner.isEmpty())
                appendBannerToPresentation(formBuilder, record.banner);
            if (!record.imageFileName.isEmpty())
                appendImageToPresentation(formBuilder, record.imageFileName);
            appendTextToPresentation(formBuilder, record.verboseDescription);

            final ParameterInfo parameterInfo = InfoConverter.parameterInfo2ParameterInfo(batchParameterInfo);
            if (parent != null && parameterInfo instanceof ISubmodelGUIInfo) {
                //               sgi.setParentValue(parent.getActualType());
            }

            final JComponent field;
            final DefaultMutableTreeNode oldNode = findParameterInfoNode(parameterInfo, true);
            Pair<ParameterInfo, JComponent> userData = null;
            JComponent oldField = null;
            if (oldNode != null) {
                userData = (Pair<ParameterInfo, JComponent>) oldNode.getUserObject();
                oldField = userData.getSecond();
            }

            if (parameterInfo.isBoolean()) {
                field = new JCheckBox();
                boolean value = oldField != null ? ((JCheckBox) oldField).isSelected()
                        : ((Boolean) batchParameterInfo.getDefaultValue()).booleanValue();
                ((JCheckBox) field).setSelected(value);
            } else if (parameterInfo.isEnum() || parameterInfo instanceof MasonChooserParameterInfo) {
                Object[] elements = null;
                if (parameterInfo.isEnum()) {
                    final Class<Enum<?>> type = (Class<Enum<?>>) parameterInfo.getJavaType();
                    elements = type.getEnumConstants();
                } else {
                    final MasonChooserParameterInfo chooserInfo = (MasonChooserParameterInfo) parameterInfo;
                    elements = chooserInfo.getValidStrings();
                }
                final JComboBox list = new JComboBox(elements);

                if (parameterInfo.isEnum()) {
                    final Object value = oldField != null ? ((JComboBox) oldField).getSelectedItem()
                            : parameterInfo.getValue();
                    list.setSelectedItem(value);
                } else {
                    final int value = oldField != null ? ((JComboBox) oldField).getSelectedIndex()
                            : (Integer) parameterInfo.getValue();
                    list.setSelectedIndex(value);
                }

                field = list;
            } else if (parameterInfo instanceof SubmodelInfo) {
                final SubmodelInfo submodelInfo = (SubmodelInfo) parameterInfo;
                final Object[] elements = new Object[] { "Loading class information..." };
                final JComboBox list = new JComboBox(elements);
                //            field = list;

                final Object value = oldField != null
                        ? ((JComboBox) ((JPanel) oldField).getComponent(0)).getSelectedItem()
                        : new ClassElement(submodelInfo.getActualType(), null);

                new ClassCollector(this, list, submodelInfo, value, submodelSelectionWithoutNotify).execute();

                final JButton rightButton = new JButton();
                rightButton.setOpaque(false);
                rightButton.setRolloverEnabled(true);
                rightButton.setIcon(SHOW_SUBMODEL_ICON);
                rightButton.setRolloverIcon(SHOW_SUBMODEL_ICON_RO);
                rightButton.setDisabledIcon(SHOW_SUBMODEL_ICON_DIS);
                rightButton.setBorder(null);
                rightButton.setToolTipText("Display submodel parameters");
                rightButton.setActionCommand(ACTIONCOMMAND_SHOW_SUBMODEL);
                rightButton.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent arg0) {
                        if (parameterInfo instanceof SubmodelInfo) {
                            SubmodelInfo submodelInfo = (SubmodelInfo) parameterInfo;
                            int level = 0;

                            showHideSubparameters(list, submodelInfo);

                            List<String> components = new ArrayList<String>();
                            components.add(submodelInfo.getName());
                            while (submodelInfo.getParent() != null) {
                                submodelInfo = submodelInfo.getParent();
                                components.add(submodelInfo.getName());
                                level++;
                            }
                            Collections.reverse(components);
                            final String[] breadcrumbText = components.toArray(new String[components.size()]);
                            for (int i = 0; i < breadcrumbText.length; ++i)
                                breadcrumbText[i] = breadcrumbText[i].replaceAll("([A-Z])", " $1");
                            breadcrumb.setPath(
                                    currentModelHandler.getModelClassSimpleName().replaceAll("([A-Z])", " $1"),
                                    breadcrumbText);
                            Style.apply(breadcrumb, dashboard.getCssStyle());

                            // reset all buttons that are nested deeper than this to default color
                            for (int i = submodelButtons.size() - 1; i >= level; i--) {
                                JButton button = submodelButtons.get(i);
                                button.setIcon(SHOW_SUBMODEL_ICON);
                                submodelButtons.remove(i);
                            }

                            rightButton.setIcon(SHOW_SUBMODEL_ICON_RO);
                            submodelButtons.add(rightButton);
                        }
                    }
                });

                field = new JPanel(new BorderLayout());
                field.add(list, BorderLayout.CENTER);
                field.add(rightButton, BorderLayout.EAST);
            } else if (File.class.isAssignableFrom(parameterInfo.getJavaType())) {
                field = new JPanel(new BorderLayout());

                String oldName = "";
                String oldPath = "";
                if (oldField != null) {
                    final JTextField oldTextField = (JTextField) oldField.getComponent(0);
                    oldName = oldTextField.getText();
                    oldPath = oldTextField.getToolTipText();
                } else if (parameterInfo.getValue() != null) {
                    final File file = (File) parameterInfo.getValue();
                    oldName = file.getName();
                    oldPath = file.getAbsolutePath();
                }

                final JTextField textField = new JTextField(oldName);
                textField.setToolTipText(oldPath);
                textField.setInputVerifier(new InputVerifier() {

                    @Override
                    public boolean verify(final JComponent input) {
                        final JTextField inputField = (JTextField) input;
                        if (inputField.getText() == null || inputField.getText().isEmpty()) {
                            final File file = new File("");
                            inputField.setToolTipText(file.getAbsolutePath());
                            hideError();
                            return true;
                        }

                        final File oldFile = new File(inputField.getToolTipText());
                        if (oldFile.exists() && oldFile.getName().equals(inputField.getText().trim())) {
                            hideError();
                            return true;
                        }

                        inputField.setToolTipText("");
                        final File file = new File(inputField.getText().trim());
                        if (file.exists()) {
                            inputField.setToolTipText(file.getAbsolutePath());
                            inputField.setText(file.getName());
                            hideError();
                            return true;
                        } else {
                            final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                            final Point locationOnScreen = inputField.getLocationOnScreen();
                            final JLabel message = new JLabel("Please specify an existing file!");
                            message.setBorder(new LineBorder(Color.RED, 2, true));
                            if (errorPopup != null)
                                errorPopup.hide();
                            errorPopup = popupFactory.getPopup(inputField, message, locationOnScreen.x - 10,
                                    locationOnScreen.y - 30);
                            errorPopup.show();
                            return false;
                        }
                    }
                });

                final JButton browseButton = new JButton(BROWSE_BUTTON_TEXT);
                browseButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        final JFileChooser fileDialog = new JFileChooser(
                                !"".equals(textField.getToolTipText()) ? textField.getToolTipText()
                                        : currentDirectory);
                        if (!"".equals(textField.getToolTipText()))
                            fileDialog.setSelectedFile(new File(textField.getToolTipText()));
                        int dialogResult = fileDialog.showOpenDialog(dashboard);
                        if (dialogResult == JFileChooser.APPROVE_OPTION) {
                            final File selectedFile = fileDialog.getSelectedFile();
                            if (selectedFile != null) {
                                currentDirectory = selectedFile.getAbsoluteFile().getParent();
                                textField.setText(selectedFile.getName());
                                textField.setToolTipText(selectedFile.getAbsolutePath());
                            }
                        }
                    }
                });

                field.add(textField, BorderLayout.CENTER);
                field.add(browseButton, BorderLayout.EAST);
            } else if (parameterInfo instanceof MasonIntervalParameterInfo) {
                final MasonIntervalParameterInfo intervalInfo = (MasonIntervalParameterInfo) parameterInfo;

                field = new JPanel(new BorderLayout());

                String oldValueStr = String.valueOf(parameterInfo.getValue());
                if (oldField != null) {
                    final JTextField oldTextField = (JTextField) oldField.getComponent(0);
                    oldValueStr = oldTextField.getText();
                }

                final JTextField textField = new JTextField(oldValueStr);

                PercentJSlider tempSlider = null;
                if (intervalInfo.isDoubleInterval())
                    tempSlider = new PercentJSlider(intervalInfo.getIntervalMin().doubleValue(),
                            intervalInfo.getIntervalMax().doubleValue(), Double.parseDouble(oldValueStr));
                else
                    tempSlider = new PercentJSlider(intervalInfo.getIntervalMin().longValue(),
                            intervalInfo.getIntervalMax().longValue(), Long.parseLong(oldValueStr));

                final PercentJSlider slider = tempSlider;
                slider.setMajorTickSpacing(100);
                slider.setMinorTickSpacing(10);
                slider.setPaintTicks(true);
                slider.setPaintLabels(true);
                slider.addChangeListener(new ChangeListener() {
                    public void stateChanged(final ChangeEvent _) {
                        if (slider.hasFocus()) {
                            final String value = intervalInfo.isDoubleInterval()
                                    ? String.valueOf(slider.getDoubleValue())
                                    : String.valueOf(slider.getLongValue());
                            textField.setText(value);
                            slider.setToolTipText(value);
                        }
                    }
                });

                textField.setInputVerifier(new InputVerifier() {
                    public boolean verify(JComponent input) {
                        final JTextField inputField = (JTextField) input;

                        try {
                            hideError();
                            final String valueStr = inputField.getText().trim();
                            if (intervalInfo.isDoubleInterval()) {
                                final double value = Double.parseDouble(valueStr);
                                if (intervalInfo.isValidValue(valueStr)) {
                                    slider.setValue(value);
                                    return true;
                                } else
                                    showError(
                                            "Please specify a value between " + intervalInfo.getIntervalMin()
                                                    + " and " + intervalInfo.getIntervalMax() + ".",
                                            inputField);
                                return false;
                            } else {
                                final long value = Long.parseLong(valueStr);
                                if (intervalInfo.isValidValue(valueStr)) {
                                    slider.setValue(value);
                                    return true;
                                } else {
                                    showError("Please specify an integer value between "
                                            + intervalInfo.getIntervalMin() + " and "
                                            + intervalInfo.getIntervalMax() + ".", inputField);
                                    return false;
                                }
                            }
                        } catch (final NumberFormatException _) {
                            final String message = "The specified value is not a"
                                    + (intervalInfo.isDoubleInterval() ? "" : "n integer") + " number.";
                            showError(message, inputField);
                            return false;
                        }

                    }
                });

                textField.getDocument().addDocumentListener(new DocumentListener() {
                    //               private Popup errorPopup;

                    public void removeUpdate(final DocumentEvent _) {
                        textFieldChanged();
                    }

                    public void insertUpdate(final DocumentEvent _) {
                        textFieldChanged();
                    }

                    public void changedUpdate(final DocumentEvent _) {
                        textFieldChanged();
                    }

                    private void textFieldChanged() {
                        if (!textField.hasFocus()) {
                            hideError();
                            return;
                        }

                        try {
                            hideError();
                            final String valueStr = textField.getText().trim();
                            if (intervalInfo.isDoubleInterval()) {
                                final double value = Double.parseDouble(valueStr);
                                if (intervalInfo.isValidValue(valueStr))
                                    slider.setValue(value);
                                else
                                    showError("Please specify a value between " + intervalInfo.getIntervalMin()
                                            + " and " + intervalInfo.getIntervalMax() + ".", textField);
                            } else {
                                final long value = Long.parseLong(valueStr);
                                if (intervalInfo.isValidValue(valueStr))
                                    slider.setValue(value);
                                else
                                    showError("Please specify an integer value between "
                                            + intervalInfo.getIntervalMin() + " and "
                                            + intervalInfo.getIntervalMax() + ".", textField);
                            }
                        } catch (final NumberFormatException _) {
                            final String message = "The specified value is not a"
                                    + (intervalInfo.isDoubleInterval() ? "" : "n integer") + " number.";
                            showError(message, textField);
                        }
                    }
                });

                field.add(textField, BorderLayout.CENTER);
                field.add(slider, BorderLayout.SOUTH);
            } else {
                final Object value = oldField != null ? ((JTextField) oldField).getText()
                        : parameterInfo.getValue();
                field = new JTextField(value.toString());
                ((JTextField) field).addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        wizard.clickDefaultButton();
                    }
                });
            }

            final JLabel parameterLabel = new JLabel(record.fieldName);

            final String description = parameterInfo.getDescription();
            if (description != null && !description.isEmpty()) {
                parameterLabel.addMouseListener(new MouseAdapter() {

                    @Override
                    public void mouseEntered(final MouseEvent e) {
                        final DescriptionPopupFactory popupFactory = DescriptionPopupFactory.getInstance();

                        final Popup parameterDescriptionPopup = popupFactory.getPopup(parameterLabel,
                                description, dashboard.getCssStyle());

                        parameterDescriptionPopup.show();
                    }

                });
            }

            if (oldNode != null)
                userData.setSecond(field);
            else {
                final Pair<ParameterInfo, JComponent> pair = new Pair<ParameterInfo, JComponent>(parameterInfo,
                        field);
                final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(pair);
                parentNode.add(newNode);
            }

            if (field instanceof JCheckBox) {
                parameterLabel
                        .setText("<html><div style=\"margin-bottom: 4pt; margin-top: 6pt; margin-left: 4pt\">"
                                + parameterLabel.getText() + "</div></html>");
                formBuilder.append(parameterLabel, field);

                //            appendCheckBoxFieldToPresentation(
                //               formBuilder, parameterLabel.getText(), (JCheckBox) field);
            } else {
                formBuilder.append(parameterLabel, field);
                final CellConstraints constraints = formBuilder.getLayout().getConstraints(parameterLabel);
                constraints.vAlign = CellConstraints.TOP;
                constraints.insets = new Insets(5, 0, 0, 0);
                formBuilder.getLayout().setConstraints(parameterLabel, constraints);
            }

            // prepare the parameterInfo for the param sweeps
            parameterInfo.setRuns(0);
            parameterInfo.setDefinitionType(ParameterInfo.CONST_DEF);
            parameterInfo.setValue(batchParameterInfo.getDefaultValue());
            info.add(parameterInfo);
        }
    }
    appendVerticalSpaceToPresentation(formBuilder);

    final JPanel panel = formBuilder.getPanel();
    singleRunParametersPanel.add(panel);

    if (singleRunParametersPanel.getComponentCount() > 1) {
        panel.setBorder(
                BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 1, 0, 0, Color.GRAY),
                        BorderFactory.createEmptyBorder(0, 5, 0, 5)));
    } else {
        panel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    }

    Style.apply(panel, dashboard.getCssStyle());

    return info;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.wbuploader.Uploader.java

public static void showStructureErrors(Vector<UploadMessage> structureErrors) {
    JPanel pane = new JPanel(new BorderLayout());
    JLabel lbl = createLabel(getResourceString("WB_UPLOAD_BAD_STRUCTURE_MSG") + ":");
    lbl.setBorder(new EmptyBorder(3, 1, 2, 0));
    pane.add(lbl, BorderLayout.NORTH);
    JPanel lstPane = new JPanel(new BorderLayout());
    JList<?> lst = UIHelper.createList(structureErrors);
    lst.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
    lstPane.setBorder(new EmptyBorder(1, 1, 10, 1));
    lstPane.add(lst, BorderLayout.CENTER);
    pane.add(lstPane, BorderLayout.CENTER);
    CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(),
            getResourceString("WB_UPLOAD_BAD_STRUCTURE_DLG"), true, CustomDialog.OKHELP, pane);
    UIHelper.centerAndShow(dlg);/*from  ww w.  j  a va  2s .co m*/
    dlg.dispose();
}

From source file:org.nuclos.client.ui.collect.Chart.java

private void init(int iScrollPane) {
    contentPane.add(toolbar,/*from  www.j  a  v a  2 s  .c o m*/
            toolbar.getOrientation() == JToolBar.HORIZONTAL ? BorderLayout.NORTH : BorderLayout.WEST);

    // Configure table
    JFreeChart chart = new JFreeChart(new Plot() {

        @Override
        public String getPlotType() {
            return null;
        }

        @Override
        public void draw(Graphics2D arg0, Rectangle2D arg1, Point2D arg2, PlotState arg3,
                PlotRenderingInfo arg4) {
        }
    });

    panel = new ChartPanel(chart, false, false, true, false, false);
    if (bFromProperties) {
        panel.setPopupMenu(null);
    }

    if (iScrollPane == -1)
        scrollPane.add(panel, BorderLayout.CENTER);
    else {
        ((JScrollPane) scrollPane).getViewport().setBackground(panel.getBackground());

        JLabel labCorner = new JLabel();
        labCorner.setEnabled(false);
        labCorner.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, Color.GRAY));
        labCorner.setBackground(Color.LIGHT_GRAY);
        ((JScrollPane) scrollPane).setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, labCorner);

        if (iScrollPane != 2) { //both
            if (iScrollPane == 0) { // horizontal
                JPanel pnl = new ScrollPaneHeightTrackingPanel(new BorderLayout());
                pnl.add(panel, BorderLayout.CENTER);
                ((JScrollPane) scrollPane).getViewport().setView(pnl);
                ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
                ((JScrollPane) scrollPane)
                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            } else if (iScrollPane == 1) { // vertical
                JPanel pnl = new ScrollPaneWidthTrackingPanel(new BorderLayout());
                pnl.add(panel, BorderLayout.CENTER);
                ((JScrollPane) scrollPane).getViewport().setView(pnl);
                ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
                ((JScrollPane) scrollPane).setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            } else if (iScrollPane == -1) { // none
                ((JScrollPane) scrollPane).setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
                ((JScrollPane) scrollPane).setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            }
        } else {
            ((JScrollPane) scrollPane).getViewport().setView(panel);
        }
    }
}

From source file:net.technicpack.launcher.ui.InstallerFrame.java

private void setupStandardInstall(JPanel panel) {
    panel.setLayout(new GridBagLayout());

    JLabel standardSpiel = new JLabel("<html><body align=\"left\" style='margin-right:10px;'>"
            + resources.getString("launcher.installer.standardspiel") + "</body></html>");
    standardSpiel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    standardSpiel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    standardSpiel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.add(standardSpiel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(9, 0, 0, 3), 0, 0));

    panel.add(Box.createGlue(), new GridBagConstraints(0, 1, 3, 1, 1.0, 0.7, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    standardDefaultDirectory = new JCheckBox(resources.getString("launcher.installer.default"));
    standardDefaultDirectory.setOpaque(false);
    standardDefaultDirectory.setHorizontalAlignment(SwingConstants.RIGHT);
    standardDefaultDirectory.setBorder(BorderFactory.createEmptyBorder());
    standardDefaultDirectory.setIconTextGap(0);
    standardDefaultDirectory.setSelectedIcon(resources.getIcon("checkbox_closed.png"));
    standardDefaultDirectory.setIcon(resources.getIcon("checkbox_open.png"));
    standardDefaultDirectory.setFocusPainted(false);
    standardDefaultDirectory.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    standardDefaultDirectory.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    standardDefaultDirectory.setIconTextGap(6);
    standardDefaultDirectory.setSelected(settings.isPortable() || settings.getTechnicRoot().getAbsolutePath()
            .equals(SettingsFactory.getTechnicHomeDir().getAbsolutePath()));
    standardDefaultDirectory.addActionListener(new ActionListener() {
        @Override//from w w w .j ava 2  s.c  om
        public void actionPerformed(ActionEvent e) {
            useDefaultDirectoryChanged();
        }
    });
    panel.add(standardDefaultDirectory, new GridBagConstraints(0, 2, 3, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 24, 12, 0), 0, 0));

    JLabel installFolderLabel = new JLabel(resources.getString("launcher.installer.folder"));
    installFolderLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    installFolderLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    panel.add(installFolderLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 24, 0, 8), 0, 0));

    String installDir = SettingsFactory.getTechnicHomeDir().getAbsolutePath();

    if (!settings.isPortable())
        installDir = settings.getTechnicRoot().getAbsolutePath();

    standardInstallDir = new JTextField(installDir);
    standardInstallDir.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    standardInstallDir.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    standardInstallDir.setHighlighter(null);
    standardInstallDir.setEditable(false);
    standardInstallDir.setCursor(null);
    panel.add(standardInstallDir, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));

    standardSelectButton = new RoundedButton(resources.getString("launcher.installer.select"));
    standardSelectButton.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    standardSelectButton.setContentAreaFilled(false);
    standardSelectButton.setHoverForeground(LauncherFrame.COLOR_BLUE);
    standardSelectButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectStandard();
        }
    });
    panel.add(standardSelectButton, new GridBagConstraints(2, 3, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 16), 0, 0));

    useDefaultDirectoryChanged();

    panel.add(Box.createGlue(), new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    String defaultLocaleText = resources.getString("launcheroptions.language.default");
    if (!resources.isDefaultLocaleSupported()) {
        defaultLocaleText = defaultLocaleText
                .concat(" (" + resources.getString("launcheroptions.language.unavailable") + ")");
    }

    standardLanguages = new JComboBox();
    standardLanguages.addItem(new LanguageItem(ResourceLoader.DEFAULT_LOCALE, defaultLocaleText, resources));
    for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
        standardLanguages
                .addItem(new LanguageItem(resources.getCodeFromLocale(ResourceLoader.SUPPORTED_LOCALES[i]),
                        ResourceLoader.SUPPORTED_LOCALES[i].getDisplayName(ResourceLoader.SUPPORTED_LOCALES[i]),
                        resources.getVariant(ResourceLoader.SUPPORTED_LOCALES[i])));
    }
    if (!settings.getLanguageCode().equalsIgnoreCase(ResourceLoader.DEFAULT_LOCALE)) {
        Locale loc = resources.getLocaleFromCode(settings.getLanguageCode());

        for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
            if (loc.equals(ResourceLoader.SUPPORTED_LOCALES[i])) {
                standardLanguages.setSelectedIndex(i + 1);
                break;
            }
        }
    }
    standardLanguages.setBorder(new RoundBorder(LauncherFrame.COLOR_SCROLL_THUMB, 1, 10));
    standardLanguages.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    standardLanguages.setUI(new LanguageCellUI(resources));
    standardLanguages.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    standardLanguages.setBackground(LauncherFrame.COLOR_SELECTOR_BACK);
    standardLanguages.setRenderer(new LanguageCellRenderer(resources, "globe.png",
            LauncherFrame.COLOR_SELECTOR_BACK, LauncherFrame.COLOR_WHITE_TEXT));
    standardLanguages.setEditable(false);
    standardLanguages.setFocusable(false);
    standardLanguages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            standardLanguageChanged();
        }
    });
    panel.add(standardLanguages, new GridBagConstraints(0, 5, 1, 0, 0, 0, GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE, new Insets(0, 8, 8, 0), 0, 0));

    RoundedButton install = new RoundedButton(resources.getString("launcher.installer.install"));
    install.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    install.setContentAreaFilled(false);
    install.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
    install.setHoverForeground(LauncherFrame.COLOR_BLUE);
    install.setBorder(BorderFactory.createEmptyBorder(8, 56, 8, 56));
    install.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            standardInstall();
        }
    });
    panel.add(install, new GridBagConstraints(1, 5, 2, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 8, 8), 0, 0));

}

From source file:net.technicpack.launcher.ui.InstallerFrame.java

private void setupPortableMode(JPanel panel) {
    panel.setLayout(new GridBagLayout());

    JLabel portableSpiel = new JLabel("<html><body align=\"left\" style='margin-right:10px;'>"
            + resources.getString("launcher.installer.portablespiel") + "</body></html>");
    portableSpiel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    portableSpiel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    portableSpiel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.add(portableSpiel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(9, 8, 9, 3), 0, 0));

    panel.add(Box.createGlue(), new GridBagConstraints(0, 1, 3, 1, 1.0, 0.7, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    JLabel installFolderLabel = new JLabel(resources.getString("launcher.installer.folder"));
    installFolderLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    installFolderLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    panel.add(installFolderLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 24, 0, 8), 0, 0));

    String installDir = "";
    if (settings.isPortable())
        installDir = settings.getTechnicRoot().getAbsolutePath();

    portableInstallDir = new JTextField(installDir);
    portableInstallDir.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    portableInstallDir.setForeground(LauncherFrame.COLOR_BLUE);
    portableInstallDir.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    portableInstallDir.setHighlighter(null);
    portableInstallDir.setEditable(false);
    portableInstallDir.setCursor(null);//from w  ww .  j  a v  a 2s  .c o  m
    portableInstallDir.setBorder(new RoundBorder(LauncherFrame.COLOR_BUTTON_BLUE, 1, 8));
    panel.add(portableInstallDir, new GridBagConstraints(1, 2, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));

    RoundedButton selectInstall = new RoundedButton(resources.getString("launcher.installer.select"));
    selectInstall.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    selectInstall.setContentAreaFilled(false);
    selectInstall.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
    selectInstall.setHoverForeground(LauncherFrame.COLOR_BLUE);
    selectInstall.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectPortable();
        }
    });
    panel.add(selectInstall, new GridBagConstraints(2, 2, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 0, 16), 0, 0));

    panel.add(Box.createGlue(), new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    String defaultLocaleText = resources.getString("launcheroptions.language.default");
    if (!resources.isDefaultLocaleSupported()) {
        defaultLocaleText = defaultLocaleText
                .concat(" (" + resources.getString("launcheroptions.language.unavailable") + ")");
    }

    portableLanguages = new JComboBox();
    portableLanguages.addItem(new LanguageItem(ResourceLoader.DEFAULT_LOCALE, defaultLocaleText, resources));
    for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
        portableLanguages
                .addItem(new LanguageItem(resources.getCodeFromLocale(ResourceLoader.SUPPORTED_LOCALES[i]),
                        ResourceLoader.SUPPORTED_LOCALES[i].getDisplayName(ResourceLoader.SUPPORTED_LOCALES[i]),
                        resources.getVariant(ResourceLoader.SUPPORTED_LOCALES[i])));
    }
    if (!settings.getLanguageCode().equalsIgnoreCase(ResourceLoader.DEFAULT_LOCALE)) {
        Locale loc = resources.getLocaleFromCode(settings.getLanguageCode());

        for (int i = 0; i < ResourceLoader.SUPPORTED_LOCALES.length; i++) {
            if (loc.equals(ResourceLoader.SUPPORTED_LOCALES[i])) {
                portableLanguages.setSelectedIndex(i + 1);
                break;
            }
        }
    }
    portableLanguages.setBorder(new RoundBorder(LauncherFrame.COLOR_SCROLL_THUMB, 1, 10));
    portableLanguages.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    portableLanguages.setUI(new LanguageCellUI(resources));
    portableLanguages.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    portableLanguages.setBackground(LauncherFrame.COLOR_SELECTOR_BACK);
    portableLanguages.setRenderer(new LanguageCellRenderer(resources, "globe.png",
            LauncherFrame.COLOR_SELECTOR_BACK, LauncherFrame.COLOR_WHITE_TEXT));
    portableLanguages.setEditable(false);
    portableLanguages.setFocusable(false);
    portableLanguages.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            portableLanguageChanged();
        }
    });
    panel.add(portableLanguages, new GridBagConstraints(0, 4, 1, 0, 0, 0, GridBagConstraints.SOUTHWEST,
            GridBagConstraints.NONE, new Insets(0, 8, 8, 0), 0, 0));

    portableInstallButton = new RoundedButton(resources.getString("launcher.installer.install"));
    portableInstallButton.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 18));
    portableInstallButton.setContentAreaFilled(false);
    portableInstallButton.setForeground(LauncherFrame.COLOR_GREY_TEXT);
    portableInstallButton.setHoverForeground(LauncherFrame.COLOR_BLUE);
    portableInstallButton.setBorder(BorderFactory.createEmptyBorder(8, 56, 8, 56));
    portableInstallButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            portableInstall();
        }
    });
    portableInstallButton.setEnabled(false);

    if (!installDir.equals("")) {
        portableInstallButton.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
        portableInstallButton.setEnabled(true);
    }

    panel.add(portableInstallButton, new GridBagConstraints(1, 4, 2, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 8, 8), 0, 0));
}

From source file:org.apache.jmeter.gui.MainFrame.java

/**
 * Show a dialog indicating that JMeter threads are stopping on a particular
 * host.//  w w  w . j  av  a2s. c  o  m
 *
 * @param host
 *            the host where JMeter threads are stopping
 */
public void showStoppingMessage(String host) {
    if (stoppingMessage != null) {
        stoppingMessage.dispose();
    }
    stoppingMessage = new EscapeDialog(this, JMeterUtils.getResString("stopping_test_title"), true); //$NON-NLS-1$
    String label = JMeterUtils.getResString("stopping_test"); //$NON-NLS-1
    if (!StringUtils.isEmpty(host)) {
        label = label + JMeterUtils.getResString("stopping_test_host") + ": " + host;
    }
    JLabel stopLabel = new JLabel(label); //$NON-NLS-1$$NON-NLS-2$
    stopLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    stoppingMessage.getContentPane().add(stopLabel);
    stoppingMessage.pack();
    ComponentUtil.centerComponentInComponent(this, stoppingMessage);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (stoppingMessage != null) { // TODO - how can this be null?
                stoppingMessage.setVisible(true);
            }
        }
    });
}

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java

private JTable createTable(final ViewState state) {
    JTable table;//from ww  w  .ja va 2  s.  co  m
    final ModelGraph selected = state.getSelected();
    if (selected != null) {
        final Vector<Vector<String>> rows = new Vector<Vector<String>>();
        ConcurrentHashMap<String, String> keyToGroupMap = new ConcurrentHashMap<String, String>();
        Metadata staticMet = selected.getModel().getStaticMetadata();
        Metadata inheritedMet = selected.getInheritedStaticMetadata(state);
        Metadata completeMet = new Metadata();
        if (staticMet != null) {
            completeMet.replaceMetadata(staticMet.getSubMetadata(state.getCurrentMetGroup()));
        }
        if (selected.getModel().getExtendsConfig() != null) {
            for (String configGroup : selected.getModel().getExtendsConfig()) {
                Metadata extendsMetadata = state.getGlobalConfigGroups().get(configGroup).getMetadata()
                        .getSubMetadata(state.getCurrentMetGroup());
                for (String key : extendsMetadata.getAllKeys()) {
                    if (!completeMet.containsKey(key)) {
                        keyToGroupMap.put(key, configGroup);
                        completeMet.replaceMetadata(key, extendsMetadata.getAllMetadata(key));
                    }
                }
            }
        }
        if (inheritedMet != null) {
            Metadata inheritedMetadata = inheritedMet.getSubMetadata(state.getCurrentMetGroup());
            for (String key : inheritedMetadata.getAllKeys()) {
                if (!completeMet.containsKey(key)) {
                    keyToGroupMap.put(key, "__inherited__");
                    completeMet.replaceMetadata(key, inheritedMetadata.getAllMetadata(key));
                }
            }
        }
        List<String> keys = completeMet.getAllKeys();
        Collections.sort(keys);
        for (String key : keys) {
            if (key.endsWith("/envReplace")) {
                continue;
            }
            String values = StringUtils.join(completeMet.getAllMetadata(key), ",");
            Vector<String> row = new Vector<String>();
            row.add(keyToGroupMap.get(key));
            row.add(key);
            row.add(values);
            row.add(Boolean.toString(Boolean.parseBoolean(completeMet.getMetadata(key + "/envReplace"))));
            rows.add(row);
        }
        table = new JTable();// rows, new Vector<String>(Arrays.asList(new
                             // String[] { "key", "values", "envReplace" })));
        table.setModel(new AbstractTableModel() {
            public String getColumnName(int col) {
                switch (col) {
                case 0:
                    return "group";
                case 1:
                    return "key";
                case 2:
                    return "values";
                case 3:
                    return "envReplace";
                default:
                    return null;
                }
            }

            public int getRowCount() {
                return rows.size() + 1;
            }

            public int getColumnCount() {
                return 4;
            }

            public Object getValueAt(int row, int col) {
                if (row >= rows.size()) {
                    return null;
                }
                String value = rows.get(row).get(col);
                if (value == null && col == 3) {
                    return "false";
                }
                if (value == null && col == 0) {
                    return "__local__";
                }
                return value;
            }

            public boolean isCellEditable(int row, int col) {
                if (row >= rows.size()) {
                    return selected.getModel().getStaticMetadata().containsGroup(state.getCurrentMetGroup());
                }
                if (col == 0) {
                    return false;
                }
                String key = rows.get(row).get(1);
                return key == null || (selected.getModel().getStaticMetadata() != null
                        && selected.getModel().getStaticMetadata().containsKey(getKey(key, state)));
            }

            public void setValueAt(Object value, int row, int col) {
                if (row >= rows.size()) {
                    Vector<String> newRow = new Vector<String>(
                            Arrays.asList(new String[] { null, null, null, null }));
                    newRow.add(col, (String) value);
                    rows.add(newRow);
                } else {
                    Vector<String> rowValues = rows.get(row);
                    rowValues.add(col, (String) value);
                    rowValues.remove(col + 1);
                }
                this.fireTableCellUpdated(row, col);
            }

        });
        MyTableListener tableListener = new MyTableListener(state);
        table.getModel().addTableModelListener(tableListener);
        table.getSelectionModel().addListSelectionListener(tableListener);
    } else {
        table = new JTable(new Vector<Vector<String>>(),
                new Vector<String>(Arrays.asList(new String[] { "key", "values", "envReplace" })));
    }

    // table.setFillsViewportHeight(true);
    table.setSelectionBackground(Color.cyan);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    TableCellRenderer cellRenderer = new TableCellRenderer() {

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            JLabel field = new JLabel((String) value);
            if (column == 0) {
                field.setForeground(Color.gray);
            } else {
                if (isSelected) {
                    field.setBorder(new EtchedBorder(1));
                }
                if (table.isCellEditable(row, 1)) {
                    field.setForeground(Color.black);
                } else {
                    field.setForeground(Color.gray);
                }
            }
            return field;
        }

    };
    TableColumn groupCol = table.getColumnModel().getColumn(0);
    groupCol.setPreferredWidth(75);
    groupCol.setCellRenderer(cellRenderer);
    TableColumn keyCol = table.getColumnModel().getColumn(1);
    keyCol.setPreferredWidth(200);
    keyCol.setCellRenderer(cellRenderer);
    TableColumn valuesCol = table.getColumnModel().getColumn(2);
    valuesCol.setPreferredWidth(300);
    valuesCol.setCellRenderer(cellRenderer);
    TableColumn envReplaceCol = table.getColumnModel().getColumn(3);
    envReplaceCol.setPreferredWidth(75);
    envReplaceCol.setCellRenderer(cellRenderer);

    table.addMouseListener(new MouseListener() {
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3 && DefaultPropView.this.table.getSelectedRow() != -1) {
                int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition());
                String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state);
                Metadata staticMet = state.getSelected().getModel().getStaticMetadata();
                override.setVisible(staticMet == null || !staticMet.containsKey(key));
                delete.setVisible(staticMet != null && staticMet.containsKey(key));
                tableMenu.show(DefaultPropView.this.table, e.getX(), e.getY());
            }
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
        }

        public void mouseReleased(MouseEvent e) {
        }
    });

    return table;
}

From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.GlobalConfigView.java

@Override
public void refreshView(ViewState state) {

    Rectangle visibleRect = null;
    if (this.tree != null) {
        visibleRect = this.tree.getVisibleRect();
    }//ww  w . j  a v a2s  .  c o m

    DefaultMutableTreeNode root = new DefaultMutableTreeNode("GlobalConfig");

    if (state != null && state.getGlobalConfigGroups() != null) {
        if (globalConfig != null && globalConfig.keySet().equals(state.getGlobalConfigGroups().keySet())
                && globalConfig.values().equals(state.getGlobalConfigGroups().values())) {
            return;
        }

        this.removeAll();

        for (ConfigGroup group : (globalConfig = state.getGlobalConfigGroups()).values()) {
            HashSet<String> keys = new HashSet<String>();
            DefaultMutableTreeNode groupNode = new DefaultMutableTreeNode(new Group(group.getName()));
            root.add(groupNode);
            for (String key : group.getMetadata().getAllKeys()) {
                keys.add(key);
                DefaultMutableTreeNode keyNode = new DefaultMutableTreeNode(new Key(key));
                groupNode.add(keyNode);
                DefaultMutableTreeNode valueNode = new DefaultMutableTreeNode(
                        new Value(StringUtils.join(group.getMetadata().getAllMetadata(key), ",")));
                keyNode.add(valueNode);
            }
            if (group.getExtends() != null) {
                List<String> extendsGroups = new Vector<String>(group.getExtends());
                Collections.reverse(extendsGroups);
                for (String extendsGroup : extendsGroups) {
                    List<String> groupKeys = state.getGlobalConfigGroups().get(extendsGroup).getMetadata()
                            .getAllKeys();
                    groupKeys.removeAll(keys);
                    if (groupKeys.size() > 0) {
                        for (String key : groupKeys) {
                            if (!keys.contains(key)) {
                                keys.add(key);
                                DefaultMutableTreeNode keyNode = new DefaultMutableTreeNode(
                                        new ExtendsKey(extendsGroup, key));
                                groupNode.add(keyNode);
                                DefaultMutableTreeNode valueNode = new DefaultMutableTreeNode(
                                        new ExtendsValue(StringUtils.join(state.getGlobalConfigGroups()
                                                .get(extendsGroup).getMetadata().getAllMetadata(key), ",")));
                                keyNode.add(valueNode);
                            }
                        }
                    }
                }
            }
        }

        tree = new JTree(root);
        tree.setShowsRootHandles(true);
        tree.setRootVisible(false);

        tree.setCellRenderer(new TreeCellRenderer() {

            public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                    boolean expanded, boolean leaf, int row, boolean hasFocus) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
                if (node.getUserObject() instanceof Key) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    JLabel label = new JLabel(node.getUserObject().toString());
                    label.setForeground(Color.darkGray);
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else if (node.getUserObject() instanceof ExtendsKey) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    ExtendsKey key = (ExtendsKey) node.getUserObject();
                    JLabel groupLabel = new JLabel("(" + key.getGroup() + ") ");
                    groupLabel.setForeground(Color.black);
                    JLabel keyLabel = new JLabel(key.getValue());
                    keyLabel.setForeground(Color.gray);
                    panel.add(groupLabel, BorderLayout.WEST);
                    panel.add(keyLabel, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else if (node.getUserObject() instanceof Group) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    JLabel label = new JLabel(node.getUserObject().toString());
                    label.setForeground(Color.black);
                    label.setBackground(Color.white);
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else if (node.getUserObject() instanceof Value) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    panel.setBorder(new EtchedBorder(1));
                    JLabel label = new JLabel(node.getUserObject().toString());
                    label.setForeground(Color.black);
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else if (node.getUserObject() instanceof ExtendsValue) {
                    JPanel panel = new JPanel();
                    panel.setLayout(new BorderLayout());
                    panel.setBorder(new EtchedBorder(1));
                    JLabel label = new JLabel(node.getUserObject().toString());
                    label.setForeground(Color.gray);
                    panel.add(label, BorderLayout.CENTER);
                    panel.setBackground(selected ? Color.lightGray : Color.white);
                    return panel;
                } else {
                    return new JLabel();
                }
            }

        });
    }

    this.setBorder(new EtchedBorder());
    JLabel panelName = new JLabel("Global-Config Groups");
    panelName.setBorder(new EtchedBorder());
    this.add(panelName, BorderLayout.NORTH);
    JScrollPane scrollPane = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Tree", scrollPane);
    tabbedPane.addTab("Table", new JPanel());

    this.add(tabbedPane, BorderLayout.CENTER);

    if (visibleRect != null) {
        this.tree.scrollRectToVisible(visibleRect);
    }

    this.revalidate();
}

From source file:org.colombbus.tangara.update.SoftwareUpdateDialog.java

private void addIntroductionPane() {
    String introFormat = bundle.getString("SoftwareUpdateDialog.introduction"); //$NON-NLS-1$
    String introduction = MessageFormat.format(introFormat, info.getVersion());

    String labelText = String.format("<html><b>%s</b></html>", introduction); //$NON-NLS-1$
    JLabel introLabel = new JLabel(labelText);
    introLabel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    introLabel.setFont(font);//from  w  w  w  .  j av a 2 s. c  o m
    add(introLabel, BorderLayout.NORTH);
}