Example usage for javax.swing JList getForeground

List of usage examples for javax.swing JList getForeground

Introduction

In this page you can find the example usage for javax.swing JList getForeground.

Prototype

@Transient
public Color getForeground() 

Source Link

Document

Gets the foreground color of this component.

Usage

From source file:userinterface.graph.GraphOptionsPanel.java

/** Creates new form GraphOptionsPanel */
public GraphOptionsPanel(GUIPlugin plugin, JFrame parent, JPanel theModel) {
    this.plugin = plugin;
    this.parent = parent;
    this.theModel = theModel;

    /* TODO: Use generic container. */
    ArrayList own = new ArrayList();
    own.add(theModel);/* w ww. ja  va  2s . com*/

    graphPropertiesTable = new SettingTable(parent);
    graphPropertiesTable.setOwners(own);

    if (theModel instanceof Graph) {

        ((Graph) theModel).setDisplay(graphPropertiesTable);
        xAxisSettings = ((Graph) theModel).getXAxisSettings();
        yAxisSettings = ((Graph) theModel).getYAxisSettings();
        zAxisSettings = null;
        displaySettings = ((Graph) theModel).getDisplaySettings();

    } else if (theModel instanceof Histogram) {

        ((Histogram) theModel).setDisplay(graphPropertiesTable);
        xAxisSettings = ((Histogram) theModel).getXAxisSettings();
        yAxisSettings = ((Histogram) theModel).getYAxisSettings();
        zAxisSettings = null;
        displaySettings = ((Histogram) theModel).getDisplaySettings();
    } else if (theModel instanceof Graph3D) {

        ((Graph3D) theModel).setDisplay(graphPropertiesTable);
        xAxisSettings = ((Graph3D) theModel).getxAxisSetting();
        yAxisSettings = ((Graph3D) theModel).getyAxisSetting();
        zAxisSettings = null;
        //zAxisSettings = ((Graph3D)theModel).getzAxisSetting();
        displaySettings = ((Graph3D) theModel).getDisplaySettings();
    }

    String[] axes = { "x-Axis", "y-Axis" };
    axesList = new JList(axes);
    axesList.setSelectedIndex(0);

    axesList.addListSelectionListener(this);

    own = new ArrayList();
    own.add(xAxisSettings);
    axisPropertiesTable = new SettingTable(parent);
    axisPropertiesTable.setOwners(own);

    if (theModel instanceof Graph) {

        ((AxisSettings) xAxisSettings).setDisplay(axisPropertiesTable);
        ((AxisSettings) yAxisSettings).setDisplay(axisPropertiesTable);

    } else if (theModel instanceof Histogram) {

        ((AxisSettingsHistogram) xAxisSettings).setDisplay(axisPropertiesTable);
        ((AxisSettingsHistogram) yAxisSettings).setDisplay(axisPropertiesTable);
    } else {

        ((AxisSettings3D) xAxisSettings).setDisplay(axisPropertiesTable);
        ((AxisSettings3D) yAxisSettings).setDisplay(axisPropertiesTable);
    }

    own = new ArrayList();
    own.add(displaySettings);
    displayPropertiesTable = new SettingTable(parent);
    displayPropertiesTable.setOwners(own);

    if (theModel instanceof ChartPanel)
        ((DisplaySettings) displaySettings).setDisplay(displayPropertiesTable);
    else if (theModel instanceof Graph3D)
        ((DisplaySettings3D) displaySettings).setDisplay(displayPropertiesTable);

    if (theModel instanceof Graph) {
        seriesList = new JList(((Graph) theModel).getGraphSeriesList());
    } else if (theModel instanceof Histogram) {

        seriesList = new JList(((Histogram) theModel).getGraphSeriesList());
    } else if (theModel instanceof Graph3D) {

        seriesList = new JList(((Graph3D) theModel).getGraphSeriesList());
    }

    seriesList.addListSelectionListener(this);

    seriesList.setCellRenderer(new ListCellRenderer() {

        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            JLabel label = new JLabel((value == null) ? "undefined" : value.toString());
            JPanel panel = new JPanel();

            panel.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));

            if (isSelected) {
                panel.setBackground(list.getSelectionBackground());
                panel.setForeground(list.getSelectionForeground());
            } else {
                panel.setBackground(list.getBackground());
                panel.setForeground(list.getForeground());
            }

            if (value instanceof SeriesSettings) {
                SeriesSettings graphSeries = (SeriesSettings) value;
                panel.add(graphSeries.getIcon());
            }

            panel.add(label);

            return panel;
        }
    });

    seriesPropertiesTable = new SettingTable(parent);

    /*seriesList = theModel.getSeriesList();
    seriesList.addListSelectionListener(this);
    //seriesModel = new PropertyTableModel();
    ArrayList ss = seriesList.getSelectedSeries();
    //seriesModel.setOwners(ss);
            
    seriesProperties = new SettingTable(parent);
    seriesProperties.setOwners(ss);*/
    initComponents();
    //addSeries.setEnabled(ss.size() > 0);
    /*removeSeries.setEnabled(ss.size() > 0);
    moveUp.setEnabled(ss.size() > 0);
    moveDown.setEnabled(ss.size() > 0);
    viewData.setEnabled(ss.size() > 0);*/

}

