Example #1
0
  // Add JButton and JList components to the panel.
  public ScribblePane3() {
    // Implicit super() call here invokes the superclass constructor

    // Add a "Clear" button to the panel.
    // Handle button events with an action listener
    JButton clear = new JButton("Clear");
    clear.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            clear();
          }
        });
    this.add(clear);

    // Add a JList to allow color choices.
    // Handle list selection events with a ListSelectionListener.
    final JList colorList = new JList(colorNames);
    colorList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            setColor(colors[colorList.getSelectedIndex()]);
          }
        });
    this.add(colorList);
  }
Example #2
0
 private void clearSourceSelected() {
   Object selected[] = sourceList.getSelectedValues();
   for (int i = selected.length - 1; i >= 0; --i) {
     sourceListModel.removeElement(selected[i]);
   }
   sourceList.getSelectionModel().clearSelection();
 }
  // -------------------------------------------------------------------------------------- //
  // ---------------------------------- Constructor Helpers ------------------------------- //
  // -------------------------------------------------------------------------------------- //
  private void buildActiveKits(JPanel container) {
    // initialize variable
    final int WIDTH = 150;

    // set containment panel properties
    container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
    setComponentSize(container, 150, PAGE_HEIGHT);

    JLabel header = new JLabel("Active Kits");
    header.setHorizontalAlignment(header.CENTER);
    header.setFont(new Font("Serif", Font.BOLD, 18));
    setComponentSize(header, WIDTH, 25);

    // create list model and list
    listModel = new DefaultListModel();
    kitList = new JList(listModel);
    kitList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    kitList.addListSelectionListener(this);
    kitList.setFixedCellHeight(25);
    JScrollPane listScrollPane = new JScrollPane(kitList);

    // add elements to containment panel
    container.add(header);
    container.add(listScrollPane);
  }
Example #4
0
  private void addListeners() {
    myMacrosList
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              public void valueChanged(ListSelectionEvent e) {
                Macro macro = getSelectedMacro();
                if (macro == null) {
                  myPreviewTextarea.setText("");
                  setOKActionEnabled(false);
                } else {
                  myPreviewTextarea.setText(macro.preview());
                  setOKActionEnabled(true);
                }
              }
            });

    // doubleclick support
    myMacrosList.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if ((e.getClickCount() == 2) && (getSelectedMacro() != null)) {
              close(OK_EXIT_CODE);
            }
          }
        });
  }
  /** Initializes the config list. */
  private void initList() {
    configList.setModel(new DefaultListModel());
    configList.setCellRenderer(new ConfigListCellRenderer());
    configList.addListSelectionListener(this);
    configList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JScrollPane configScrollList = new JScrollPane();

    configScrollList.getVerticalScrollBar().setUnitIncrement(30);

    configScrollList.getViewport().add(configList);

    add(configScrollList, BorderLayout.WEST);

    String osgiFilter =
        "(" + ConfigurationForm.FORM_TYPE + "=" + ConfigurationForm.ADVANCED_TYPE + ")";
    ServiceReference[] confFormsRefs = null;
    try {
      confFormsRefs =
          AdvancedConfigActivator.bundleContext.getServiceReferences(
              ConfigurationForm.class.getName(), osgiFilter);
    } catch (InvalidSyntaxException ex) {
    }

    if (confFormsRefs != null) {
      for (int i = 0; i < confFormsRefs.length; i++) {
        ConfigurationForm form =
            (ConfigurationForm) AdvancedConfigActivator.bundleContext.getService(confFormsRefs[i]);

        if (form.isAdvanced()) this.addConfigForm(form);
      }
    }
  }
Example #6
0
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   assert (value instanceof Node);
   Node node = (Node) value;
   String html =
       "<html><b>"
           + StringUtils.humanizeName(node.getName())
           + "</b> &ndash; "
           + node.getDescription()
           + "<br><font color=#333333>"
           + node.getDataClass().getSimpleName()
           + " &mdash;</font> <font color=#666666>"
           + node.getLibrary().getName()
           + "</font></html>";
   setText(html);
   if (isSelected) {
     setBackground(Theme.NODE_SELECTION_ACTIVE_BACKGROUND_COLOR);
   } else {
     setBackground(Theme.NODE_SELECTION_BACKGROUND_COLOR);
   }
   setEnabled(list.isEnabled());
   setFont(list.getFont());
   setIcon(new ImageIcon(NodeView.getImageForNode(node)));
   setBorder(Theme.BOTTOM_BORDER);
   setOpaque(true);
   return this;
 }
