Java 类javax.swing.plaf.basic.BasicComboBoxRenderer 实例源码

项目:incubator-netbeans    文件:GenericToolbar.java   
public Dimension getPreferredSize() {
    Dimension dim = super.getPreferredSize();
    if (PREFERRED_HEIGHT == -1) {
        GenericToolbar tb = new GenericToolbar();
        tb.setBorder(getBorder());
        tb.setBorderPainted(isBorderPainted());
        tb.setRollover(isRollover());
        tb.setFloatable(isFloatable());
        Icon icon = Icons.getIcon(GeneralIcons.SAVE);
        tb.add(new JButton("Button", icon)); // NOI18N
        tb.add(new JToggleButton("Button", icon)); // NOI18N
        tb.add(new JTextField("Text")); // NOI18N
        JComboBox c = new JComboBox();
        c.setEditor(new BasicComboBoxEditor());
        c.setRenderer(new BasicComboBoxRenderer());
        tb.add(c);
        tb.addSeparator();
        PREFERRED_HEIGHT = tb.getSuperPreferredSize().height;
    }
    dim.height = getParent() instanceof JToolBar ? 1 :
                 Math.max(dim.height, PREFERRED_HEIGHT);
    return dim;
}
项目:Introspect-Framework    文件:ComboBox.java   
private ListCellRenderer createObjectRenderer(
        final ReflectionProvider reflectionProvider) {
    return new BasicComboBoxRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list,
                Object value, int index, boolean isSelected,
                boolean cellHasFocus) {

            super.getListCellRendererComponent(list, value, index,
                    isSelected, cellHasFocus);

            String text = "";
            if (value != null) {
                ClassInfo classInfo = reflectionProvider.getClassInfo(value
                        .getClass());
                text = classInfo.getTitle(value);
            }
            setText(text);
            return this;
        }

    };
}
项目:Introspect-Framework    文件:ComboBox.java   
private ListCellRenderer createEnumRenderer(final Format format) {
    return new BasicComboBoxRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list,
                Object value, int index, boolean isSelected,
                boolean cellHasFocus) {

            super.getListCellRendererComponent(list, value, index,
                    isSelected, cellHasFocus);

            String text = format.format(value);
            setText(text);

            return this;
        }

    };
}
项目:cn1    文件:MetalComboBoxUITest.java   
public void testGetMinimumSize() throws Exception {
    ui.setComboBox(comboBox);
    ComboPopup popup = new BasicComboPopup(comboBox);
    ui.setPopup(popup);
    ui.setListBox(popup.getList());
    ui.installListeners();
    comboBox.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    Dimension listPart = new BasicComboBoxRenderer().getListCellRendererComponent(
            popup.getList(), "", -1, false, false).getPreferredSize();
    Dimension expectedSize = new Dimension(listPart.width + listPart.height + 8,
            listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
    assertEquals(expectedSize, ui.getCachedMinimumSize());
    ui.setCachedMinimumSize(new Dimension(100, 100));
    assertEquals(ui.getCachedMinimumSize(), ui.getMinimumSize(null));
    comboBox.addItem("aaa");
    listPart = new BasicComboBoxRenderer().getListCellRendererComponent(popup.getList(),
            "aaa", -1, false, false).getPreferredSize();
    expectedSize = new Dimension(listPart.width + listPart.height + 8, listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
}
项目:tools-idea    文件:DarculaComboBoxUI.java   
@Override
protected ListCellRenderer createRenderer() {
  return new BasicComboBoxRenderer.UIResource() {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      if (c instanceof JComponent) {
        final JComponent jc = (JComponent)c;
        if (index == -1) {
          jc.setOpaque(false);
          jc.setForeground(list.getForeground());
        } else {
          jc.setOpaque(true);
        }
      }
      return c;
    }
  };
}
项目:SubTools    文件:PartialDisableComboBox.java   
@SuppressWarnings("unchecked")
public PartialDisableComboBox(Object[] items) {
  super();
  for (Object o : items) {
    addItem(o);
  }
  this.setRenderer(new BasicComboBoxRenderer() {
    private static final long serialVersionUID = -2774241371293899669L;

    @SuppressWarnings("rawtypes")
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index,
        boolean isSelected, boolean cellHasFocus) {
      Component c =
          super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      boolean disabled = index >= 0 && index < itemsState.size() && !itemsState.get(index);
      c.setEnabled(!disabled);
      c.setFocusable(!disabled);
      return c;
    }
  });
}
项目:freeVM    文件:MetalComboBoxUITest.java   
public void testGetMinimumSize() throws Exception {
    ui.setComboBox(comboBox);
    ComboPopup popup = new BasicComboPopup(comboBox);
    ui.setPopup(popup);
    ui.setListBox(popup.getList());
    ui.installListeners();
    comboBox.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    Dimension listPart = new BasicComboBoxRenderer().getListCellRendererComponent(
            popup.getList(), "", -1, false, false).getPreferredSize();
    Dimension expectedSize = new Dimension(listPart.width + listPart.height + 8,
            listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
    assertEquals(expectedSize, ui.getCachedMinimumSize());
    ui.setCachedMinimumSize(new Dimension(100, 100));
    assertEquals(ui.getCachedMinimumSize(), ui.getMinimumSize(null));
    comboBox.addItem("aaa");
    listPart = new BasicComboBoxRenderer().getListCellRendererComponent(popup.getList(),
            "aaa", -1, false, false).getPreferredSize();
    expectedSize = new Dimension(listPart.width + listPart.height + 8, listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
}
项目:freeVM    文件:MetalComboBoxUITest.java   
public void testGetMinimumSize() throws Exception {
    ui.setComboBox(comboBox);
    ComboPopup popup = new BasicComboPopup(comboBox);
    ui.setPopup(popup);
    ui.setListBox(popup.getList());
    ui.installListeners();
    comboBox.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    Dimension listPart = new BasicComboBoxRenderer().getListCellRendererComponent(
            popup.getList(), "", -1, false, false).getPreferredSize();
    Dimension expectedSize = new Dimension(listPart.width + listPart.height + 8,
            listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
    assertEquals(expectedSize, ui.getCachedMinimumSize());
    ui.setCachedMinimumSize(new Dimension(100, 100));
    assertEquals(ui.getCachedMinimumSize(), ui.getMinimumSize(null));
    comboBox.addItem("aaa");
    listPart = new BasicComboBoxRenderer().getListCellRendererComponent(popup.getList(),
            "aaa", -1, false, false).getPreferredSize();
    expectedSize = new Dimension(listPart.width + listPart.height + 8, listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
}
项目:consulo    文件:ModernComboBoxUI.java   
@Override
protected ListCellRenderer createRenderer() {
  return new BasicComboBoxRenderer.UIResource() {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      if (c instanceof JComponent) {
        final JComponent jc = (JComponent)c;
        if (index == -1) {
          jc.setOpaque(false);
          jc.setForeground(list.getForeground());
        }
        else {
          jc.setOpaque(true);
        }
      }
      return c;
    }
  };
}
项目:consulo    文件:DarculaComboBoxUI.java   
@Override
protected ListCellRenderer createRenderer() {
  return new BasicComboBoxRenderer.UIResource() {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      if (c instanceof JComponent) {
        final JComponent jc = (JComponent)c;
        if (index == -1) {
          jc.setOpaque(false);
          jc.setForeground(list.getForeground());
        }
        else {
          jc.setOpaque(true);
        }
      }
      return c;
    }
  };
}
项目:jdk8u-jdk    文件:Test7195179.java   
public static void main(String[] args) throws Exception {
    invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Integer[] items = {null, 1, 2, 3};
            JComboBox<Integer> combo = new JComboBox<>(items);
            JLabel label = new JLabel("choose:");
            JPanel panel = new JPanel();
            GroupLayout layout = new GroupLayout(panel);
            panel.setLayout(layout);
            label.setLabelFor(combo);
            combo.setSelectedIndex(0);
            combo.setRenderer(new ListCellRenderer<Integer>() {
                private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();

                @Override
                public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
                    return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                }
            });
            layout.setAutoCreateContainerGaps(true);
            layout.setAutoCreateGaps(true);
            layout.setHorizontalGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup().addComponent(label))
                    .addGroup(layout.createParallelGroup().addComponent(combo)));
            layout.setVerticalGroup(layout
                    .createSequentialGroup()
                    .addGroup(layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label)
                            .addComponent(combo)));

            JFrame frame = new JFrame(getClass().getSimpleName());
            frame.add(panel);
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:openjdk-jdk10    文件:Test7195179.java   
public static void main(String[] args) throws Exception {
    invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Integer[] items = {null, 1, 2, 3};
            JComboBox<Integer> combo = new JComboBox<>(items);
            JLabel label = new JLabel("choose:");
            JPanel panel = new JPanel();
            GroupLayout layout = new GroupLayout(panel);
            panel.setLayout(layout);
            label.setLabelFor(combo);
            combo.setSelectedIndex(0);
            combo.setRenderer(new ListCellRenderer<Integer>() {
                private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();

                @Override
                public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
                    return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                }
            });
            layout.setAutoCreateContainerGaps(true);
            layout.setAutoCreateGaps(true);
            layout.setHorizontalGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup().addComponent(label))
                    .addGroup(layout.createParallelGroup().addComponent(combo)));
            layout.setVerticalGroup(layout
                    .createSequentialGroup()
                    .addGroup(layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label)
                            .addComponent(combo)));

            JFrame frame = new JFrame(getClass().getSimpleName());
            frame.add(panel);
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:openjdk9    文件:Test7195179.java   
public static void main(String[] args) throws Exception {
    invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Integer[] items = {null, 1, 2, 3};
            JComboBox<Integer> combo = new JComboBox<>(items);
            JLabel label = new JLabel("choose:");
            JPanel panel = new JPanel();
            GroupLayout layout = new GroupLayout(panel);
            panel.setLayout(layout);
            label.setLabelFor(combo);
            combo.setSelectedIndex(0);
            combo.setRenderer(new ListCellRenderer<Integer>() {
                private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();

                @Override
                public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
                    return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                }
            });
            layout.setAutoCreateContainerGaps(true);
            layout.setAutoCreateGaps(true);
            layout.setHorizontalGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup().addComponent(label))
                    .addGroup(layout.createParallelGroup().addComponent(combo)));
            layout.setVerticalGroup(layout
                    .createSequentialGroup()
                    .addGroup(layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label)
                            .addComponent(combo)));

            JFrame frame = new JFrame(getClass().getSimpleName());
            frame.add(panel);
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:jdk8u_jdk    文件:Test7195179.java   
public static void main(String[] args) throws Exception {
    invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Integer[] items = {null, 1, 2, 3};
            JComboBox<Integer> combo = new JComboBox<>(items);
            JLabel label = new JLabel("choose:");
            JPanel panel = new JPanel();
            GroupLayout layout = new GroupLayout(panel);
            panel.setLayout(layout);
            label.setLabelFor(combo);
            combo.setSelectedIndex(0);
            combo.setRenderer(new ListCellRenderer<Integer>() {
                private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();

                @Override
                public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
                    return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                }
            });
            layout.setAutoCreateContainerGaps(true);
            layout.setAutoCreateGaps(true);
            layout.setHorizontalGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup().addComponent(label))
                    .addGroup(layout.createParallelGroup().addComponent(combo)));
            layout.setVerticalGroup(layout
                    .createSequentialGroup()
                    .addGroup(layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label)
                            .addComponent(combo)));

            JFrame frame = new JFrame(getClass().getSimpleName());
            frame.add(panel);
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:lookaside_java-1.8.0-openjdk    文件:Test7195179.java   
public static void main(String[] args) throws Exception {
    invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Integer[] items = {null, 1, 2, 3};
            JComboBox<Integer> combo = new JComboBox<>(items);
            JLabel label = new JLabel("choose:");
            JPanel panel = new JPanel();
            GroupLayout layout = new GroupLayout(panel);
            panel.setLayout(layout);
            label.setLabelFor(combo);
            combo.setSelectedIndex(0);
            combo.setRenderer(new ListCellRenderer<Integer>() {
                private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();

                @Override
                public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
                    return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                }
            });
            layout.setAutoCreateContainerGaps(true);
            layout.setAutoCreateGaps(true);
            layout.setHorizontalGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup().addComponent(label))
                    .addGroup(layout.createParallelGroup().addComponent(combo)));
            layout.setVerticalGroup(layout
                    .createSequentialGroup()
                    .addGroup(layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label)
                            .addComponent(combo)));

            JFrame frame = new JFrame(getClass().getSimpleName());
            frame.add(panel);
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:intellij-ce-playground    文件:ComboBoxTableCellEditor.java   
private ComboBoxTableCellEditor() {
  myComboBox.setRenderer(new BasicComboBoxRenderer());
  myComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      stopCellEditing();
    }
  });
  myPanel.add(myComboBox,
              new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0,
                                     0));
}
项目:confluence.keygen    文件:PlasticComboBoxUI.java   
protected ListCellRenderer createRenderer()
/* 105:    */   {
/* 106:186 */     if (this.tableCellEditor) {
/* 107:187 */       return super.createRenderer();
/* 108:    */     }
/* 109:189 */     BasicComboBoxRenderer renderer = new BasicComboBoxRenderer.UIResource();
/* 110:190 */     renderer.setBorder(UIManager.getBorder("ComboBox.rendererBorder"));
/* 111:191 */     return renderer;
/* 112:    */   }
项目:infobip-open-jdk-8    文件:Test7195179.java   
public static void main(String[] args) throws Exception {
    invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Integer[] items = {null, 1, 2, 3};
            JComboBox<Integer> combo = new JComboBox<>(items);
            JLabel label = new JLabel("choose:");
            JPanel panel = new JPanel();
            GroupLayout layout = new GroupLayout(panel);
            panel.setLayout(layout);
            label.setLabelFor(combo);
            combo.setSelectedIndex(0);
            combo.setRenderer(new ListCellRenderer<Integer>() {
                private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();

                @Override
                public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
                    return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                }
            });
            layout.setAutoCreateContainerGaps(true);
            layout.setAutoCreateGaps(true);
            layout.setHorizontalGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup().addComponent(label))
                    .addGroup(layout.createParallelGroup().addComponent(combo)));
            layout.setVerticalGroup(layout
                    .createSequentialGroup()
                    .addGroup(layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label)
                            .addComponent(combo)));

            JFrame frame = new JFrame(getClass().getSimpleName());
            frame.add(panel);
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:jdk8u-dev-jdk    文件:Test7195179.java   
public static void main(String[] args) throws Exception {
    invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Integer[] items = {null, 1, 2, 3};
            JComboBox<Integer> combo = new JComboBox<>(items);
            JLabel label = new JLabel("choose:");
            JPanel panel = new JPanel();
            GroupLayout layout = new GroupLayout(panel);
            panel.setLayout(layout);
            label.setLabelFor(combo);
            combo.setSelectedIndex(0);
            combo.setRenderer(new ListCellRenderer<Integer>() {
                private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();

                @Override
                public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
                    return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                }
            });
            layout.setAutoCreateContainerGaps(true);
            layout.setAutoCreateGaps(true);
            layout.setHorizontalGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup().addComponent(label))
                    .addGroup(layout.createParallelGroup().addComponent(combo)));
            layout.setVerticalGroup(layout
                    .createSequentialGroup()
                    .addGroup(layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label)
                            .addComponent(combo)));

            JFrame frame = new JFrame(getClass().getSimpleName());
            frame.add(panel);
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:OLD-OpenJDK8    文件:Test7195179.java   
public static void main(String[] args) throws Exception {
    invokeAndWait(new Runnable() {
        @Override
        public void run() {
            Integer[] items = {null, 1, 2, 3};
            JComboBox<Integer> combo = new JComboBox<>(items);
            JLabel label = new JLabel("choose:");
            JPanel panel = new JPanel();
            GroupLayout layout = new GroupLayout(panel);
            panel.setLayout(layout);
            label.setLabelFor(combo);
            combo.setSelectedIndex(0);
            combo.setRenderer(new ListCellRenderer<Integer>() {
                private final BasicComboBoxRenderer renderer = new BasicComboBoxRenderer();

                @Override
                public Component getListCellRendererComponent(JList<? extends Integer> list, Integer value, int index, boolean isSelected, boolean cellHasFocus) {
                    return this.renderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                }
            });
            layout.setAutoCreateContainerGaps(true);
            layout.setAutoCreateGaps(true);
            layout.setHorizontalGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup().addComponent(label))
                    .addGroup(layout.createParallelGroup().addComponent(combo)));
            layout.setVerticalGroup(layout
                    .createSequentialGroup()
                    .addGroup(layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(label)
                            .addComponent(combo)));

            JFrame frame = new JFrame(getClass().getSimpleName());
            frame.add(panel);
            frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        }
    });
}
项目:tools-idea    文件:ComboBoxTableCellEditor.java   
private ComboBoxTableCellEditor() {
  myComboBox.setRenderer(new BasicComboBoxRenderer());
  myComboBox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      stopCellEditing();
    }
  });
  myPanel.add(myComboBox,
              new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0,
                                     0));
}
项目:intellij-xquery    文件:DataSourceSelectorGuiTest.java   
@Test
public void shouldDisplayNoSelected() {
    window.label(new GenericTypeMatcher<BasicComboBoxRenderer>(BasicComboBoxRenderer.class) {
        @Override
        protected boolean isMatching(BasicComboBoxRenderer component) {
            return true;
        }
    }).requireText(NO_DATA_SOURCE);
}
项目:consulo    文件:ComboBoxTableCellEditor.java   
private ComboBoxTableCellEditor() {
  myComboBox.setRenderer(new BasicComboBoxRenderer());
  myComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      stopCellEditing();
    }
  });
  myPanel.add(myComboBox,
              new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0,
                                     0));
}
项目:PasswordSafe    文件:AgComboBoxUI.java   
protected ListCellRenderer createRenderer()
{
    return new BasicComboBoxRenderer();
}
项目:FlexProjector    文件:FlexProjectorWindow.java   
private Projection askUserForProjection() {
    Projection proj = null;

    // construct list with projection names
    java.util.List projNames = ProjectionsManager.getProjectionNames(false, false, false);
    DisplayModel dm = projectionBrewerPanel.getModel().getDisplayModel();
    if (dm.showFlexProjection) {
        Projection flexProj = projectionBrewerPanel.getModel().getDesignProjection();
        projNames.add(new JSeparator());
        projNames.add(flexProj.getName());
    }

    // display dialog
    JComboBox jcb = new JComboBox(projNames.toArray());
    jcb.setMaximumRowCount(projNames.size());
    // custom renderer for separator in menu
    jcb.setRenderer(new BasicComboBoxRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value,
                int index, boolean isSelected, boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (value instanceof JSeparator) {
                return (JSeparator) value;
            }
            return this;
        }
    });

    int res = JOptionPane.showOptionDialog(this, jcb, "Select a Projection",
            JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
            null, null, null);
    if (res == JOptionPane.OK_OPTION) {
        if (jcb.getSelectedIndex() == projNames.size() - 1) {
            proj = projectionBrewerPanel.getModel().getDesignProjection();
            proj = cloneAndNormalizeIfFlexProjection(proj);
        } else {
            proj = ProjectionsManager.getProjection((String) (jcb.getSelectedItem()));
        }
        proj.initialize();
    }

    return proj;
}
项目:perfload-loadprofiles    文件:OneTimePanel.java   
/**
 * Create the panel.
 */
