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

下面列出了怎么用javax.swing.plaf.basic.BasicComboBoxRenderer的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: 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;
}
 
源代码2 项目: visualvm   文件: 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;
}
 
源代码3 项目: 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;
    }
  };
}
 
源代码4 项目: 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;
    }
  };
}
 
源代码5 项目: FlatLaf   文件: LookAndFeelsComboBox.java
@SuppressWarnings( "unchecked" )
public LookAndFeelsComboBox() {
	setRenderer( new BasicComboBoxRenderer() {
		@Override
		@SuppressWarnings( "rawtypes" )
		public Component getListCellRendererComponent( JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus )
		{
			value = (value != null)
				? ((LookAndFeelInfo)value).getName()
				: UIManager.getLookAndFeel().getName();
			return super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
		}
	} );
}
 
源代码6 项目: dragonwell8_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);
        }
    });
}
 
源代码7 项目: TencentKona-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);
        }
    });
}
 
源代码8 项目: jdk8u60   文件: 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);
        }
    });
}
 
源代码9 项目: openjdk-jdk8u   文件: 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);
        }
    });
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: 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);
        }
    });
}
 
源代码11 项目: openjdk-jdk9   文件: 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);
        }
    });
}
 
源代码12 项目: NBANDROID-V2   文件: CreateAvdVisualPanel3.java
void readSettings() {
    defaultSdk = (AndroidSdk) wiz.getProperty(ANDROID_SDK);
    avdManager = (AvdManager) wiz.getProperty(AVD_MANAGER);
    selectedDevice = (Device) wiz.getProperty(DEVICE_SELECTED);
    selectedImage = (SystemImageDescription) wiz.getProperty(SYSTEM_IMAGE);
    initAvdName();
    updateAvdId();
    defaultSkinPath = defaultSdk.getSdkPath() + File.separator + "skins";
    File skinFile = selectedDevice.getDefaultHardware().getSkinFile();
    String skinPath = defaultSdk.getSdkPath() + File.separator + "skins" + File.separator + skinFile;
    skinCombo.setModel(new SkinsComboboxModel(new File(defaultSkinPath)));
    skinCombo.setSelectedItem(new File(skinPath));
    skinCombo.setRenderer(new BasicComboBoxRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
            if ((component instanceof JLabel) && (value instanceof File)) {
                ((JLabel) component).setText(((File) value).getName());
            }
            return component;
        }

    });
    performanceGraphics.setSelectedItem(GpuMode.AUTO);
    avdName.getDocument().addDocumentListener(this);
    performanceCores.setModel(new javax.swing.SpinnerNumberModel(RECOMMENDED_NUMBER_OF_CORES, 1, MAX_NUMBER_OF_CORES, 1));
    //   initPlaystore();
    initMemory();
}
 
源代码13 项目: 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);
        }
    });
}
 
源代码14 项目: hottub   文件: 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);
        }
    });
}
 
源代码15 项目: openjdk-8-source   文件: 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);
        }
    });
}
 
源代码16 项目: openjdk-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);
        }
    });
}
 
源代码17 项目: 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);
        }
    });
}
 
源代码18 项目: 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);
        }
    });
}
 
源代码19 项目: 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);
        }
    });
}
 
@Test
public void shouldDisplayNoSelected() {
    window.label(new GenericTypeMatcher<BasicComboBoxRenderer>(BasicComboBoxRenderer.class) {
        @Override
        protected boolean isMatching(BasicComboBoxRenderer component) {
            return true;
        }
    }).requireText(NO_DATA_SOURCE);
}
 
源代码21 项目: 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));
}
 
源代码22 项目: NBANDROID-V2   文件: AvdHwProfile.java
/**
 * Creates new form AvdHwProfile
 */
