本文整理汇总了Python中javax.swing.JComboBox.addItemListener方法的典型用法代码示例。如果您正苦于以下问题:Python JComboBox.addItemListener方法的具体用法?Python JComboBox.addItemListener怎么用?Python JComboBox.addItemListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.addItemListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import addItemListener [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
示例2: CurveDialog
# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import addItemListener [as 别名]
class CurveDialog(JDialog):
def __init__(self, cattrs):
#JDialog.__init__(self,"Curve Attribute Editor")
#("Curve Attribute Editor")
if cattrs == None or len(cattrs) == 0:
raise "No curve attributes specified"
self.attrs = cattrs
self.cpanel = EditCurveAttr(cattrs[0])
pane = self.getContentPane()
pane.setLayout(BorderLayout())
x = map(lambda x: x+1,range(len(self.attrs)))
self.curveBox = JComboBox(x)
self.curveBox.setBorder(BorderFactory.createTitledBorder("Curve #"))
self.curveBox.setSelectedItem(0)
class CListener(ItemListener):
def __init__(self,cbox,cpanel,cattrs):
self.cbox = cbox
self.cpanel = cpanel
self.attrs = cattrs
def itemStateChanged(self, evt):
crvNo = self.cbox.getSelectedItem()
self.cpanel.update()
self.cpanel.setAttribute(self.attrs[crvNo-1])
self.curveBox.addItemListener(CListener(self.curveBox, self.cpanel,self.attrs))
okBtn = JButton("OK",actionPerformed=self.ok_action)
cancelBtn = JButton("Cancel",actionPerformed=self.cancel_action)
btnPanel = JPanel()
btnPanel.setLayout(GridLayout(1,3))
btnPanel.add(self.curveBox)
btnPanel.add(okBtn)
btnPanel.add(cancelBtn)
pane.add(self.cpanel,BorderLayout.CENTER)
pane.add(btnPanel, BorderLayout.SOUTH)
self.setLocation(100,100)
self.pack()
self.setVisible(1)
def ok_action(self,evt):
#crvNo = self.curveBox.getSelectedItem()
#print 'Setting attributes for ', crvNo
#print self.attrs[crvNo-1]
self.cpanel.update()
self.cancel_action(evt)
def cancel_action(self,evt):
self.dispose()
示例3: EmpiricalPanel
# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import addItemListener [as 别名]
#.........这里部分代码省略.........
self.beta1.setValue(beta[0])
self.beta2.setValue(beta[1])
self.ignoreChanges = ignoreChanges
def getCrit(self):
return self.crit.getValue()
def setCrit(self, crit):
ignoreChanges = self.ignoreChanges
self.ignoreChanges = True
self.crit.setValue(crit)
self.ignoreChanges = ignoreChanges
def getSampleSize(self):
return self.sampleSize.getValue()
def setSampleSize(self, sampleSize):
ignoreChanges = self.ignoreChanges
self.ignoreChanges = True
self.sampleSize.setValue(sampleSize)
self.ignoreChanges = ignoreChanges
def __init__(self, menuHandles, manager, isDominant, systemPanel, isTemporal=False):
self.systemPanel = systemPanel
self.knownPops = 0
self.ignoreChanges = True
JPanel()
self.menuHandles = menuHandles
self.isDominant = isDominant
self.isTemporal = isTemporal
if isDominant:
self.setLayout(GridLayout(8, 2))
else:
self.setLayout(GridLayout(5, 2))
if isTemporal:
self.add(JLabel("Ne"))
ne = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
ne.addPropertyChangeListener(self)
self.ne = ne
self.add(ne)
else:
self.add(JLabel("Attempted Fst"))
fst = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
fst.addPropertyChangeListener(self)
self.fst = fst
self.add(fst)
self.add(JLabel("Expected total pops"))
pops = JFormattedTextField(NumberFormat.getIntegerInstance(Locale.US))
pops.addPropertyChangeListener(self)
# self.pops = JComboBox(['1', '2', '4', '8', '12', '16'])
self.pops = pops
self.add(self.pops)
if not isDominant and not isTemporal:
self.add(JLabel("Mutation model"))
self.mut = JComboBox(["Infinite Alleles", "Stepwise"])
self.mut.addItemListener(self)
self.add(self.mut)
self.add(JLabel("Subsample size"))
sampleSize = JFormattedTextField(NumberFormat.getIntegerInstance(Locale.US))
sampleSize.addPropertyChangeListener(self)
self.sampleSize = sampleSize
self.add(self.sampleSize)
if isDominant:
self.add(JLabel("Theta"))
theta = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
theta.addPropertyChangeListener(self)
self.theta = theta
self.add(theta)
theta.setValue(0.1)
self.add(JLabel("Beta-a"))
beta1 = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
beta1.addPropertyChangeListener(self)
self.beta1 = beta1
self.add(beta1)
beta1.setValue(0.25)
self.add(JLabel("Beta-b"))
beta2 = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
beta2.addPropertyChangeListener(self)
self.beta2 = beta2
self.add(beta2)
beta2.setValue(0.25)
self.add(JLabel("Critical frequency"))
crit = JFormattedTextField(NumberFormat.getNumberInstance(Locale.US))
crit.addPropertyChangeListener(self)
self.crit = crit
self.add(crit)
crit.setValue(0.99)
run = JButton("Run!")
run.addActionListener(manager)
run.setActionCommand("RunFDist")
self.run = run
self.add(run)
cancel = JButton("Stop")
cancel.addActionListener(manager)
cancel.setActionCommand("CancelFDist")
self.cancel = cancel