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


Java JComboBox.setMaximumSize方法代码示例

本文整理汇总了Java中javax.swing.JComboBox.setMaximumSize方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.setMaximumSize方法的具体用法?Java JComboBox.setMaximumSize怎么用?Java JComboBox.setMaximumSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JComboBox的用法示例。


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

示例1: addInputCombo

import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
 * Adds an input field to select from a ComboBox
 * @param text text to be shown on a label
 * @param property property to be changed in Defaults
 * @param cont container where input field must be added
 * @param values Map with internal value <-> showed value relations
 */
protected void addInputCombo(String text, final String property, Container cont, final Map<String, String> values) {
	JLabel label = new JLabel(text + ":");
	JComboBox combo = new JComboBox(values.values().toArray());
	combo.setName(property);
	label.setLabelFor(combo);
	combo.setSelectedItem(values.get(Defaults.get(property)));
	// Sets maximum size to minimal one, otherwise springLayout will stretch this
	combo.setMaximumSize(new Dimension(combo.getMaximumSize().width, combo.getMinimumSize().height));
	combo.addItemListener(new ItemListener() {
		public void itemStateChanged(ItemEvent e) {
			// As Map does not allows reverse mapping, scans the entire keyset to
			// find the key corresponding to a given object
			Object[] keys = values.keySet().toArray();
			for (Object key : keys) {
				if (values.get(key) == e.getItem()) {
					Defaults.set(property, (String) key);
				}
			}
		}
	});
	cont.add(label);
	cont.add(combo);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:31,代码来源:DefaultsEditor.java

示例2: addBooleanComboBox

import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
 * Adds a ComboBox to select a boolean property
 * @param text text to be shown on a label
 * @param property property to be changed in Defaults
 * @param cont container where input field must be added
 */
protected void addBooleanComboBox(String text, final String property, Container cont) {
	JLabel label = new JLabel(text + ":");
	JComboBox combo = new JComboBox(new Object[] { Boolean.TRUE.toString(), Boolean.FALSE.toString() });
	combo.setName(property);
	label.setLabelFor(combo);
	combo.setSelectedItem(Defaults.get(property));
	// Sets maximum size to minimal one, otherwise springLayout will stretch this
	combo.setMaximumSize(new Dimension(combo.getMaximumSize().width, combo.getMinimumSize().height));
	combo.addItemListener(new ItemListener() {
		public void itemStateChanged(ItemEvent e) {
			Defaults.set(property, (String) e.getItem());
		}
	});
	cont.add(label);
	cont.add(combo);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:23,代码来源:DefaultsEditor.java

示例3: getControls

import javax.swing.JComboBox; //导入方法依赖的package包/类
public Component getControls() {
  if (panel == null) {
    panel = Box.createHorizontalBox();
    panel.add(new JLabel(name));
    box = new JComboBox(validValues);
    box.setMaximumSize(new Dimension(box.getMaximumSize().width,box.getPreferredSize().height));
    if (isValidValue(getValue())) {
      box.setSelectedItem(getValue());
    }
    else if (validValues.length > 0) {
      box.setSelectedIndex(0);
    }
    box.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        noUpdate = true;
        setValue(box.getSelectedItem());
        noUpdate = false;
      }
    });
    panel.add(box);
  }
  return panel;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:24,代码来源:StringEnumConfigurer.java

示例4: getFilterChooser

import javax.swing.JComboBox; //导入方法依赖的package包/类
private JComboBox<Filter> getFilterChooser() {
    if (this.filterChooser == null) {
        this.filterListening = true;
        final JComboBox<Filter> result = this.filterChooser = new JComboBox<>(Filter.values());
        result.setMaximumSize(new Dimension(result.getPreferredSize().width, 1000));
        result.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                if (LTSDisplay.this.filterListening) {
                    doFilterLTS();
                }
            }
        });
    }
    return this.filterChooser;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:LTSDisplay.java

示例5: createConnectionPanel

