Package javax.swing

Examples of javax.swing.ListCellRenderer


        BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    tests = new JComboBox(model.getComboModel());
    tests.setMaximumRowCount(30);
    tests.setMaximumSize(new Dimension(250, 20));
    tests.addActionListener(this);
    tests.setRenderer(new ListCellRenderer() {
      JLabel categoryLabel = null;
      JLabel testLabel = null;

      @Override
      public Component getListCellRendererComponent(JList list, Object ovalue, int index,
View Full Code Here


        multiSelection.revalidate();
        multiSelection.repaint();
      }
    });

    list.setCellRenderer(new ListCellRenderer() {
      private final JCheckBox cb = new JCheckBox();

      private final JLabel label = new JLabel();

      @Override
View Full Code Here

    * @param initialValue - if nonnull it is the initial value to choose in this combo box
    */
   public OurCombobox (boolean addNull, Object[] list, int width, int height, Object initialValue) {
      super(do_copy(list, addNull));
      setFont(OurUtil.getVizFont());
      setRenderer(new ListCellRenderer() {
         public Component getListCellRendererComponent(JList list, Object value, int i, boolean selected, boolean focused) {
            if (jlabel == null) jlabel = OurUtil.label("", Color.BLACK, Color.WHITE, new EmptyBorder(0, 2, 0, 0));
            jlabel.setText(do_getText(value));
            jlabel.setIcon(do_getIcon(value));
            jlabel.setBackground(selected ? list.getSelectionBackground() : list.getBackground());
View Full Code Here

    ListModel textmodel = factory.getTexturesModel();
    JLabel texlabel = new JLabel(
        Messages.getString("SetSpriteTextureAction.LABEL_TEXTURE")); //$NON-NLS-1$
    JList texlist = new JList(textmodel);
    JScrollPane texscroll = new JScrollPane(texlist);
    ListCellRenderer texrender = new TextureCellRenderer();

    texlist.setCellRenderer(texrender);

    texlist.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    texlist.setVisibleRowCount(-1);
View Full Code Here

    ListModel textmodel = factory.getTexturesModel();
    JLabel texlabel = new JLabel(
        Messages.getString("CreateSpriteAction.LABEL_TEXTURE")); //$NON-NLS-1$
    JList texlist = new JList(textmodel);
    JScrollPane texscroll = new JScrollPane(texlist);
    ListCellRenderer texrender = new TextureCellRenderer();

    texlist.setCellRenderer(texrender);

    texlist.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    texlist.setVisibleRowCount(-1);
View Full Code Here

          selectNodes(selected, false);
        }

      }});
    nodeList.setBorder(BorderFactory.createTitledBorder("Nodes"));
    ListCellRenderer renderer = nodeList.getCellRenderer();
    if (renderer instanceof JLabel) {
      ((JLabel)renderer).setHorizontalAlignment(JLabel.CENTER);
    }
    window.getContentPane().add(new JScrollPane(nodeList), BorderLayout.WEST);
View Full Code Here

   * @param maxRowCount Maximum row count
   * @return The height (default of 100 if computation fails for any reason)
   */
  protected int computePopupHeightForRowCount(int maxRowCount)
  {
    ListCellRenderer renderer = list.getCellRenderer();
    int n = selectionField.getNumberOfItems();
    int rowCount = Math.min(maxRowCount, n);
    int height = 0;

    for (int i = 0; i < rowCount; ++i)
    {
      Object value = list.getModel().getElementAt(i);
      if (value == null)
        value = "x";
      Component c = renderer.getListCellRendererComponent(list, value, i, false, false);
      height += c.getPreferredSize().height;
    }

    return height == 0 ? 100 : height;
  }
View Full Code Here

      }

      // Let the renderer paint
      if (!iconOnly && comboBox != null)
      {
        ListCellRenderer renderer = comboBox.getRenderer();
        Component c;
        boolean renderPressed = getModel().isPressed();
        c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, renderPressed, false);
        c.setFont(rendererPane.getFont());

        c.setForeground(comboBox.getForeground());
        c.setBackground(comboBox.getBackground());
View Full Code Here

TOP

Related Classes of javax.swing.ListCellRenderer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.