本文整理汇总了Python中javax.swing.JComboBox.getPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Python JComboBox.getPreferredSize方法的具体用法?Python JComboBox.getPreferredSize怎么用?Python JComboBox.getPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.getPreferredSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addLine
# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getPreferredSize [as 别名]
def addLine(self, objectID, category, text):
"""
Add a new panel containing the text corresponding to one line in the
ATF file.
This panel will show the line type (ruling, comment, text,
translation...), followed by the line content and a group of icons to
add, edit or remove the line.
"""
linePanel = JPanel()
linePanel.setLayout(BorderLayout())
label = JLabel(category)
combo = JComboBox(text)
combo.setEditable(True)
combo.setPreferredSize(Dimension(500, 20))
combo.setSize(combo.getPreferredSize())
combo.setMinimumSize(combo.getPreferredSize())
combo.setMaximumSize(combo.getPreferredSize())
buttonsPanel = JPanel()
addButton = JButton("Add")
editButton = JButton("Edit")
deleteButton = JButton("Delete")
buttonsPanel.add(addButton)
buttonsPanel.add(editButton)
buttonsPanel.add(deleteButton)
linePanel.add(label, BorderLayout.WEST)
linePanel.add(combo, BorderLayout.CENTER)
linePanel.add(buttonsPanel, BorderLayout.EAST)
# Add metadataPanel to object tab in main panel
self.objectTabs[objectID].add(linePanel)
示例2: __init__
# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getPreferredSize [as 别名]
def __init__(self, chartFun, isTemporal = False):
self.isTemporal = isTemporal
JPanel()
#self.setBackground(Color.LIGHT_GRAY)
self.chartFun = chartFun
self.enableChartFun = False
self.setLayout(GridLayout(6,2))
self.add(JLabel('CPU Cores'))
cores = JComboBox(['1', '2', '4', '8', '16', '32', '64', '128'])
nprocs = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors()
pos = min([7, log(ceil(nprocs)) / log(2)])
cores.setSelectedIndex(int(pos))
cores.setMaximumSize(cores.getPreferredSize())
self.cores = cores
self.add(self.cores)
self.add(JLabel('# of sims (x1000) '))
numSims = JComboBox(
map(lambda x: str((10+x)*5), range(10)) +
map(lambda x: str(x*100), range(1,11))
)
numSims.setMaximumSize(numSims.getPreferredSize())
self.numSims = numSims
self.add(self.numSims)
if isTemporal:
self.add(JLabel('"Neutral" Ne'))
self.neutral = JCheckBox()
self.neutral.addActionListener(self)
self.add(self.neutral)
else:
self.add(JLabel('"Neutral" mean Fst'))
self.neutral = JCheckBox()
self.neutral.addActionListener(self)
self.add(self.neutral)
self.add(JLabel('Force mean Fst'))
self.force = JCheckBox()
self.force.addActionListener(self)
self.add(self.force)
self.add(JLabel('Confidence interval '))
ci = JComboBox(['0.95', '0.99', '0.995'])
ci.addItemListener(self)
ci.setMaximumSize(cores.getPreferredSize())
self.ci = ci
self.add(self.ci)
self.add(JLabel('False Disc. Rate'))
fdr = JFormattedTextField(
NumberFormat.getNumberInstance(Locale.US))
fdr.setValue(0.1)
fdr.addPropertyChangeListener(self)
self.add(fdr)
self.fdr = fdr
示例3: NewAtfView
# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getPreferredSize [as 别名]
#.........这里部分代码省略.........
panel.setLayout(layout)
# Create necessary components and add them to panel.
project_label = JLabel('Project: ')
self.right_combo = JComboBox()
self.right_combo.setEditable(True)
def create_project_list():
'''
Prepares list of projects and subprojects ordered with the default
one first.
'''
default_project = self.projects['default'][0].split('/')[0]
if '/' in self.projects['default']:
default_subproject = self.projects['default'].split('/')[1]
else:
default_subproject = ''
projects = [default_project]
subprojects = [default_subproject]
# User created projects might not be in default dictionary
for project in self.projects.keys():
if (project != default_project and project != 'default'):
projects.append(project)
# Default project might not have subproject
if default_project in self.projects.keys():
if default_subproject:
for subproject in self.projects[default_project]:
if (subproject != default_subproject):
subprojects.append(subproject)
return projects, subprojects
self.left_combo = JComboBox(create_project_list()[0])
# Make left combo keep size no matter how long project names are
self.left_combo.setPreferredSize(Dimension(125, 30))
self.left_combo.setMinimumSize(self.left_combo.getPreferredSize())
self.left_combo.setMaximumSize(self.left_combo.getPreferredSize())
self.left_combo.setSize(self.left_combo.getPreferredSize())
self.right_combo = JComboBox(create_project_list()[1])
# Prevent right combo to change sizes dynamically
self.right_combo.setPreferredSize(Dimension(100, 30))
self.right_combo.setMinimumSize(self.left_combo.getPreferredSize())
self.right_combo.setMaximumSize(self.left_combo.getPreferredSize())
self.right_combo.setSize(self.left_combo.getPreferredSize())
action_listener = ComboActionListener(self.right_combo,
self.projects)
self.left_combo.addActionListener(action_listener)
self.left_combo.setEditable(True)
self.right_combo.setEditable(True)
slash_label = JLabel('/')
tooltip_text = ("<html><body>Choose project from list or insert a new "
"one.<br/>You can leave the right-hand field blank."
"</body><html>")
help_label = self.build_help_label(tooltip_text)
panel.add(project_label)
panel.add(self.left_combo)
panel.add(slash_label)
panel.add(self.right_combo)
panel.add(help_label)
# Set up constraints to tell panel how to position components.
layout.putConstraint(SpringLayout.WEST,
project_label,
15,
SpringLayout.WEST,