Example #7
0
  /**
   * Instantiates a new help search panel.
   *
   * @param root the root
   * @param dialog the dialog
   */
  public HelpSearchPanel(HelpIndexRoot root, HelpDialog dialog) {
    this.root = root;
    this.dialog = dialog;

    setLayout(new BorderLayout());

    JPanel queryPanel = new JPanel();
    queryPanel.setLayout(new BorderLayout());
    queryPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    queryField = new JTextField();
    queryField.setActionCommand(MenuUtils.SEARCH_BUTTON);
    queryField.addActionListener(this);
    queryPanel.add(queryField, BorderLayout.CENTER);
    searchButton = new JButton(MenuUtils.SEARCH_BUTTON);
    searchButton.setActionCommand(MenuUtils.SEARCH_BUTTON);
    searchButton.addActionListener(this);
    queryPanel.add(searchButton, BorderLayout.EAST);
    add(queryPanel, BorderLayout.NORTH);

    listModel = new DefaultListModel();
    listModel.addElement("[No search results]");
    resultList = new JList(listModel);
    resultList.addListSelectionListener(this);
    resultList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    resultsScrollPane = new JScrollPane(resultList);
    add(resultsScrollPane, BorderLayout.CENTER);
  }
 private void fillList(final HighlightSeverity severity) {
   DefaultListModel model = new DefaultListModel();
   model.removeAllElements();
   final List<SeverityBasedTextAttributes> infoTypes =
       new ArrayList<SeverityBasedTextAttributes>();
   infoTypes.addAll(SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
   Collections.sort(
       infoTypes,
       new Comparator<SeverityBasedTextAttributes>() {
         @Override
         public int compare(
             SeverityBasedTextAttributes attributes1, SeverityBasedTextAttributes attributes2) {
           return -mySeverityRegistrar.compare(
               attributes1.getSeverity(), attributes2.getSeverity());
         }
       });
   SeverityBasedTextAttributes preselection = null;
   for (SeverityBasedTextAttributes type : infoTypes) {
     model.addElement(type);
     if (type.getSeverity().equals(severity)) {
       preselection = type;
     }
   }
   myOptionsList.setModel(model);
   myOptionsList.setSelectedValue(preselection, true);
 }
 @Override
 protected void doOKAction() {
   apply((SeverityBasedTextAttributes) myOptionsList.getSelectedValue());
   final Collection<SeverityBasedTextAttributes> infoTypes =
       new HashSet<SeverityBasedTextAttributes>(
           SeverityUtil.getRegisteredHighlightingInfoTypes(mySeverityRegistrar));
   final ListModel listModel = myOptionsList.getModel();
   final List<HighlightSeverity> order = new ArrayList<HighlightSeverity>();
   for (int i = listModel.getSize() - 1; i >= 0; i--) {
     final SeverityBasedTextAttributes info =
         (SeverityBasedTextAttributes) listModel.getElementAt(i);
     order.add(info.getSeverity());
     if (!mySeverityRegistrar.isDefaultSeverity(info.getSeverity())) {
       infoTypes.remove(info);
       final Color stripeColor = info.getAttributes().getErrorStripeColor();
       mySeverityRegistrar.registerSeverity(
           info, stripeColor != null ? stripeColor : LightColors.YELLOW);
     }
   }
   for (SeverityBasedTextAttributes info : infoTypes) {
     mySeverityRegistrar.unregisterSeverity(info.getSeverity());
   }
   mySeverityRegistrar.setOrder(order);
   super.doOKAction();
 }
  public FeedbackViewerUI(
      DefaultListModel<AbstractFeedbackType> questionListModel,
      DefaultListModel<FeedbackViewerUserEntry> userListModel) {
    super();
    setTitle("Feedback Viewer");
    setIconImage(Loader.getImageIcon(Loader.IMAGE_STURESY).getImage());

    // Button Panel containing download/upload/etc. buttons
    JPanel buttonPanel = createButtonPanel();

    JPanel leftPanel = new JPanel();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS));

    questionList = new JList<>(questionListModel);
    questionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    questionList.setCellRenderer(new NumberedListCellRenderer());
    userList = new JList<>(userListModel);
    userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane questionListScrollPane = new JScrollPane(questionList);
    JScrollPane userListScrollPane = new JScrollPane(userList);

    // Populate left panel of SplitPane
    leftPanel.add(new JLabel("Select by Question:"));
    leftPanel.add(questionListScrollPane);
    leftPanel.add(new JLabel("Select by User:"));
    leftPanel.add(userListScrollPane);

    splitPane = new JSplitPane();
    splitPane.setLeftComponent(leftPanel);

    add(splitPane, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.PAGE_END);

    setRightPanel(new JPanel());
  }
