当前位置: 首页>>代码示例>>Java>>正文


Java BasicComboBoxRenderer类代码示例

本文整理汇总了Java中javax.swing.plaf.basic.BasicComboBoxRenderer的典型用法代码示例。如果您正苦于以下问题:Java BasicComboBoxRenderer类的具体用法?Java BasicComboBoxRenderer怎么用?Java BasicComboBoxRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BasicComboBoxRenderer类属于javax.swing.plaf.basic包,在下文中一共展示了BasicComboBoxRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPreferredSize

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:GenericToolbar.java

示例2: createObjectRenderer

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
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;
		}

	};
}
 
开发者ID:ntenhoeve,项目名称:Introspect-Framework,代码行数:25,代码来源:ComboBox.java

示例3: createEnumRenderer

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
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;
		}

	};
}
 
开发者ID:ntenhoeve,项目名称:Introspect-Framework,代码行数:20,代码来源:ComboBox.java

示例4: testGetMinimumSize

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
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));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:MetalComboBoxUITest.java

示例5: createRenderer

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
@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;
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:DarculaComboBoxUI.java

示例6: PartialDisableComboBox

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
@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;
    }
  });
}
 
开发者ID:phdelodder,项目名称:SubTools,代码行数:23,代码来源:PartialDisableComboBox.java

示例7: createRenderer

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
@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;
    }
  };
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:ModernComboBoxUI.java

示例8: main

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:Test7195179.java

示例9: ComboBoxTableCellEditor

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ComboBoxTableCellEditor.java

示例10: createRenderer

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
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:    */   }
 
开发者ID:xiwc,项目名称:confluence.keygen,代码行数:10,代码来源:PlasticComboBoxUI.java

示例11: ComboBoxTableCellEditor

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
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));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:ComboBoxTableCellEditor.java

示例12: shouldDisplayNoSelected

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
@Test
public void shouldDisplayNoSelected() {
    window.label(new GenericTypeMatcher<BasicComboBoxRenderer>(BasicComboBoxRenderer.class) {
        @Override
        protected boolean isMatching(BasicComboBoxRenderer component) {
            return true;
        }
    }).requireText(NO_DATA_SOURCE);
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:10,代码来源:DataSourceSelectorGuiTest.java

示例13: createRenderer

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
protected ListCellRenderer createRenderer()
{
	return new BasicComboBoxRenderer();
}
 
开发者ID:andy-goryachev,项目名称:PasswordSafe,代码行数:5,代码来源:AgComboBoxUI.java

示例14: askUserForProjection

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
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;
}
 
开发者ID:OSUCartography,项目名称:FlexProjector,代码行数:44,代码来源:FlexProjectorWindow.java

示例15: OneTimePanel

import javax.swing.plaf.basic.BasicComboBoxRenderer; //导入依赖的package包/类
/**
 * 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!");
}
 
开发者ID:mgm-tp,项目名称:perfload-loadprofiles,代码行数:46,代码来源:OneTimePanel.java


注:本文中的javax.swing.plaf.basic.BasicComboBoxRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。