javax.swing.JComboBox.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(258)

本文整理了Java中javax.swing.JComboBox.<init>()方法的一些代码示例,展示了JComboBox.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComboBox.<init>()方法的具体详情如下:
包路径:javax.swing.JComboBox
类名称:JComboBox
方法名:<init>

JComboBox.<init>介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

JComboBox box = new JComboBox();
box.addItem("One");
box.addItem("Two");
JFrame frame = new JFrame();
frame.getContentPane().add(box);
frame.pack();
frame.setVisible(true);

代码示例来源:origin: stackoverflow.com

JComboBox combo = new JComboBox(items);
JTextField field1 = new JTextField("1234.56");
JTextField field2 = new JTextField("9876.54");
JPanel panel = new JPanel(new GridLayout(0, 1));
panel.add(combo);
panel.add(new JLabel("Field 1:"));
panel.add(field1);
panel.add(new JLabel("Field 2:"));
panel.add(field2);

代码示例来源:origin: stackoverflow.com

public static void main(String... args) {

  JFrame frame = new JFrame("Test");

  JTable table = new JTable(10, 2);
  JComboBox box = new JComboBox(new String[] {"A", "B", "C"});
  table.setDefaultEditor(Object.class, new DefaultCellEditor(box) {

    @Override
    public Component getTableCellEditorComponent(JTable table,
        Object value, boolean isSelected, int row, int column) {
      return super.getTableCellEditorComponent(
            table, 
            table.getValueAt(Math.max(row-1, 0), column), 
            isSelected, 
            row, 
            column);
    }
  });

  frame.add(table);

  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(400, 300);
  frame.setVisible(true);
}

代码示例来源:origin: stackoverflow.com

private final JComboBox combo1 = new JComboBox(
  new String[]{"Course 1", "Course 2", "Course 3"});
private final JComboBox combo2 = new JComboBox();
private ComboBoxModel[] models = new ComboBoxModel[3];
  this.add(combo1);
  this.add(combo2);
  combo1.addActionListener(this);
  JFrame f = new JFrame("ComboTest");
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.add(this);
  f.pack();
  f.setLocationRelativeTo(null);
  f.setVisible(true);

代码示例来源:origin: skylot/jadx