From source file:com.rapidminer.gui.properties.RegexpPropertyDialog.java

public RegexpPropertyDialog(final Collection<String> items, String predefinedRegexp, String description) {
    super(ApplicationFrame.getApplicationFrame(), "parameter.regexp", ModalityType.APPLICATION_MODAL,
            new Object[] {});
    this.items = items;
    this.supportsItems = items != null;
    this.infoText = "<html>" + I18N.getMessage(I18N.getGUIBundle(), getKey() + ".title") + ": <br/>"
            + description + "</html>";
    Dimension size = new Dimension(420, 500);
    this.setMinimumSize(size);
    this.setPreferredSize(size);

    JPanel panel = new JPanel(createGridLayout(1, supportsItems ? 2 : 1));

    // create regexp text field
    regexpTextField = new JTextField(predefinedRegexp);
    regexpTextField.setToolTipText(//from w w  w .ja va 2  s  . c om
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.tip"));
    regexpTextField.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            fireRegularExpressionUpdated();
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

    });
    regexpTextField.requestFocus();

    // create replacement text field
    replacementTextField = new JTextField();
    replacementTextField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.tip"));
    replacementTextField.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            fireRegularExpressionUpdated();
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

    });

    // create inline search documents
    inlineSearchDocument = new RegexpSearchStyledDocument();
    inlineReplaceDocument = new RegexpReplaceStyledDocument();

    // create search results list
    DefaultListCellRenderer resultCellRenderer = new DefaultListCellRenderer() {

        private static final long serialVersionUID = 1L;

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            setBackground(list.getBackground());
            setForeground(list.getForeground());
            setBorder(getNoFocusBorder());
            return this;
        }

        private Border getNoFocusBorder() {
            Border border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray);
            return border;
        }
    };

    JList<RegExpResult> regexpFindingsList = new JList<RegExpResult>(resultsListModel);
    regexpFindingsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    regexpFindingsList.setLayoutOrientation(JList.VERTICAL);
    regexpFindingsList.setCellRenderer(resultCellRenderer);

    // regexp panel on left side of dialog
    JPanel regexpPanel = new JPanel(new GridBagLayout());
    regexpPanel.setBorder(createTitledBorder(
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.border")));
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(4, 4, 4, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    regexpPanel.add(regexpTextField, c);

    // make shortcut button
    final Action nullAction = new DefaultAction();
    PlainArrowDropDownButton autoWireDropDownButton = PlainArrowDropDownButton.makeDropDownButton(nullAction);

    for (String[] popupItem : (String[][]) ArrayUtils.addAll(regexpConstructs, regexpShortcuts)) {
        String shortcut = popupItem[0].length() > 14 ? popupItem[0].substring(0, 14) + "..." : popupItem[0];
        autoWireDropDownButton
                .add(new InsertionAction("<html><table border=0 cellpadding=0 cellspacing=0><tr><td width=100>"
                        + shortcut + "</td><td>" + popupItem[1] + "</td></tr></table></html>", popupItem[0]));
    }
    c.insets = new Insets(4, 0, 4, 0);
    c.gridx = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    regexpPanel.add(autoWireDropDownButton.getDropDownArrowButton(), c);

    // make delete button
    c.insets = new Insets(4, 0, 4, 4);
    c.gridx = 2;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    JButton clearRegexpTextFieldButton = new JButton(SwingTools.createIcon("16/delete2.png"));
    clearRegexpTextFieldButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            regexpTextField.setText("");
            fireRegularExpressionUpdated();
            regexpTextField.requestFocusInWindow();
        }
    });

    regexpPanel.add(clearRegexpTextFieldButton, c);

    errorMessage = new JLabel(NO_ERROR_MESSAGE, NO_ERROR_ICON, SwingConstants.LEFT);
    errorMessage.setFocusable(false);
    c.insets = new Insets(4, 8, 4, 4);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    regexpPanel.add(errorMessage, c);

    // create replacement panel
    JPanel replacementPanel = new JPanel(new GridBagLayout());
    replacementPanel.setBorder(createTitledBorder(
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.border")));

    JPanel testerPanel = new JPanel(new GridBagLayout());

    c.insets = new Insets(4, 4, 4, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    replacementPanel.add(replacementTextField, c);

    // create inline search panel
    JPanel inlineSearchPanel = new JPanel(new GridBagLayout());

    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    inlineSearchPanel.add(
            new JLabel(
                    I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.search")),
            c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    inlineSearchPanel.add(new JScrollPane(new JTextPane(inlineSearchDocument)), c);

    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    inlineSearchPanel.add(
            new JLabel(
                    I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.replaced")),
            c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    JTextPane replaceTextPane = new JTextPane(inlineReplaceDocument);
    replaceTextPane.setEditable(false);
    inlineSearchPanel.add(new JScrollPane(replaceTextPane), c);

    // create regexp options panel
    ItemListener defaultOptionListener = new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            fireRegexpOptionsChanged();
        }
    };

    cbCaseInsensitive = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive"));
    cbCaseInsensitive.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive.tip"));
    cbCaseInsensitive.addItemListener(defaultOptionListener);

    cbMultiline = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode"));
    cbMultiline.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode.tip"));
    cbMultiline.addItemListener(defaultOptionListener);

    cbDotall = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode"));
    cbDotall.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode.tip"));
    cbDotall.addItemListener(defaultOptionListener);

    cbUnicodeCase = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case"));
    cbUnicodeCase.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case.tip"));
    cbUnicodeCase.addItemListener(defaultOptionListener);

    JPanel regexpOptionsPanelWrapper = new JPanel(new BorderLayout());
    JPanel regexpOptionsPanel = new JPanel(new GridBagLayout());
    regexpOptionsPanelWrapper.add(regexpOptionsPanel, BorderLayout.NORTH);

    c.insets = new Insets(12, 4, 0, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    regexpOptionsPanel.add(cbMultiline, c);
    c.insets = new Insets(8, 4, 0, 4);
    c.gridy = 1;
    regexpOptionsPanel.add(cbCaseInsensitive, c);
    c.gridy = 2;
    regexpOptionsPanel.add(cbUnicodeCase, c);
    c.gridy = 3;
    regexpOptionsPanel.add(cbDotall, c);

    // create tabbed panel
    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    testExp = new JTabbedPane();
    testExp.add(
            I18N.getMessage(I18N.getGUIBundle(),
                    "gui.dialog.parameter.regexp.regular_expression.inline_search.title"),
            new JScrollPane(inlineSearchPanel));
    testExp.add(
            I18N.getMessage(I18N.getGUIBundle(),
                    "gui.dialog.parameter.regexp.regular_expression.result_list.title"),
            new JScrollPane(regexpFindingsList));
    testExp.add(
            I18N.getMessage(I18N.getGUIBundle(),
                    "gui.dialog.parameter.regexp.regular_expression.regexp_options.title"),
            regexpOptionsPanelWrapper);
    testerPanel.add(testExp, c);

    JPanel groupPanel = new JPanel(new GridBagLayout());
    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    groupPanel.add(regexpPanel, c);

    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    groupPanel.add(replacementPanel, c);

    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    groupPanel.add(testerPanel, c);

    panel.add(groupPanel, 1, 0);

    if (supportsItems) {
        // item shortcuts list
        itemShortcutsList = new JList<String>(items.toArray(new String[items.size()]));
        itemShortcutsList.setToolTipText(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.tip"));
        itemShortcutsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        itemShortcutsList.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    String text = regexpTextField.getText();
                    int cursorPosition = regexpTextField.getCaretPosition();
                    int index = itemShortcutsList.getSelectedIndex();
                    if (index > -1 && index < itemShortcutsList.getModel().getSize()) {
                        String insertionString = itemShortcutsList.getModel().getElementAt(index).toString();
                        String newText = text.substring(0, cursorPosition) + insertionString
                                + (cursorPosition < text.length() ? text.substring(cursorPosition) : "");
                        regexpTextField.setText(newText);
                        regexpTextField.setCaretPosition(cursorPosition + insertionString.length());
                        regexpTextField.requestFocus();
                        fireRegularExpressionUpdated();
                    }
                }
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }
        });
        JScrollPane itemShortcutsPane = new JScrollPane(itemShortcutsList);
        itemShortcutsPane.setBorder(createTitledBorder(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.border")));

        // matched items list
        matchedItemsListModel = new DefaultListModel<String>();
        JList<String> matchedItemsList = new JList<String>(matchedItemsListModel);
        matchedItemsList.setToolTipText(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.tip"));
        // add custom cell renderer to disallow selections
        matchedItemsList.setCellRenderer(new DefaultListCellRenderer() {

            private static final long serialVersionUID = -5795848004756768378L;

            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index,
                    boolean isSelected, boolean cellHasFocus) {
                return super.getListCellRendererComponent(list, value, index, false, false);
            }
        });
        JScrollPane matchedItemsPanel = new JScrollPane(matchedItemsList);
        matchedItemsPanel.setBorder(createTitledBorder(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.border")));

        // item panel on right side of dialog
        JPanel itemPanel = new JPanel(createGridLayout(1, 2));
        itemPanel.add(itemShortcutsPane, 0, 0);
        itemPanel.add(matchedItemsPanel, 0, 1);

        panel.add(itemPanel, 0, 1);
    }

    okButton = makeOkButton("regexp_property_dialog_apply");
    fireRegularExpressionUpdated();

    layoutDefault(panel, supportsItems ? NORMAL : NARROW, okButton, makeCancelButton());
}

From source file:filterviewplugin.FilterViewSettingsTab.java

public JPanel createSettingsPanel() {
    final EnhancedPanelBuilder panelBuilder = new EnhancedPanelBuilder(FormFactory.RELATED_GAP_COLSPEC.encode()
            + ',' + FormFactory.PREF_COLSPEC.encode() + ',' + FormFactory.RELATED_GAP_COLSPEC.encode() + ','
            + FormFactory.PREF_COLSPEC.encode() + ", fill:default:grow");
    final CellConstraints cc = new CellConstraints();

    final JLabel label = new JLabel(mLocalizer.msg("daysToShow", "Days to show"));

    panelBuilder.addRow();/* w  w w .  ja  v  a2 s  .c om*/
    panelBuilder.add(label, cc.xy(2, panelBuilder.getRow()));

    final SpinnerNumberModel model = new SpinnerNumberModel(3, 1, 7, 1);
    mSpinner = new JSpinner(model);
    mSpinner.setValue(mSettings.getDays());
    panelBuilder.add(mSpinner, cc.xy(4, panelBuilder.getRow()));

    panelBuilder.addParagraph(mLocalizer.msg("filters", "Filters to show"));

    mFilterList = new SelectableItemList(mSettings.getActiveFilterNames(),
            FilterViewSettings.getAvailableFilterNames());
    mIcons.clear();
    for (String filterName : FilterViewSettings.getAvailableFilterNames()) {
        mIcons.put(filterName, mSettings.getFilterIconName(mSettings.getFilter(filterName)));
    }
    mFilterList.addCenterRendererComponent(String.class, new SelectableItemRendererCenterComponentIf() {
        private DefaultListCellRenderer mRenderer = new DefaultListCellRenderer();

        public void calculateSize(JList list, int index, JPanel contentPane) {
        }

        public JPanel createCenterPanel(JList list, Object value, int index, boolean isSelected,
                boolean isEnabled, JScrollPane parentScrollPane, int leftColumnWidth) {
            DefaultListCellRenderer label = (DefaultListCellRenderer) mRenderer
                    .getListCellRendererComponent(list, value, index, isSelected, false);
            String filterName = value.toString();
            String iconFileName = mIcons.get(filterName);
            Icon icon = null;
            if (!StringUtils.isEmpty(iconFileName)) {
                try {
                    icon = FilterViewPlugin.getInstance().getIcon(
                            FilterViewSettings.getIconDirectoryName() + File.separatorChar + iconFileName);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                label.setIcon(icon);
            }
            String text = filterName;
            if (icon == null) {
                text += " (" + mLocalizer.msg("noIcon", "no icon") + ')';
            }
            label.setText(text);
            label.setHorizontalAlignment(SwingConstants.LEADING);
            label.setVerticalAlignment(SwingConstants.CENTER);
            label.setOpaque(false);

            JPanel panel = new JPanel(new BorderLayout());
            if (isSelected && isEnabled) {
                panel.setOpaque(true);
                panel.setForeground(list.getSelectionForeground());
                panel.setBackground(list.getSelectionBackground());
            } else {
                panel.setOpaque(false);
                panel.setForeground(list.getForeground());
                panel.setBackground(list.getBackground());
            }
            panel.add(label, BorderLayout.WEST);
            return panel;
        }
    });

    panelBuilder.addGrowingRow();
    panelBuilder.add(mFilterList, cc.xyw(2, panelBuilder.getRow(), panelBuilder.getColumnCount() - 1));

    panelBuilder.addRow();
    mFilterButton = new JButton(mLocalizer.msg("changeIcon", "Change icon"));
    mFilterButton.setEnabled(false);
    panelBuilder.add(mFilterButton, cc.xyw(2, panelBuilder.getRow(), 1));

    mRemoveButton = new JButton(mLocalizer.msg("deleteIcon", "Remove icon"));
    mRemoveButton.setEnabled(false);
    panelBuilder.add(mRemoveButton, cc.xyw(4, panelBuilder.getRow(), 1));

    mFilterButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SelectableItem item = (SelectableItem) mFilterList.getSelectedValue();
            String filterName = (String) item.getItem();
            chooseIcon(filterName);
        }
    });

    mFilterList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            mFilterButton.setEnabled(mFilterList.getSelectedValue() != null);
            mRemoveButton.setEnabled(mFilterButton.isEnabled());
        }
    });

    mRemoveButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SelectableItem item = (SelectableItem) mFilterList.getSelectedValue();
            String filterName = (String) item.getItem();
            mIcons.put(filterName, "");
            mFilterList.updateUI();
        }
    });

    return panelBuilder.getPanel();
}