import javax.swing.JComboBox; //导入方法依赖的package包/类
Box createConnectionPanel() {
	Box box = Box.createVerticalBox();
	box.setOpaque(false);
	box.setBorder(new EmptyBorder(10, 0, 0, 10));

	Box box2 = Box.createHorizontalBox();
	box2.add(new JLabel(getString("DWN_TYM")));
	box2.add(Box.createHorizontalGlue());
	cmbTimeout = new JComboBox(new String[] { "10", "15", "20", "30", "45",
			"60", "120", "180", "240", "300" });
	cmbTimeout.setMaximumSize(cmbTimeout.getPreferredSize());
	box2.add(cmbTimeout);
	box.add(box2);
	box2.setBorder(new EmptyBorder(2, 0, 2, 0));

	Box box1 = Box.createHorizontalBox();
	box1.add(new JLabel(getString("DWN_SEG")));
	box1.add(Box.createHorizontalGlue());
	cmbConn = new JComboBox(new String[] { "1", "2", "3", "4", "5", "6",
			"7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "20",
			"24", "26", "28", "30", "32" });
	cmbConn.setMaximumSize(cmbTimeout.getPreferredSize());
	cmbConn.setPreferredSize(cmbTimeout.getPreferredSize());
	box1.add(cmbConn);
	box.add(box1);
	box1.setBorder(new EmptyBorder(2, 0, 2, 0));

	Box box3 = Box.createHorizontalBox();
	box3.add(new JLabel(getString("DWN_TCP")));
	box3.add(Box.createHorizontalGlue());
	cmbTcpW = new JComboBox(new String[] { "8", "16", "32", "64" });
	cmbTcpW.setMaximumSize(cmbTimeout.getPreferredSize());
	cmbTcpW.setPreferredSize(cmbTimeout.getPreferredSize());
	box3.add(cmbTcpW);
	box.add(box3);
	box3.setBorder(new EmptyBorder(2, 0, 2, 0));

	box.add(Box.createVerticalGlue());
	return box;
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:41,代码来源:ConfigDialog.java

示例6: createGeneralPanel

import javax.swing.JComboBox; //导入方法依赖的package包/类
Box createGeneralPanel() {
	chkDwnldPrg = new JCheckBox(getString("SHOW_DWNLD_PRG"));
	chkDwnldPrg.setContentAreaFilled(false);
	chkDwnldPrg.setFocusPainted(false);
	chkDwnldNotify = new JCheckBox(getString("SHOW_DWNLD_PRG_NOTIFY"));
	chkDwnldPrg.setContentAreaFilled(false);
	chkDwnldPrg.setFocusPainted(false);
	chkFinishedDlg = new JCheckBox(getString("SHOW_DWNLD_DLG"));
	chkFinishedDlg.setContentAreaFilled(false);
	chkFinishedDlg.setFocusPainted(false);
	chkFinishedNotify = new JCheckBox(getString("SHOW_DWNLD_NOTIFY"));
	chkFinishedNotify.setContentAreaFilled(false);
	chkFinishedNotify.setFocusPainted(false);
	// chkAllowBrowser = new JCheckBox(getString("ALLOW_BROWSER"));
	// chkAllowBrowser.setContentAreaFilled(false);
	// chkAllowBrowser.setFocusPainted(false);
	cmbDupAction = new JComboBox(new String[] {
			StringResource.getString("DUP__OP1"),
			StringResource.getString("DUP__OP2"),
			StringResource.getString("DUP__OP3"),
			StringResource.getString("DUP__OP4") });
	cmbDupAction.setBorder(null);
	cmbDupAction.setMaximumSize(new Dimension(chkDwnldPrg
			.getPreferredSize().width,
			cmbDupAction.getPreferredSize().height));

	Box box = Box.createVerticalBox();
	box.setOpaque(false);
	box.setBorder(new EmptyBorder(10, 0, 0, 10));

	Box b0 = Box.createHorizontalBox();
	b0.add(chkDwnldPrg);
	b0.add(Box.createHorizontalGlue());
	box.add(b0);
	Box b1 = Box.createHorizontalBox();
	b1.add(chkFinishedDlg);
	b1.add(Box.createHorizontalGlue());
	box.add(b1);
	
	Box b31 = Box.createHorizontalBox();
	b31.add(chkDwnldNotify);
	b31.add(Box.createHorizontalGlue());
	box.add(b31);

	Box b3 = Box.createHorizontalBox();
	b3.add(chkFinishedNotify);
	b3.add(Box.createHorizontalGlue());
	box.add(b3);
	// Box b2 = Box.createHorizontalBox();
	// b2.add(chkAllowBrowser);
	// b2.add(Box.createHorizontalGlue());
	// box.add(b2);

	Box b4 = Box.createHorizontalBox();
	b4.add(new JLabel(getString("SHOW_DUP_ACTION")));
	b4.add(Box.createHorizontalGlue());
	b4.add(cmbDupAction);
	box.add(Box.createVerticalStrut(10));
	box.add(b4);

	return box;
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:63,代码来源:ConfigDialog.java

示例7: getComboBox

import javax.swing.JComboBox; //导入方法依赖的package包/类
public JComboBox getComboBox() {
  JComboBox b = new JComboBox(validValues);
  b.setMaximumSize(new Dimension(b.getMaximumSize().width,b.getPreferredSize().height));
  return b;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:6,代码来源:StringEnumConfigurer.java

示例8: createPanel

import javax.swing.JComboBox; //导入方法依赖的package包/类
protected JComponent createPanel(final WizardController controller, String id, final Map settings) {
  final JComboBox setupSelection = new JComboBox(setups.toArray());
  ((DefaultComboBoxModel) setupSelection.getModel()).insertElementAt(description, 0);
  setupSelection.setSelectedIndex(0);
  setupSelection.addActionListener(new ActionListener() {
    @SuppressWarnings("unchecked")
    public void actionPerformed(ActionEvent e) {
      if (setupSelection.getSelectedItem() instanceof PredefinedSetup) {
        PredefinedSetup setup = (PredefinedSetup) setupSelection.getSelectedItem();
        if (setup.isUseFile() && setup.getFileName() != null) {
          loadSetup(setup, controller, settings);
        }
        else {
          final GameSetupPanels panels = GameSetupPanels.newInstance();
          settings.put(POST_PLAY_OFFLINE_WIZARD, panels);
          controller.setProblem(null);
          controller.setForwardNavigationMode(panels == null ? WizardController.MODE_CAN_FINISH : WizardController.MODE_CAN_CONTINUE);
        }
      }
      else {
        controller.setProblem(description);
      }
    }
  });
  setupSelection.setMaximumSize(new Dimension(setupSelection.getMaximumSize().width, setupSelection.getPreferredSize().height));
  setupSelection.setRenderer(new DefaultListCellRenderer() {
    private static final long serialVersionUID = 1L;

    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      JLabel c = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      if (value instanceof PredefinedSetup) {
        PredefinedSetup pds = (PredefinedSetup) value;
        c.setText((pds).getConfigureName());
        if (pds.isMenu()) {
          c.setSize(0, 0);
        }
      }
      else {
        c.setText(value == null ? "" : value.toString());
      }
      return c;
    }
  });
  Box box = Box.createVerticalBox();
  box.add(Box.createVerticalGlue());
  box.add(setupSelection);
  box.add(Box.createVerticalGlue());
  controller.setProblem(description);
  return box;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:51,代码来源:WizardSupport.java


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