Example #11
0
  @Override
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnQAuswahl) {
      addQListBoxEintrag(dateiAuswählen());
    }
    if (e.getSource() == btnQEntfernen) {
      subQListBoxEintrag();
    }
    if (e.getSource() == btnZAuswahl) {
      addZListBoxEintrag(dateiAuswählen());
    }
    if (e.getSource() == btnZEntfernen) {
      subZListBoxEintrag();
    }
    if (e.getSource() == btnSync) {

      startCopy(
          (Path) quellJList.getSelectedValue().getValueMember(),
          (Path) zielJList.getSelectedValue().getValueMember());
    }
    if (e.getSource() == btnAbbruch) {
      setAbbruch();
    }
    if (e.getSource() == btnBackup) {
      MainNtray.bwvisible();
      this.invisible();
    }
  }
Example #12
0
  protected void exportDone(JComponent c, Transferable data, int action) {
    //System.out.println("action="+action + " " + addCount + " " + sourceIndices);
    if ((action == MOVE) && (sourceIndices != null)) {
      DefaultListModel model = (DefaultListModel) source.getModel();

      //If we are moving items around in the same list, we
      //need to adjust the indices accordingly since those
      //after the insertion point have moved.
      if (addCount > 0) {
        for (int i = 0; i < sourceIndices.length; i++) {
          if (sourceIndices[i] > addIndex) {
            sourceIndices[i] += addCount;
          }
        }
      }
      for (int i = sourceIndices.length - 1; i >= 0; i--)
        model.remove(sourceIndices[i]);
      ((JList) c).setSelectedIndices(new int[] {});
      if (webPanel != null)
        webPanel.syncLists();
    }
    sourceIndices = null;
    addIndex = -1;
    addCount = 0;
  }
Example #13
0
 void enableButtons(JList list) {
   int nSelected = list.getSelectedIndices().length;
   int nListed = list.getModel().getSize();
   saveButton.setEnabled(nListed > 0);
   deleteInstanceButton.setEnabled(nSelected > 0);
   showInstanceButton.setEnabled(nSelected == 1);
 }
Example #14
0
 String getInstanceName(int i) {
   if (i < 0)
     i = instanceList.getSelectedIndex();
   JmolInstance instance = (JmolInstance) instanceList.getModel()
       .getElementAt(i);
   return (instance == null ? "" : instance.name);
 }
Example #15
0
  public SplitPaneDemo() {

    // Create the list of images and put it in a scroll pane.

    list = new JList(imageNames);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);

    JScrollPane listScrollPane = new JScrollPane(list);
    picture = new JLabel();
    picture.setFont(picture.getFont().deriveFont(Font.ITALIC));
    picture.setHorizontalAlignment(JLabel.CENTER);

    JScrollPane pictureScrollPane = new JScrollPane(picture);

    // Create a split pane with the two scroll panes in it.
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(150);

    // Provide minimum sizes for the two components in the split pane.
    Dimension minimumSize = new Dimension(100, 50);
    listScrollPane.setMinimumSize(minimumSize);
    pictureScrollPane.setMinimumSize(minimumSize);

    // Provide a preferred size for the split pane.
    splitPane.setPreferredSize(new Dimension(400, 200));
    updateLabel(imageNames[list.getSelectedIndex()]);
  }
 @Override
 public boolean setArgs(String[] args) {
   try {
     // first make sure that there are the right number of args
     if (args.length != numArgs) {
       return false;
     }
     name = args[0];
     description = args[1];
     label = args[2];
     if (args[3].toLowerCase().contains("false")) {
       multiSelect = false;
       list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     } else { // true
       multiSelect = true;
       list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
     }
     //            if (args[4].toLowerCase().contains("false")) {
     //                this.isVisible() = false;
     //            }
     // value = (String)comboBox.getSelectedItem();
     createUI();
     return true;
   } catch (Exception e) {
     return false;
   }
 }