public AvdHwProfile(Device device, DeviceManager deviceManager,boolean edit) {
    this.deviceManager = deviceManager;
    this.edit=edit;
    initComponents();
    deviceType.setModel(new DefaultComboBoxModel<>(DeviceType.values()));
    if (device != null) {
         String tagId = device.getTagId();
        initBootProperties(device);
        if (tagId == null) {
            deviceType.setSelectedItem(DeviceType.MOBILE);
        } else if (DeviceType.TV.id.equals(tagId)) {
            deviceType.setSelectedItem(DeviceType.TV);
        } else if (DeviceType.WEAR.id.equals(tagId)) {
            deviceType.setSelectedItem(DeviceType.WEAR);
        }
        if (edit) {
            deviceName.setText(device.getDisplayName());
            deviceName.setEditable(false);
        }else{
            deviceName.setText(String.format("%s (Edited)", device.getDisplayName()));
        }
        if (CreateAvdVisualPanel1.isTv(device)) {
            deviceType.setSelectedItem(DeviceType.TV);
        } else if (HardwareConfigHelper.isWear(device)) {
            deviceType.setSelectedItem(DeviceType.WEAR);
        } else {
            deviceType.setSelectedItem(DeviceType.MOBILE);
        }
        screenSize.setValue(device.getDefaultHardware().getScreen().getDiagonalLength());
        Dimension dimension = device.getScreenSize(device.getDefaultState().getOrientation());
        resolutionX.setValue(dimension.width);
        resolutionY.setValue(dimension.height);
        round.setSelected(device.isScreenRound());
        ram.setValue(device.getDefaultHardware().getRam().getSizeAsUnit(Storage.Unit.MiB));
        hwButt.setSelected(device.getDefaultHardware().getButtonType() == ButtonType.HARD);
        hwKeyb.setSelected(device.getDefaultHardware().getKeyboard() != Keyboard.NOKEY);
        List<State> states = device.getAllStates();
        portrait.setSelected(false);
        landscape.setSelected(false);
        for (State state : states) {
            if (state.getOrientation().equals(ScreenOrientation.PORTRAIT)) {
                portrait.setSelected(true);
            }
            if (state.getOrientation().equals(ScreenOrientation.LANDSCAPE)) {
                landscape.setSelected(true);
            }
        }
        Navigation nav = device.getDefaultHardware().getNav();
        switch (nav) {
            case NONAV:
                navigationStyle.setSelectedIndex(0);
                break;
            case DPAD:
                navigationStyle.setSelectedIndex(1);
                break;
            case TRACKBALL:
                navigationStyle.setSelectedIndex(2);
                break;
            case WHEEL:
                navigationStyle.setSelectedIndex(3);
                break;
        }
        cameraFront.setSelected(device.getDefaultHardware().getCamera(CameraLocation.FRONT) != null);
        cameraBack.setSelected(device.getDefaultHardware().getCamera(CameraLocation.BACK) != null);
        accelerometer.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.ACCELEROMETER));
        gyroscope.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GYROSCOPE));
        gps.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GPS));
        proximity.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.PROXIMITY_SENSOR));
        File skinFile = device.getDefaultHardware().getSkinFile();
        AndroidSdk defaultSdk = AndroidSdkProvider.getDefaultSdk();
        if (defaultSdk != null) {
            String skinPath = defaultSdk.getSdkPath() + File.separator + "skins";
            skin.setModel(new SkinsComboboxModel(new File(skinPath)));
        }
        skin.setSelectedItem(skinFile);
        playstore.setSelected(device.hasPlayStore());
    } else {
        deviceType.setSelectedItem(DeviceType.MOBILE);
        navigationStyle.setSelectedIndex(0);
        deviceName.setText(getUniqueId(null));
    }
    skin.setRenderer(new BasicComboBoxRenderer() {
        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
            if ((component instanceof JLabel) && (value instanceof File)) {
                ((JLabel) component).setText(((File) value).getName());
            }
            return component;
        }

    });
}
 
 类所在包
 同包方法