From source file:org.domainmath.gui.MainFrame.java

public CompletionProvider createCompletionProvider() {

    DefaultCompletionProvider provider = new DefaultCompletionProvider();

    JList l = new JList();

    AutoCompleteListCellRenderer cellRender = new AutoCompleteListCellRenderer(l.getFont(), l.getBackground(),
            l.getForeground(), l.getSelectionBackground(), l.getSelectionForeground());
    provider.setListCellRenderer(cellRender);

    OctaveM _m = new OctaveM();
    List a = _m.getKey("DomainMath_OctaveAutoComplete.ini");

    for (int i = 0; i < a.size(); i++) {
        provider.addCompletion(new BasicCompletion(provider, a.get(i).toString()));
    }//from ww  w.  java  2 s . c  o m

    return provider;

}

From source file:org.mbari.aved.ui.classifier.ClassModelListRenderer.java

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    if (isSelected) {
        setBackground(list.getSelectionBackground());
        setForeground(list.getSelectionForeground());
    } else {/*w  ww.j  ava2  s  . c  o  m*/
        setBackground(list.getBackground());
        setForeground(list.getForeground());
    }

    // Set the icon and text.  If icon was null, say so.
    if ((value != null) && value.getClass().equals(ClassModel.class)) {
        ClassModel model = (ClassModel) value;
        URL imageUrl = null;

        if (model != null) {
            ArrayList<String> listing = model.getRawImageFileListing();

            if (listing.size() > 0) {
                try {
                    imageUrl = new URL(
                            "file://" + model.getRawImageDirectory().toString() + "/" + listing.get(0));
                    icon = createImageIcon(imageUrl);
                } catch (MalformedURLException ex) {
                    Logger.getLogger(ClassModelListRenderer.class.getName()).log(Level.SEVERE,
                            "Error creating image icon for " + imageUrl.getFile(), ex);
                }

            } else {

                // Insert a default icon here
                URL url = Application.class.getResource("/org/mbari/aved/ui/images/missingframeexception.jpg");

                icon = new ImageIcon(url);
            }

            // scale icons to a normalized size here
            if (icon != null) {
                Image image = icon.getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH);

                icon = convertImageIcon(image, model.getColorSpace());
            }

            String name = model.getName();

            setIcon(icon);

            if (icon != null) {
                setText(name);
                setFont(list.getFont());
            } else {
                setDefaultText(name + " (no image available)", list.getFont());
            }
        }
    }

    return this;
}

