本文整理汇总了Java中javax.swing.JComboBox.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.setPreferredSize方法的具体用法?Java JComboBox.setPreferredSize怎么用?Java JComboBox.setPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.setPreferredSize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareControls
import javax.swing.JComboBox; //导入方法依赖的package包/类
protected void prepareControls() {
frame = new JFrame("Mixing : Dropdown Overlapping test");
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS));
frame.setSize(200, 200);
frame.setVisible(true);
cb = new JComboBox(petStrings);
cb.setPreferredSize(new Dimension(frame.getContentPane().getWidth(), 20));
cb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == cb) {
lwClicked = true;
}
}
});
frame.add(cb);
propagateAWTControls(frame);
frame.setVisible(true);
}
示例2: setComboBox
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setComboBox()
{
percorso = new JComboBox(progetto.percorsoArray());
percorso.setPreferredSize(new Dimension(200, 30));
ComboBoxListener cbl = new ComboBoxListener(progetto, this, percorso);
percorso.addActionListener(cbl);
}
示例3: 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;
}
示例4: initComponents
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void initComponents() {
setLayout(new BorderLayout(4, 0));
setBorder(new EmptyBorder(0, 2, 0, 8));
setOpaque(false);
setFocusTraversalPolicyProvider(true);
setFocusTraversalPolicy(new DefaultFocusTraversalPolicy() {
@Override
public Component getDefaultComponent(Container aContainer) {
if (!SwingUtilities.isEventDispatchThread()) {
return null;
}
final EditorCookie ec = actionContext.lookup(
EditorCookie.class);
if (ec != null) {
JEditorPane[] panes = ec.getOpenedPanes();
if (panes != null) {
for (JEditorPane pane : panes) {
if (pane.isShowing()) {
return pane;
}
}
}
}
return null;
}
});
combo = new JComboBox();
combo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
DatabaseConnection dbconn = (DatabaseConnection)combo.getSelectedItem();
combo.setToolTipText(dbconn != null ? dbconn.getDisplayName() : null);
}
});
combo.setOpaque(false);
combo.setModel(new DefaultComboBoxModel(
new String[] { NbBundle.getMessage(ToolbarPresenter.class, "ConnectionAction.ToolbarPresenter.LoadingConnections") }));
combo.setRenderer(new DatabaseConnectionRenderer());
String accessibleName = NbBundle.getMessage(ConnectionAction.class, "LBL_DatabaseConnection");
combo.getAccessibleContext().setAccessibleName(accessibleName);
combo.getAccessibleContext().setAccessibleDescription(accessibleName);
combo.setPreferredSize (new Dimension (400, combo.getPreferredSize ().height));
add(combo, BorderLayout.CENTER);
comboLabel = new JLabel();
Mnemonics.setLocalizedText(comboLabel, NbBundle.getMessage(ConnectionAction.class, "LBL_ConnectionAction"));
comboLabel.setOpaque(false);
comboLabel.setLabelFor(combo);
add(comboLabel, BorderLayout.WEST);
}
示例5: initGui
import javax.swing.JComboBox; //导入方法依赖的package包/类
public void initGui() {
enabler = new JCheckBox("Enable What-If analysis");
enabler.setToolTipText("Enable or disable What-If analysis");
enablerPanel = new JPanel(new BorderLayout());
enablerPanel.add(enabler, BorderLayout.WEST);
upperPanel = new JPanel(new BorderLayout());
chooserPanel = new JPanel();
tb = new TitledBorder("Parameter selection for the control of repeated executions");
chooserPanel.setBorder(tb);
chooser = new JComboBox(parameters);
chooser.setPreferredSize(DIM_BUTTON_L);
chooser.setToolTipText("Choose the what-if analysis to be performed");
chooserPanel.add(chooser, BorderLayout.NORTH);
JLabel description = new JLabel(PARAMETRIC_ANALYSIS_DESCRIPTION);
JLabel Warning = new JLabel (HTML_START + HTML_FONT_TITLE + "WARNING: "+ HTML_FONT_TIT_END + HTML_FONT_NORM
+ "Enabling What-If analysis will disable all statistical outputs." + HTML_FONT_NOR_END + HTML_END);
JPanel northPanel = new JPanel(new BorderLayout());
northPanel.setBorder(new EmptyBorder(0, 0, 15, 0));
northPanel.add(description, "Center");
northPanel.add(Warning, "South");
northPanel.add(enablerPanel, "East");
upperPanel.add(northPanel, BorderLayout.NORTH);
upperPanel.add(chooserPanel, BorderLayout.SOUTH);
this.setLayout(new BorderLayout());
this.setBorder(new EmptyBorder(20, 20, 20, 20));
chooser.removeAllItems();
ParametricAnalysisChecker pac = new ParametricAnalysisChecker(cd, sd, simd);
if (!pac.canBeEnabled()) {
enabler.setEnabled(false);
parameterOptionPanel = createPanel(null);
simd.setParametricAnalysisModel(null);
simd.setParametricAnalysisEnabled(false);
} else {
enabler.setEnabled(true);
enabler.setSelected(simd.isParametricAnalysisEnabled());
ParametricAnalysisDefinition pad = simd.getParametricAnalysisModel();
parameters = pac.getRunnableParametricAnalysis();
for (String parameter : parameters) {
chooser.addItem(parameter);
}
String temp = parameters[0];
if (pad == null) {
pad = ParametricAnalysisModelFactory.createParametricAnalysisModel(temp, cd, sd, simd);
simd.setParametricAnalysisModel(pad);
} else {
int code = pad.checkCorrectness(true); //check correctness of the PAD and if it is possible corrects it
if (code != 2) {
chooser.setSelectedItem(pad.getType());
} else { //the old type of parametric analysis is no more available
pad = ParametricAnalysisModelFactory.createParametricAnalysisModel(temp, cd, sd, simd);
simd.setParametricAnalysisModel(pad);
}
}
parameterOptionPanel = createPanel(pad);
}
parameterOptionPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
this.add(upperPanel, BorderLayout.NORTH);
this.add(parameterOptionPanel, BorderLayout.CENTER);
this.setEnabled(enabler.isSelected());
}
示例6: PartPanel
import javax.swing.JComboBox; //导入方法依赖的package包/类
private PartPanel(final PartObj part)
{
this.part = part;
setLayout(new GridBagLayout());
setBorder(BorderFactory.createLineBorder(Color.black));
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(0,3,0,3);
c.anchor = GridBagConstraints.CENTER;
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
add(new JLabel(part.getDisplayName()),c);
c.gridx = 1;
c.weightx = 0;
c.anchor = GridBagConstraints.EAST;
JTextField textField = new JTextField(part.getDisplayName());
textField.getDocument().addDocumentListener(new DisplayNameDocumentListener(part, textField));
textField.setPreferredSize(new Dimension(200,22));
add(textField, c);
c.gridx = 2;
c.weightx = 0;
box = new JComboBox();
box.setPreferredSize(new Dimension(200,20));
box.addActionListener(new GroupDropDownActionListener(part));
box.setSelectedItem(controller.getPartGroups().getPartGroup(part));
add(box, c);
c.weightx = 0;
c.gridx = 3;
DragPanel dp = new DragPanel(this);
c.anchor = GridBagConstraints.EAST;
add(dp, c);
//Mouse listener to highlight part when panel entered.
addMouseListener(new BlankMouseListener()
{
@Override
public void mouseEntered(MouseEvent e)
{
controller.setSelectedPart(part);
}
});
}
示例7: XiaoShouPaiHang
import javax.swing.JComboBox; //导入方法依赖的package包/类
public XiaoShouPaiHang() {
setIconifiable(true);
setClosable(true);
setTitle("��������");
getContentPane().setLayout(new GridBagLayout());
setBounds(100, 100, 650, 375);
final JLabel label_1 = new JLabel();
label_1.setText("��");
final GridBagConstraints gridBagConstraints_8 = new GridBagConstraints();
gridBagConstraints_8.anchor = GridBagConstraints.EAST;
gridBagConstraints_8.gridy = 0;
gridBagConstraints_8.gridx = 0;
getContentPane().add(label_1, gridBagConstraints_8);
year = new JComboBox();
for (int i = 1981, j = 0; i <= date.get(Calendar.YEAR) + 1; i++, j++) {
year.addItem(i);
if (i == date.get(Calendar.YEAR))
year.setSelectedIndex(j);
}
year.setPreferredSize(new Dimension(100, 21));
setupComponet(year, 1, 0, 1, 90, true);
setupComponet(new JLabel("��"), 2, 0, 1, 1, false);
month = new JComboBox();
for (int i = 1; i <= 12; i++) {
month.addItem(String.format("%02d", i));
if (date.get(Calendar.MONTH) == i)
month.setSelectedIndex(i - 1);
}
month.setPreferredSize(new Dimension(100, 21));
setupComponet(month, 3, 0, 1, 30, true);
setupComponet(new JLabel(" �·ݵ�������Ϣ����"), 4, 0, 1, 1, false);
condition = new JComboBox();
condition.setModel(new DefaultComboBoxModel(new String[]{"���", "����"}));
setupComponet(condition, 5, 0, 1, 30, true);
setupComponet(new JLabel(" ����"), 6, 0, 1, 1, false);
operation = new JComboBox();
operation.setModel(new DefaultComboBoxModel(
new String[]{"��������", "��������"}));
setupComponet(operation, 7, 0, 1, 30, true);
okButton = new JButton();
okButton.addActionListener(new OkAction());
setupComponet(okButton, 8, 0, 1, 1, false);
okButton.setText("ȷ��");
final JScrollPane scrollPane = new JScrollPane();
final GridBagConstraints gridBagConstraints_6 = new GridBagConstraints();
gridBagConstraints_6.weighty = 1.0;
gridBagConstraints_6.anchor = GridBagConstraints.NORTH;
gridBagConstraints_6.insets = new Insets(0, 10, 5, 10);
gridBagConstraints_6.fill = GridBagConstraints.BOTH;
gridBagConstraints_6.gridwidth = 9;
gridBagConstraints_6.gridy = 1;
gridBagConstraints_6.gridx = 0;
getContentPane().add(scrollPane, gridBagConstraints_6);
table = new JTable();
table.setEnabled(false);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
dftm = (DefaultTableModel) table.getModel();
String[] tableHeads = new String[]{"��Ʒ���", "��Ʒ����", "���۽��", "��������",
"���", "����", "��λ", "���", "��װ", "����", "���ĺ�","���","��Ӧ��"};
dftm.setColumnIdentifiers(tableHeads);
scrollPane.setViewportView(table);
}
示例8: initGui
import javax.swing.JComboBox; //导入方法依赖的package包/类
public void initGui() {
enabler = new JCheckBox("Enable what-if analysis");
enabler.setToolTipText("Enable or disable what-if analysis");
enablerPanel = new JPanel(new BorderLayout());
enablerPanel.add(enabler, BorderLayout.WEST);
//enablerPanel.setBorder(new EmptyBorder(30,10,10,10));
upperPanel = new JPanel(new BorderLayout());
chooserPanel = new JPanel();
tb = new TitledBorder("Parameter selection for the control of repeated executions");
chooserPanel.setBorder(tb);
chooser = new JComboBox(parameters);
chooser.setPreferredSize(DIM_BUTTON_L);
chooser.setToolTipText("Choose the what-if analysis to be performed");
chooserPanel.add(chooser, BorderLayout.NORTH);
JLabel description = new JLabel(PARAMETRIC_ANALYSIS_DESCRIPTION);
JPanel northPanel = new JPanel(new BorderLayout());
northPanel.setBorder(new EmptyBorder(0, 0, 15, 0));
northPanel.add(description, "Center");
northPanel.add(enablerPanel, "East");
upperPanel.add(northPanel, BorderLayout.NORTH);
upperPanel.add(chooserPanel, BorderLayout.SOUTH);
this.setLayout(new BorderLayout());
this.setBorder(new EmptyBorder(20, 20, 20, 20));
chooser.removeAllItems();
ParametricAnalysisChecker pac = new ParametricAnalysisChecker(cd, sd, simd);
if (!pac.canBeEnabled()) {
enabler.setEnabled(false);
parameterOptionPanel = createPanel(null);
simd.setParametricAnalysisModel(null);
simd.setParametricAnalysisEnabled(false);
} else {
enabler.setEnabled(true);
enabler.setSelected(simd.isParametricAnalysisEnabled());
ParametricAnalysisDefinition pad = simd.getParametricAnalysisModel();
parameters = pac.getRunnableParametricAnalysis();
for (String parameter : parameters) {
chooser.addItem(parameter);
}
String temp = parameters[0];
if (pad == null) {
pad = ParametricAnalysisModelFactory.createParametricAnalysisModel(temp, cd, sd, simd);
simd.setParametricAnalysisModel(pad);
} else {
int code = pad.checkCorrectness(true); //check correctness of the PAD and if it is possible corrects it
if (code != 2) {
chooser.setSelectedItem(pad.getType());
} else { //the old type of parametric analysis is no more avaible
pad = ParametricAnalysisModelFactory.createParametricAnalysisModel(temp, cd, sd, simd);
simd.setParametricAnalysisModel(pad);
}
}
parameterOptionPanel = createPanel(pad);
}
parameterOptionPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
this.add(upperPanel, BorderLayout.NORTH);
this.add(parameterOptionPanel, BorderLayout.CENTER);
this.setEnabled(enabler.isSelected());
}
示例9: setupGUI
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setupGUI()
{
JLabel identifierLabel = new JLabel(getString("detailstab.identifier")); //$NON-NLS-1$
JLabel nameLabel = new JLabel(getString("reports.detailstab.name")); //$NON-NLS-1$
JLabel descriptionLabel = new JLabel(getString("detailstab.desc")); //$NON-NLS-1$
JLabel ownerLabel = new JLabel(getString("reports.detailstab.owner")); //$NON-NLS-1$
JLabel uploadLabel = new JLabel(getString("detailstab.design")); //$NON-NLS-1$
JLabel hideReportLabel = new JLabel(getString("detailstab.hidereport")); //$NON-NLS-1$
descriptionLabel.setVerticalAlignment(SwingConstants.TOP);
identifier = new JTextField();
identifier.setEditable(false);
name = new I18nTextField(BundleCache.getLanguages());
description = new I18nTextArea(BundleCache.getLanguages());
owner = new SingleUserSelector(clientService.getService(RemoteUserService.class));
hideReport = new JCheckBox();
final int height1 = owner.getPreferredSize().height;
final int width1 = hideReportLabel.getPreferredSize().width;
final int[] rows = {height1, height1, height1 * 3, height1, height1, height1, TableLayout.FILL,};
final int[] cols = {width1, TableLayout.DOUBLE_FILL, TableLayout.FILL,};
setLayout(new TableLayout(rows, cols));
add(identifierLabel, new Rectangle(0, 0, 1, 1));
add(identifier, new Rectangle(1, 0, 1, 1));
add(nameLabel, new Rectangle(0, 1, 1, 1));
add(name, new Rectangle(1, 1, 1, 1));
add(descriptionLabel, new Rectangle(0, 2, 1, 1));
add(description, new Rectangle(1, 2, 1, 1));
add(ownerLabel, new Rectangle(0, 3, 1, 1));
add(owner, new Rectangle(1, 3, 1, 1));
// Make sure things are readonly.
if( state.isReadonly() )
{
name.setEnabled(false);
description.setEnabled(false);
owner.setEnabled(false);
}
initialReport = new JComboBox();
initialReport.setEditable(false);
initialReport.setPreferredSize(new Dimension(230, 23));
upload = new JButton(getString("detailstab.upload")); //$NON-NLS-1$
upload.addActionListener(this);
download = new JButton(getString("detailstab.download")); //$NON-NLS-1$
download.addActionListener(this);
add(uploadLabel, new Rectangle(0, 4, 1, 1));
// Stupid java layout!!!
JPanel panelsomething = new JPanel();
panelsomething.setLayout(new BorderLayout(0, 0));
panelsomething.add(upload, BorderLayout.WEST);
panelsomething.add(download, BorderLayout.EAST);
JPanel panelsomething2 = new JPanel();
panelsomething2.setLayout(new BorderLayout(5, 10));
panelsomething2.add(initialReport, BorderLayout.CENTER);
panelsomething2.add(panelsomething, BorderLayout.EAST);
panelsomething2.add(initialReport, BorderLayout.CENTER);
panelsomething2.add(panelsomething, BorderLayout.EAST);
add(panelsomething2, new Rectangle(1, 4, 1, 1));
add(hideReportLabel, new Rectangle(0, 5, 1, 1));
add(hideReport, new Rectangle(1, 5, 1, 1));
}
示例10: ToadDataPanel
import javax.swing.JComboBox; //导入方法依赖的package包/类
public ToadDataPanel(DisplayMode displayMode)
{
super(displayMode);
comboBoxPopulation = new JComboBox();
for (Object item : Locale.dropDownPopulations)
comboBoxPopulation.addItem(item);
comboBoxPopulation.setPreferredSize(new Dimension(iw, lh));
textFieldSize1 = new JTextField(""); textFieldSize1.setPreferredSize(new Dimension(iw, 30)); textFieldSize1.setBorder(BorderFactory.createLineBorder(Color.BLACK));
textFieldSize2 = new JTextField(""); textFieldSize2.setPreferredSize(new Dimension(iw, 30)); textFieldSize2.setBorder(BorderFactory.createLineBorder(Color.BLACK));
textFieldWeight = new JTextField(""); textFieldWeight.setPreferredSize(new Dimension(iw, 30)); textFieldWeight.setBorder(BorderFactory.createLineBorder(Color.BLACK));
textFieldTotal = new JTextField(""); textFieldTotal.setPreferredSize(new Dimension(iw, 30)); textFieldTotal.setBorder(BorderFactory.createLineBorder(Color.BLACK));
textFieldTotal.setEditable(false);
labelPopulation = GUISettings.getDefaultLabel(Locale.labelPopulation, lw, lh, a, va);
labelSize1 = GUISettings.getDefaultLabel(Locale.labelSize1, lw, lh, a, va);
labelSize2 = GUISettings.getDefaultLabel(Locale.labelSize2, lw, lh, a, va);
labelSizeTotal = GUISettings.getDefaultLabel(Locale.labelSizeTotal, lw, lh, a, va);
labelWeight = GUISettings.getDefaultLabel(Locale.labelWeight, lw, lh, a, va);
JPanel panelSize1 = new JPanel(new FlowLayout(orientation));
JPanel panelSize2 = new JPanel(new FlowLayout(orientation));
JPanel panelSizeTotal = new JPanel(new FlowLayout(orientation));
JPanel panelWeight = new JPanel(new FlowLayout(orientation));
JPanel panelPopulation = new JPanel(new FlowLayout(orientation));
if (currentDisplayMode.equals(DisplayMode.vertical_align_left))
{
panelSize1.add(textFieldSize1);
panelSize1.add(labelSize1);
panelSize2.add(textFieldSize2);
panelSize2.add(labelSize2);
panelSizeTotal.add(textFieldTotal);
panelSizeTotal.add(labelSizeTotal);
panelWeight.add(textFieldWeight);
panelWeight.add(labelWeight);
panelPopulation.add(comboBoxPopulation);
panelPopulation.add(labelPopulation);
}
else
{
panelSize1.add(labelSize1);
panelSize1.add(textFieldSize1);
panelSize2.add(labelSize2);
panelSize2.add(textFieldSize2);
panelSizeTotal.add(labelSizeTotal);
panelSizeTotal.add(textFieldTotal);
panelWeight.add(labelWeight);
panelWeight.add(textFieldWeight);
panelPopulation.add(labelPopulation);
panelPopulation.add(comboBoxPopulation);
}
inputLabels.add(labelSize1);
inputLabels.add(labelSize2);
inputLabels.add(labelSizeTotal);
inputLabels.add(labelWeight);
inputLabels.add(labelPopulation);
JPanel toadDataPanel = new JPanel();
toadDataPanel.setLayout(new BoxLayout(toadDataPanel, BoxLayout.Y_AXIS));
toadDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black, 1), Locale.labelToadData));
toadDataPanel.add(panelPopulation);
toadDataPanel.add(panelSize1);
toadDataPanel.add(panelSize2);
toadDataPanel.add(panelSizeTotal);
toadDataPanel.add(panelWeight);
JPanel placeholder = new JPanel();
toadDataPanel.add(placeholder);
dataPanel.add(toadDataPanel);
}
示例11: setComboBoxes
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setComboBoxes()
{
elencoOggetti = new JComboBox(progetto.elencoOggettiArray());
elencoOggetti.setPreferredSize(new Dimension(200, 30));
}