public OneTimePanel() {
    setLayout(new MigLayout("insets 0", "[120!,left][200:200:]16[:300:]", "[][75px][][]"));

    JLabel lblOperation = new JLabel("Operation");
    lblOperation.setName("lblOperation");
    add(lblOperation, "cell 0 0");

    cboOperation = new JComboBox();
    cboOperation.setRenderer(new OperationComboRendererDecorator((BasicComboBoxRenderer) cboOperation.getRenderer()));

    lblOperation.setLabelFor(cboOperation);
    add(cboOperation, "cell 1 0,growx");

    JLabel lblImage = new JLabel();
    lblImage.setLayout(new BorderLayout(0, 0));
    lblImage.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    lblImage.setIcon(new ImageIcon(Thread.currentThread().getContextClassLoader()
            .getResource("com/mgmtp/perfload/loadprofiles/ui/onetime.png")));
    add(lblImage, "cell 2 0 1 4, alignx right, grow");

    JLabel lblTarget = new JLabel("Targets");
    lblTarget.setName("lblTarget");
    add(lblTarget, "cell 0 1");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setName("scrollPane");
    add(scrollPane, "cell 1 1,growx");

    {
        tblTarget = new JCheckListTable();
        scrollPane.setViewportView(tblTarget);
    }

    lblTarget.setLabelFor(tblTarget);

    JLabel lblT0 = new JLabel("<html>T<sub>0</sub> (min)");
    add(lblT0, "cell 0 2");

    txtT0 = createTextField();
    lblT0.setLabelFor(txtT0);
    add(txtT0, "cell 1 2, width 50!");
}
项目:perfload-loadprofiles    文件:StairsPanel.java   
/**
 * Create the panel.
 */