Example #17
0
 public NodeSelectionDialog(Frame owner, NodeLibrary library, NodeLibraryManager manager) {
   super(owner, "New Node", true);
   getRootPane().putClientProperty("Window.style", "small");
   JPanel panel = new JPanel(new BorderLayout());
   this.library = library;
   this.manager = manager;
   filteredNodeListModel = new FilteredNodeListModel(library, manager);
   searchField = new JTextField();
   searchField.putClientProperty("JTextField.variant", "search");
   EscapeListener escapeListener = new EscapeListener();
   searchField.addKeyListener(escapeListener);
   ArrowKeysListener arrowKeysListener = new ArrowKeysListener();
   searchField.addKeyListener(arrowKeysListener);
   SearchFieldChangeListener searchFieldChangeListener = new SearchFieldChangeListener();
   searchField.getDocument().addDocumentListener(searchFieldChangeListener);
   nodeList = new JList(filteredNodeListModel);
   DoubleClickListener doubleClickListener = new DoubleClickListener();
   nodeList.addMouseListener(doubleClickListener);
   nodeList.addKeyListener(escapeListener);
   nodeList.addKeyListener(arrowKeysListener);
   nodeList.setSelectedIndex(0);
   nodeList.setCellRenderer(new NodeRenderer());
   JScrollPane nodeScroll =
       new JScrollPane(
           nodeList,
           JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
           JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
   nodeScroll.setBorder(null);
   panel.add(searchField, BorderLayout.NORTH);
   panel.add(nodeScroll, BorderLayout.CENTER);
   setContentPane(panel);
   setSize(500, 400);
   SwingUtils.centerOnScreen(this);
 }
Example #18
0
    /*
     * Fires AccessibleActiveDescendant PropertyChangeEvent to notify listeners
     * on the popup menu invoker that a popup list item has been selected
     */
    private void fireActiveDescendant() {
      if (JPopupMenu.this instanceof BasicComboPopup) {
        // get the popup list
        JList popupList = ((BasicComboPopup) JPopupMenu.this).getList();
        if (popupList == null) {
          return;
        }

        // get the first selected item
        AccessibleContext ac = popupList.getAccessibleContext();
        AccessibleSelection selection = ac.getAccessibleSelection();
        if (selection == null) {
          return;
        }
        Accessible a = selection.getAccessibleSelection(0);
        if (a == null) {
          return;
        }
        AccessibleContext selectedItem = a.getAccessibleContext();

        // fire the event with the popup invoker as the source.
        if (selectedItem != null && invoker != null) {
          AccessibleContext invokerContext = invoker.getAccessibleContext();
          if (invokerContext != null) {
            // Check invokerContext because Component.getAccessibleContext
            // returns null. Classes that extend Component are responsible
            // for returning a non-null AccessibleContext.
            invokerContext.firePropertyChange(
                ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, null, selectedItem);
          }
        }
      }
    }
Example #19
0
  /** {@inheritDoc} */
  @Override
  public Component getListCellRendererComponent(
      JList list,
      final Object value,
      final int index,
      boolean isSelected,
      final boolean cellHasFocus) {

    Component label = getObjectComponent(list, value, index, isSelected, cellHasFocus);
    if (label instanceof JComponent) ((JComponent) label).setOpaque(false);

    panel.removeAll();
    panel.add(label);
    panel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    panel.restoreBackground();

    if (cellHasFocus)
      if (panel.isBackgroundRestored())
        panel.setBackground(UIUtils.setAlpha(list.getSelectionBackground(), 100));
      else panel.setBorder(BorderFactory.createLineBorder(list.getSelectionBackground()));

    if (isSelected)
      if (panel.isBackgroundRestored())
        panel.setBackground(UIUtils.setAlpha(list.getSelectionBackground(), 200));
      else panel.setBorder(BorderFactory.createLineBorder(list.getSelectionBackground()));

    if (index == hoveredIndex) panel.mouseEntered(null);

    return panel;
  }
Example #20
0
 public void valueChanged(ListSelectionEvent e) {
   if (!myIsEnabled || e.getValueIsAdjusting()) {
     return;
   }
   final JList list = (JList) e.getSource();
   processListValue(list.getSelectedValue());
 }
Example #21
0
  private void initDialog() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setTitle("");

    list.setVisibleRowCount(4);
    list.setEnabled(true);
    listPanel.add(new JScrollPane(list));

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JPanel buttonPanel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    String[] buttonNames = {"delete", "add", "cancel", "add"};
    for (int i = 0; i < buttonNames.length; i++) {
      JButton b = new JButton(buttonNames[i]);
      b.setActionCommand(Integer.toString(i));
      b.addActionListener(this);
      if (i < CANCEL) buttonPanel.add(b);
      else buttonPanel2.add(b);
    }
    listPanel.add(buttonPanel, BorderLayout.SOUTH);

    addElementPanel.add(buttonPanel2, BorderLayout.SOUTH);
    addElementPanel.setBorder(BorderFactory.createTitledBorder("add"));
    addElementPanel.setVisible(false);

    add(listPanel);
    add(addElementPanel);
  }