From source file:org.netbeans.jcode.mvc.controller.MVCPanel.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from  ww w  .j  a  va  2  s.  c o  m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    packagePanel = new javax.swing.JPanel();
    packageLabel = new javax.swing.JLabel();
    packageCombo = new javax.swing.JComboBox();
    warningPanel = new javax.swing.JPanel();
    warningLabel = new javax.swing.JLabel();
    suffixPanel = new javax.swing.JPanel();
    namePane = new javax.swing.JLayeredPane();
    prefixField = new javax.swing.JTextField();
    entityLabel = new javax.swing.JLabel();
    suffixField = new javax.swing.JTextField();
    nameLabel = new javax.swing.JLabel();
    viewPanel = new javax.swing.JPanel();
    viewLabel = new javax.swing.JLabel();
    viewCombo = new javax.swing.JComboBox();
    eventObserversPanel = new javax.swing.JPanel();
    jCheckBox4 = new javax.swing.JCheckBox();
    jCheckBox1 = new javax.swing.JCheckBox();
    securityPanel = new javax.swing.JPanel();
    securityLabel = new javax.swing.JLabel();
    securityCompPanel = new javax.swing.JLayeredPane();
    authenticationCheckbox = new javax.swing.JCheckBox();
    csrfCheckbox = new javax.swing.JCheckBox();
    xssCheckbox = new javax.swing.JCheckBox();
    miscPanel = new javax.swing.JPanel();
    applicationConfigButton = new javax.swing.JButton();
    wrapper = new javax.swing.JLayeredPane();
    beanValidation = new javax.swing.JCheckBox();
    hybridClassCheckbox = new javax.swing.JCheckBox();

    packagePanel.setLayout(new java.awt.BorderLayout(10, 0));

    packageLabel.setLabelFor(packageCombo);
    org.openide.awt.Mnemonics.setLocalizedText(packageLabel,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.packageLabel.text")); // NOI18N
    packageLabel.setPreferredSize(new java.awt.Dimension(100, 17));
    packagePanel.add(packageLabel, java.awt.BorderLayout.LINE_START);

    packageCombo.setEditable(true);
    packageCombo.setEditable(true);
    packageCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { " " }));
    packageCombo.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            packageComboPropertyChange(evt);
        }
    });
    packagePanel.add(packageCombo, java.awt.BorderLayout.CENTER);

    warningPanel.setLayout(new java.awt.BorderLayout(10, 0));

    warningLabel.setForeground(new java.awt.Color(200, 0, 0));
    warningLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    org.openide.awt.Mnemonics.setLocalizedText(warningLabel,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.warningLabel.text")); // NOI18N
    warningPanel.add(warningLabel, java.awt.BorderLayout.CENTER);

    suffixPanel.setLayout(new java.awt.BorderLayout(10, 0));

    namePane.setLayout(new javax.swing.BoxLayout(namePane, javax.swing.BoxLayout.LINE_AXIS));

    prefixField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    prefixField.setText(org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.prefixField.text")); // NOI18N
    prefixField.setToolTipText(
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.prefixField.toolTipText")); // NOI18N
    prefixField.setPreferredSize(new java.awt.Dimension(100, 27));
    prefixField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            prefixFieldPropertyChange(evt);
        }
    });
    namePane.add(prefixField);

    entityLabel.setForeground(javax.swing.UIManager.getDefaults().getColor("Button.shadow"));
    entityLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    org.openide.awt.Mnemonics.setLocalizedText(entityLabel,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.entityLabel.text")); // NOI18N
    entityLabel.setPreferredSize(new java.awt.Dimension(58, 27));
    entityLabel.setRequestFocusEnabled(false);
    namePane.add(entityLabel);

    suffixField.setText(org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.suffixField.text")); // NOI18N
    suffixField.setPreferredSize(new java.awt.Dimension(100, 27));
    suffixField.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            suffixFieldPropertyChange(evt);
        }
    });
    namePane.add(suffixField);

    suffixPanel.add(namePane, java.awt.BorderLayout.CENTER);

    org.openide.awt.Mnemonics.setLocalizedText(nameLabel,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.nameLabel.text")); // NOI18N
    nameLabel.setPreferredSize(new java.awt.Dimension(100, 17));
    suffixPanel.add(nameLabel, java.awt.BorderLayout.WEST);

    viewPanel.setLayout(new java.awt.BorderLayout(10, 0));

    viewLabel.setLabelFor(viewCombo);
    org.openide.awt.Mnemonics.setLocalizedText(viewLabel,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.viewLabel.text")); // NOI18N
    viewLabel.setPreferredSize(new java.awt.Dimension(100, 17));
    viewPanel.add(viewLabel, java.awt.BorderLayout.LINE_START);

    viewCombo.setModel(new DefaultComboBoxModel(ControllerReturnType.values()));
    viewCombo.setRenderer(new BasicComboBoxRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            if (isSelected) {
                setBackground(list.getSelectionBackground());
                setForeground(list.getSelectionForeground());
                if (index > -1) {
                    ControllerReturnType returnType = (ControllerReturnType) value;
                    list.setToolTipText(returnType.getDescription());
                }
            } else {
                setBackground(list.getBackground());
                setForeground(list.getForeground());
            }
            setFont(list.getFont());
            setText((value == null) ? "" : value.toString());

            return this;
        }
    });
    viewCombo.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            viewComboPropertyChange(evt);
        }
    });
    viewPanel.add(viewCombo, java.awt.BorderLayout.CENTER);

    eventObserversPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.eventObserversPanel.border.title"),
            javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
            javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11),
            new java.awt.Color(100, 100, 100))); // NOI18N
    eventObserversPanel.setLayout(new java.awt.GridLayout(2, 3));

    org.openide.awt.Mnemonics.setLocalizedText(jCheckBox4,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.jCheckBox4.text")); // NOI18N
    jCheckBox4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCheckBox4ActionPerformed(evt);
        }
    });
    eventObserversPanel.add(jCheckBox4);

    org.openide.awt.Mnemonics.setLocalizedText(jCheckBox1,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.jCheckBox1.text")); // NOI18N
    eventObserversPanel.add(jCheckBox1);

    securityPanel.setLayout(new java.awt.BorderLayout(10, 0));

    org.openide.awt.Mnemonics.setLocalizedText(securityLabel,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.securityLabel.text")); // NOI18N
    securityLabel.setPreferredSize(new java.awt.Dimension(100, 17));
    securityPanel.add(securityLabel, java.awt.BorderLayout.LINE_START);

    securityCompPanel.setLayout(new java.awt.GridLayout(1, 0));

    org.openide.awt.Mnemonics.setLocalizedText(authenticationCheckbox,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.authenticationCheckbox.text")); // NOI18N
    securityCompPanel.add(authenticationCheckbox);

    org.openide.awt.Mnemonics.setLocalizedText(csrfCheckbox,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.csrfCheckbox.text")); // NOI18N
    securityCompPanel.add(csrfCheckbox);

    org.openide.awt.Mnemonics.setLocalizedText(xssCheckbox,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.xssCheckbox.text")); // NOI18N
    securityCompPanel.add(xssCheckbox);

    securityPanel.add(securityCompPanel, java.awt.BorderLayout.CENTER);

    miscPanel.setLayout(new java.awt.BorderLayout());

    org.openide.awt.Mnemonics.setLocalizedText(applicationConfigButton,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.applicationConfigButton.text")); // NOI18N
    applicationConfigButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            applicationConfigButtonActionPerformed(evt);
        }
    });
    miscPanel.add(applicationConfigButton, java.awt.BorderLayout.EAST);

    beanValidation.setSelected(true);
    org.openide.awt.Mnemonics.setLocalizedText(beanValidation,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.beanValidation.text")); // NOI18N
    beanValidation.setToolTipText(
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.beanValidation.toolTipText")); // NOI18N

    hybridClassCheckbox.setSelected(true);
    org.openide.awt.Mnemonics.setLocalizedText(hybridClassCheckbox,
            org.openide.util.NbBundle.getMessage(MVCPanel.class, "MVCPanel.hybridClassCheckbox.text")); // NOI18N

    wrapper.setLayer(beanValidation, javax.swing.JLayeredPane.DEFAULT_LAYER);
    wrapper.setLayer(hybridClassCheckbox, javax.swing.JLayeredPane.DEFAULT_LAYER);

    javax.swing.GroupLayout wrapperLayout = new javax.swing.GroupLayout(wrapper);
    wrapper.setLayout(wrapperLayout);
    wrapperLayout
            .setHorizontalGroup(wrapperLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(wrapperLayout.createSequentialGroup().addGap(114, 114, 114)
                            .addComponent(hybridClassCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 172,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(beanValidation, javax.swing.GroupLayout.PREFERRED_SIZE, 151,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(151, Short.MAX_VALUE)));
    wrapperLayout.setVerticalGroup(wrapperLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                    wrapperLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addGroup(wrapperLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(beanValidation, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(hybridClassCheckbox, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
                                    Short.MAX_VALUE))
                            .addGap(10, 10, 10)));

    miscPanel.add(wrapper, java.awt.BorderLayout.CENTER);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(eventObserversPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(packagePanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(suffixPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(viewPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(securityPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(miscPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
                                    Short.MAX_VALUE))
                    .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            layout.createSequentialGroup().addContainerGap().addComponent(warningPanel,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, 707, Short.MAX_VALUE)
                                    .addContainerGap())));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addGap(9, 9, 9)
                    .addComponent(suffixPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(15, 15, 15)
                    .addComponent(packagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(15, 15, 15)
                    .addComponent(miscPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(15, 15, 15)
                    .addComponent(viewPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(15, 15, 15)
                    .addComponent(securityPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(eventObserversPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(51, Short.MAX_VALUE))
            .addGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                    layout.createSequentialGroup().addContainerGap(279, Short.MAX_VALUE)
                                            .addComponent(warningPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    20, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addContainerGap())));
}