public StairsPanel() {
    setLayout(new MigLayout("insets 0", "[120!,left][200:200:]16[:300:]", "[][][][][][][][]"));

    JLabel lblOperation = new JLabel("Operation");
    lblOperation.setName("lblOperation");
    add(lblOperation, "cell 0 0");

    cboOperation = new JComboBox();
    cboOperation.setRenderer(new OperationComboRendererDecorator((BasicComboBoxRenderer) cboOperation.getRenderer()));

    lblOperation.setLabelFor(cboOperation);
    add(cboOperation, "cell 1 0,growx");

    JLabel lblImage = new JLabel();
    lblImage.setLayout(new BorderLayout(0, 0));
    lblImage.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    lblImage.setIcon(new ImageIcon(Thread.currentThread().getContextClassLoader()
            .getResource("com/mgmtp/perfload/loadprofiles/ui/stairs.png")));
    add(lblImage, "cell 2 0 1 8, alignx right, grow");

    JLabel lblT0 = new JLabel("<html>T<sub>0</sub> (min)");
    add(lblT0, "cell 0 1");

    txtT0 = createTextField();
    lblT0.setLabelFor(txtT0);
    add(txtT0, "cell 1 1, width 50!");

    JLabel lblA = new JLabel("a (min)");
    add(lblA, "cell 0 2");

    txtA = createTextField();
    lblA.setLabelFor(txtA);
    add(txtA, "cell 1 2, width 50!");

    JLabel lblB = new JLabel("b (min)");
    add(lblB, "cell 0 3");
    txtB = createTextField();
    lblB.setLabelFor(txtB);
    add(txtB, "cell 1 3, width 50!");

    JLabel lblC = new JLabel("c (min)");
    add(lblC, "cell 0 4");

    txtC = createTextField();
    lblC.setLabelFor(txtC);
    add(txtC, "cell 1 4, width 50!");

    JLabel lblH = new JLabel("h (executions/hour)");
    add(lblH, "cell 0 5");

    txtH = createTextField();
    lblH.setLabelFor(txtH);
    add(txtH, "cell 1 5, width 50!");

    JLabel lblSteps = new JLabel("# of steps");
    add(lblSteps, "cell 0 6");

    txtNumSteps = createTextField();
    lblSteps.setLabelFor(txtNumSteps);
    add(txtNumSteps, "cell 1 6, width 50!");
}
项目:perfload-loadprofiles    文件:OperationComboRendererDecorator.java   
public OperationComboRendererDecorator(final BasicComboBoxRenderer delegate) {
    this.delegate = delegate;
}
项目:fll-sw    文件:ChooseChallengeDescriptor.java   
public DescriptionInfoRenderer() {
  mDelegate = new BasicComboBoxRenderer();
}
项目:IBMDataMovementTool    文件:PlasticComboBoxUI.java   
/**
 * Creates the default renderer that will be used in a non-editiable combo
 * box. A default renderer will used only if a renderer has not been
 * explicitly set with {@code setRenderer}.<p>
 *
 * This method differs from the superclass implementation
 * in that it uses an empty border with wider left and right margins
 * of 2 pixels instead of 1.
 *
 * @return a {@code ListCellRender} used for the combo box
 * @see javax.swing.JComboBox#setRenderer
 */