Example #22
0
  /** deletes the chosen attributes */
  public void deleteAttributes() {
    ListSelectorDialog dialog;
    ArffSortedTableModel model;
    Object[] atts;
    int[] indices;
    int i;
    JList list;
    int result;

    list = new JList(getAttributes());
    dialog = new ListSelectorDialog(null, list);
    result = dialog.showDialog();

    if (result != ListSelectorDialog.APPROVE_OPTION) return;

    atts = list.getSelectedValues();

    // really?
    if (ComponentHelper.showMessageBox(
            getParent(),
            "Confirm...",
            "Do you really want to delete these " + atts.length + " attributes?",
            JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE)
        != JOptionPane.YES_OPTION) return;

    model = (ArffSortedTableModel) m_TableArff.getModel();
    indices = new int[atts.length];
    for (i = 0; i < atts.length; i++) indices[i] = model.getAttributeColumn(atts[i].toString());

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    model.deleteAttributes(indices);
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
  }
Example #23
0
  // Listener method for list selection changes.
  public void valueChanged(ListSelectionEvent e) {
    if (e.getValueIsAdjusting() == false) {

      if (list.getSelectedIndex() == -1) {
        // No selection: disable delete, up, and down buttons.
        deleteButton.setEnabled(false);
        upButton.setEnabled(false);
        downButton.setEnabled(false);
        nameField.setText("");

      } else if (list.getSelectedIndices().length > 1) {
        // Multiple selection: disable up and down buttons.
        deleteButton.setEnabled(true);
        upButton.setEnabled(false);
        downButton.setEnabled(false);

      } else {
        // Single selection: permit all operations.
        deleteButton.setEnabled(true);
        upButton.setEnabled(true);
        downButton.setEnabled(true);
        nameField.setText(list.getSelectedValue().toString());
      }
    }
  }
  public Component getListCellRendererComponent(
      JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

    /**
     * if (isSelected) { setBackground(UIManager.getColor("ComboBox.selectionBackground"));
     * setForeground(UIManager.getColor("ComboBox.selectionForeground")); } else {
     * setBackground(UIManager.getColor("ComboBox.background"));
     * setForeground(UIManager.getColor("ComboBox.foreground")); }*
     */
    if (isSelected) {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    } else {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }

    setFont(list.getFont());

    if (value instanceof Icon) {
      setIcon((Icon) value);
    } else {
      setText((value == null) ? "" : value.toString());
    }
    return this;
  }
    @Override
    protected void customizeCellRenderer(
        JList list, Object value, int index, boolean selected, boolean hasFocus) {
      setIcon(myListEntryIcon);
      if (myUseIdeaEditor) {
        int max = list.getModel().getSize();
        String indexString = String.valueOf(index + 1);
        int count = String.valueOf(max).length() - indexString.length();
        char[] spaces = new char[count];
        Arrays.fill(spaces, ' ');
        String prefix = indexString + new String(spaces) + "  ";
        append(prefix, SimpleTextAttributes.GRAYED_ATTRIBUTES);
      } else if (UIUtil.isUnderGTKLookAndFeel()) {
        // Fix GTK background
        Color background =
            selected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground();
        UIUtil.changeBackGround(this, background);
      }
      String text = ((Item) value).shortText;

      FontMetrics metrics = list.getFontMetrics(list.getFont());
      int charWidth = metrics.charWidth('m');
      int maxLength = list.getParent().getParent().getWidth() * 3 / charWidth / 2;
      text = StringUtil.first(text, maxLength, true); // do not paint long strings
      append(text, SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
Example #26
0
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      // #93658: GTK needs name to render cell renderer "natively"
      setName("ComboBox.listRenderer"); // NOI18N

      String config = (String) value;
      String label;
      if (config == null) {
        // uninitialized?
        label = null;
      } else if (config.length() > 0) {
        Map<String, String> m = configs.get(config);
        label = m != null ? m.get("$label") : /* temporary? */ null; // NOI18N
        if (label == null) {
          label = config;
        }
      } else {
        label =
            NbBundle.getBundle("org.netbeans.modules.java.j2seproject.Bundle")
                .getString("J2SEConfigurationProvider.default.label"); // NOI18N
      }
      setText(label);

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

      return this;
    }
Example #27
0
 private void clearDestinationSelected() {
   Object selected[] = destList.getSelectedValues();
   for (int i = selected.length - 1; i >= 0; --i) {
     destListModel.removeElement(selected[i]);
   }
   destList.getSelectionModel().clearSelection();
 }
Example #28
0
 @Override
 public void valueChanged(ListSelectionEvent e) {
   if (e.getSource() == listData && listData.getSelectedValue() != null) {
     Data tmp = rssFeed.searchByTitle((String) listData.getSelectedValue());
     if (tmp != null) this.desc.setText(tmp.getDesc());
   }
 }
  /*
   *  Adjust the width of the scrollpane used by the popup
   */
  protected void popupWider(BasicComboPopup popup) {
    JList list = popup.getList();

    //  Determine the maximimum width to use:
    //  a) determine the popup preferred width
    //  b) limit width to the maximum if specified
    //  c) ensure width is not less than the scroll pane width

    int popupWidth =
        list.getPreferredSize().width
            + 5 // make sure horizontal scrollbar doesn't appear
            + getScrollBarWidth(popup, scrollPane);

    if (maximumWidth != -1) {
      popupWidth = Math.min(popupWidth, maximumWidth);
    }

    Dimension scrollPaneSize = scrollPane.getPreferredSize();
    popupWidth = Math.max(popupWidth, scrollPaneSize.width);

    //  Adjust the width

    scrollPaneSize.width = popupWidth;
    scrollPane.setPreferredSize(scrollPaneSize);
    scrollPane.setMaximumSize(scrollPaneSize);
  }
Example #30
0
 private void initPlugins() {
   plugins.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   plugins.addListSelectionListener(
       new ListSelectionListener() {
         @Override
         public void valueChanged(ListSelectionEvent e) {
           if (plugins.getSelectedIndex() != -1) {
             PluginLoader loader = getCurrentLoader();
             description.setText(loader.getDescription());
             description.revalidate();
             config.setEnabled(loader.getConfigDialog(SelectionFrame.this) != null);
             StringBuilder sb = new StringBuilder();
             if (stat.isEmpty()) {
               sb = sb.append(loader.getName());
             } else {
               sb = sb.append(stat).append(" > ").append(loader.getName());
             }
             for (int i = 0;
                 i < InterfaceConfig.SELECTION_FRAME_PROPERTIES.getInt("tabs-count");
                 i++) {
               sb = sb.insert(0, "    ");
             }
             status.setText(sb.toString());
           }
         }
       });
   setLoaders(TaskState.getLoaders());
 }