final JComboBox<Level> cb = new JComboBox<>(LEVEL_ITEMS);
cb.setSelectedItem(level);
cb.addActionListener(e -> {
contentPane.add(controlPane, BorderLayout.PAGE_START);
contentPane.add(scrollPane, BorderLayout.CENTER);
contentPane.add(close, BorderLayout.PAGE_END);

代码示例来源:origin: stackoverflow.com

final JFrame frame = new JFrame("Nested Layout Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  plafNames[ii] = plafInfos[ii].getName();
final JComboBox plafChooser = new JComboBox(plafNames);
plafComponents.add(plafChooser);
plafComponents.add(pack);
      SwingUtilities.updateComponentTreeUI(frame);
      if (pack.isSelected()) {
        frame.pack();
        frame.setMinimumSize(frame.getSize());
gui.add(plafComponents, BorderLayout.NORTH);
frame.pack();
frame.setVisible(true);

代码示例来源:origin: libgdx/libgdx

getContentPane().add(splitPane, BorderLayout.CENTER);
        influencerBox = new JComboBox(new DefaultComboBoxModel());
        JButton addInfluencerButton = new JButton("Add");
        addInfluencerButton.addActionListener(new ActionListener() {

代码示例来源:origin: stackoverflow.com

menuBar.add(createMenu("Menu 2"));
menuBar.add(createMenu("Menu 3"));
menuBar.add(new JSeparator());
menuBar.add(new JButton("   Seach ....  "));
menuBar.add(new JTextField("   Seach ....  "));
menuBar.add(new JComboBox(new Object[]{"height", "length", "volume"}));
menuBar.add(Box.createHorizontalGlue());
menuBar.add(createMenu("About"));
JFrame frame = new JFrame("MenuGlueDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(menuBar);
frame.pack();
frame.setVisible(true);

代码示例来源:origin: libgdx/libgdx

getContentPane().add(splitPane, BorderLayout.CENTER);
        influencerBox = new JComboBox(new DefaultComboBoxModel());
        JButton addInfluencerButton = new JButton("Add");
        addInfluencerButton.addActionListener(new ActionListener() {

代码示例来源:origin: stackoverflow.com

final JFrame frame = new JFrame("Text HIGHLIGHT");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
contentPane.add(scrollPane);
frame.add(remHighButton, BorderLayout.PAGE_START);
frame.add(contentPane, BorderLayout.CENTER);
frame.add(button, BorderLayout.PAGE_END);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
cbox = new JComboBox(colourNames);
panel.add(colourLabel);

代码示例来源:origin: libgdx/libgdx

JPanel leftSidePanel = new JPanel();
leftSidePanel.setLayout(new GridBagLayout());
getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
  GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
      glyphPageWidthCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64),
        new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048)}));
      glyphCachePanel.add(glyphPageWidthCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
      glyphPageHeightCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64),
        new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048)}));
      glyphCachePanel.add(glyphPageHeightCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
      glyphPageCombo = new JComboBox();
      glyphCachePanel.add(glyphPageCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
        GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER,
  GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

代码示例来源:origin: stackoverflow.com

JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
  JPanel bottomPanel = CreateBottomPanel();
  frame = new JFrame("Comp Table Test");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(CompTableScrollpane, BorderLayout.CENTER);
  frame.add(bottomPanel, BorderLayout.SOUTH);
  frame.setPreferredSize(new Dimension(800, 400));
  frame.setLocation(150, 150);
  frame.pack();
  frame.setVisible(true);
  panel.add(addButton);
  return panel;
private JComboBox typeCombo = new JComboBox(new Object[]{"height", "length", "volume"});
private JComboBox relationCombo = new JComboBox(new Object[]{"above", "below", "between"});
private JTextField lowerField = new JTextField();
private JLabel labelAnd = new JLabel(" and ");

代码示例来源:origin: libgdx/libgdx

JPanel leftSidePanel = new JPanel();
leftSidePanel.setLayout(new GridBagLayout());
getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
  GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
      glyphPageWidthCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64),
        new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048)}));
      glyphCachePanel.add(glyphPageWidthCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
      glyphPageHeightCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] {new Integer(32), new Integer(64),
        new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048)}));
      glyphCachePanel.add(glyphPageHeightCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
      glyphPageCombo = new JComboBox();
      glyphCachePanel.add(glyphPageCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
        GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER,
  GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

代码示例来源:origin: stackoverflow.com

JFrame f = new JFrame(title);
f.setTitle(title);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setLayout(new BorderLayout(0, 5));
f.add(chartPanel, BorderLayout.CENTER);
chartPanel.setMouseWheelEnabled(true);
chartPanel.setHorizontalAxisTrace(true);
panel.add(createTrace());
panel.add(createDate());
panel.add(createZoom());
f.add(panel, BorderLayout.SOUTH);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
final JComboBox trace = new JComboBox();
final String[] traceCmds = {"Enable Trace", "Disable Trace"};
trace.setModel(new DefaultComboBoxModel(traceCmds));
final JComboBox date = new JComboBox();
final String[] dateCmds = {"Horizontal Dates", "Vertical Dates"};
date.setModel(new DefaultComboBoxModel(dateCmds));

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

colorDepthCombo = new JComboBox();
colorDepthCombo.addKeyListener(aListener);
displayFreqCombo = new JComboBox();
displayFreqCombo.addKeyListener(aListener);
antialiasCombo = new JComboBox();
antialiasCombo.addKeyListener(aListener);
fullscreenBox = new JCheckBox(resourceBundle.getString("checkbox.fullscreen"));
this.getContentPane().add(mainPanel);

代码示例来源:origin: stackoverflow.com

bnb.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
bnb.createUI();
bnb.setVisible(true);
borderPanel.add(northLabel, BorderLayout.NORTH);
JComboBox southCombo = new JComboBox(southComboChoices);
borderPanel.add(southCombo, BorderLayout.SOUTH);
String[] secondChoices = { "second", "dos", "zwei" };
String[] thirdChoices = { "third", "tres", "drei" };
JComboBox firstCombo = new JComboBox(firstChoices);
JComboBox secondCombo = new JComboBox(secondChoices);
JComboBox thirdCombo = new JComboBox(thirdChoices);
centerPanel.add(firstCombo);
centerPanel.add(secondCombo);
centerPanel.add(thirdCombo);
getContentPane().add(borderPanel);
pack();

代码示例来源:origin: RipMeApp/ripme

configUrlFileChooserButton = new JButton(rb.getString("download.url.list"));
configLogLevelCombobox = new JComboBox<>(new String[] {"Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug"});
configSelectLangComboBox = new JComboBox<>(supportedLanges);
configSelectLangComboBox.setSelectedItem(rb.getLocale().toString());
configLogLevelCombobox.setSelectedItem(Utils.getConfigString("log.level", "Log level: Debug"));
gbc.gridy = 0; pane.add(ripPanel, gbc);
gbc.gridy = 1; pane.add(statusPanel, gbc);
gbc.gridy = 2; pane.add(progressPanel, gbc);
gbc.gridy = 3; pane.add(optionsPanel, gbc);
gbc.weighty = 1;

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame("Combo Example");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
cBox = new JComboBox(data);
cBox.addActionListener(comboActions);
contentPane.add(imageLabel);
contentPane.add(cBox);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);

代码示例来源:origin: stackoverflow.com

final JComboBox combo = new JComboBox();
combo.addItem("Fast");
combo.addItem("Slow");
btnPanel.add(run);
btnPanel.add(combo);
this.add(btnPanel, BorderLayout.SOUTH);

代码示例来源:origin: stackoverflow.com

JFrame f = new JFrame();
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.setResizable(false);
  f.add(new ObserverPanel());
  f.pack();
  f.setLocationByPlatform(true);
  f.setVisible(true);
  this.setBorder(BorderFactory.createTitledBorder("ObserverPanel"));
  JPanel panel = new JPanel(new GridLayout(0, 1));
  panel.add(title);
  panel.add(label);
  this.add(panel);
  ObservedPanel observed = new ObservedPanel();
  "Alpher", "Bethe", "Gamow", "Dirac", "Einstein"
};
private JComboBox combo = new JComboBox(items);
private String oldValue;

相关文章

JComboBox类方法