@Override
protected ListCellRenderer createRenderer() {
    if (tableCellEditor) {
        return super.createRenderer();
    }
    BasicComboBoxRenderer renderer = new BasicComboBoxRenderer.UIResource();
    renderer.setBorder(UIManager.getBorder("ComboBox.rendererBorder"));
    return renderer;
}
项目:IBMDataMovementTool    文件:WindowsComboBoxUI.java   
/**
 * Creates the default renderer that will be used in a non-editiable combo
 * box. A default renderer will used only if a renderer has not been
 * explicitly set with {@code setRenderer}.<p>
 *
 * This method differs from the superclass implementation in that
 * it uses an empty border with the default left and right text insets,
 * the same as used by a combo box editor.
 *
 * @return a {@code ListCellRender} used for the combo box
 * @see javax.swing.JComboBox#setRenderer
 */
@Override
protected ListCellRenderer createRenderer() {
    if (tableCellEditor) {
        return super.createRenderer();
    }
    BasicComboBoxRenderer renderer = new BasicComboBoxRenderer.UIResource();
    renderer.setBorder(UIManager.getBorder("ComboBox.rendererBorder"));
    return renderer;
}
项目:IBMDataMovementTool    文件:WindowsComboBoxUI.java   
/**
 * Checks and answer whether the border of the given renderer component
 * can be removed temporarily, so the combo's selection background will
 * be consistent with the default renderer and native appearance.
 * This test is invoked from {@code #paintCurrentValue}.<p>
 *
 * It is safe to remove an EmptyBorder if the component doesn't override
 * {@code #update}, {@code #paint} and {@code #paintBorder}.
 * Since we know the default renderer, we can remove its border.<p>
 *
 * Custom renderers may set a hint to make their border removable.
 * To do so, set the client property "isBorderRemovable"
 * to {@code Boolean.TRUE}. If this client property is set,
 * its value will be returned. If it is not set, {@code true} is returned
 * if and only if the component's border is an EmptyBorder.
 *
 * @param rendererComponent  the renderer component to check
 * @return true if the component's border can be removed, false if not
 * @see #paintCurrentValue(Graphics, Rectangle, boolean)
 */
protected boolean isRendererBorderRemovable(JComponent rendererComponent) {
    if (rendererComponent instanceof BasicComboBoxRenderer.UIResource) {
        return true;
    }
    Object hint = rendererComponent.getClientProperty(Options.COMBO_RENDERER_IS_BORDER_REMOVABLE);
    if (hint != null) {
        return Boolean.TRUE.equals(hint);
    }
    Border border = rendererComponent.getBorder();
    return border instanceof EmptyBorder;
}