class myRenderer( DefaultTableCellRenderer ) : #--------------------------------------------------------------------------- # Name: __init__() # Role: Constructor - instantiate the JFormattedTextField to be used #--------------------------------------------------------------------------- def __init__( self ) : nf = NumberFormat.getInstance() nf.setMinimumFractionDigits( 2 ) nf.setMaximumFractionDigits( 2 ) self.result = JFormattedTextField( nf, horizontalAlignment = JTextField.RIGHT ) #--------------------------------------------------------------------------- # Name: getTableCellRendererComponent() # Role: Return the component containing the rendered value # Note: Called frequently, don't create a new component each time #--------------------------------------------------------------------------- def getTableCellRendererComponent( self, table, # JTable - table containing value value, # Object - value being rendered isSelected, # boolean - Is value selected? hasFocus, # boolean - Does this cell have focus? rowIndex, # int - Row # (0..N) vColIndex # int - Col # (0..N) ) : self.result.setValue( value ) return self.result
def run(self): self.frame = frame = JFrame('Frame4', size=(200, 200), layout=None, locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) frame.addComponentListener(listener(self)) self.width = JFormattedTextField(NumberFormat.getIntegerInstance(), columns=4) self.height = JFormattedTextField(NumberFormat.getIntegerInstance(), columns=4) self.x = JFormattedTextField(NumberFormat.getIntegerInstance(), columns=4) self.y = JFormattedTextField(NumberFormat.getIntegerInstance(), columns=4) items = [[JLabel('Width:'), 11, 7], [self.width, 50, 5], [JLabel('Height:'), 7, 31], [self.height, 50, 30], [JLabel('X:'), 35, 55], [self.x, 50, 53], [JLabel('Y:'), 35, 79], [self.y, 50, 78]] for item in items: thing = frame.add(item[0]) size = thing.getPreferredSize() thing.setBounds(item[1], item[2], size.width, size.height) frame.setVisible(1)
def __init__( self ) : nf = NumberFormat.getInstance() nf.setMinimumFractionDigits( 2 ) nf.setMaximumFractionDigits( 2 ) self.result = JFormattedTextField( nf, horizontalAlignment = JTextField.RIGHT )
def testDateFormat(): textField = JFormattedTextField() installFormat(textField, SimpleDateFormat('yyyy-MM-dd')) textField.setText(u'2010-11-9') textField.commitEdit() assert type(textField.value) == Date cal = GregorianCalendar(time=textField.value) assert cal.get(GregorianCalendar.YEAR) == 2010 assert cal.get(GregorianCalendar.MONTH) == 10 # January = 0 assert cal.get(GregorianCalendar.DAY_OF_MONTH) == 9
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
def addFTF(self, name): pane = self.frame.getContentPane() pane.add(JLabel(name)) pane.add( JFormattedTextField(eval('NumberFormat.' + name), value=12345.67890, columns=10))
def testJTextField(self): firstNameField = JTextField() lastNameField = JTextField() birthYearField = JFormattedTextField() self.group.bind(self.person, u'firstName', firstNameField, u'text', mode=TWOWAY) self.group.bind(self.person, u'lastName', lastNameField, u'text', mode=TWOWAY) self.group.bind(self.person, u'birthYear', birthYearField, u'value', mode=TWOWAY) self.group.bind(self.person, u'"%s %s, %s" % (firstName, lastName, birthYear)', self.dummy, u'value') assert firstNameField.text == u'Joe' firstNameField.text = u'Mary' assert self.person.firstName == u'Mary' assert self.dummy.value == u'Mary Average, 1970' self.person.firstName = u'Susan' assert firstNameField.text == u'Susan' assert self.dummy.value == u'Susan Average, 1970' self.person.lastName = u'Mediocre' assert lastNameField.text == u'Mediocre' assert self.dummy.value == u'Susan Mediocre, 1970'
def addFTF(self, name): pane = self.frame.getContentPane() pane.add(JLabel(name)) format = eval('NumberFormat.' + name) pane.add(JFormattedTextField(format, value=12345.67890)) pane.add( JTextField(str(format.getMinimumIntegerDigits()), horizontalAlignment=JTextField.CENTER)) pane.add( JTextField(str(format.getMaximumIntegerDigits()), horizontalAlignment=JTextField.CENTER)) pane.add( JTextField(str(format.getMinimumFractionDigits()), horizontalAlignment=JTextField.CENTER)) pane.add( JTextField(str(format.getMaximumFractionDigits()), horizontalAlignment=JTextField.CENTER)) pane.add( JTextField(str(format.getRoundingMode()), horizontalAlignment=JTextField.CENTER)) pane.add( JTextField(str(format.isGroupingUsed()), horizontalAlignment=JTextField.CENTER)) pane.add( JTextField(str(format.isParseIntegerOnly()), horizontalAlignment=JTextField.CENTER))
def __init__(self): nf = NumberFormat.getInstance() nf.setMinimumFractionDigits(2) nf.setMaximumFractionDigits(2) self.result = JFormattedTextField(nf, border=None, horizontalAlignment=JTextField.RIGHT) self.DTCR = DefaultTableCellRenderer()
def initComponents(self): peopleTableModel = ObjectTableModel( [], (u'First name', String, 'firstName'), (u'Last name', String, 'lastName'), (u'Birth year', Integer, 'birthYear')) self.peopleTable = JTable(peopleTableModel, selectionMode=SINGLE_SELECTION) # Create a selection holder that tracks the row selection and # notifies the table model of any changes made to the object self.selection = TableSelectionMirror(self.peopleTable) self.firstNameField = JTextField() self.lastNameField = JTextField() self.birthYearField = JFormattedTextField() installNumberFormat(self.birthYearField, int, groupingUsed=False) self.summaryField = JTextField(15, editable=False) self.addButton = JButton(u'Add person') self.removeButton = JButton(u'Remove person')
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')) nprocs = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors() procvals = sorted(set([nprocs, 1, 2, 4, 8, 16, 32, 64, 128])) cores = JComboBox(procvals) cores.setSelectedIndex(procvals.index(nprocs)) 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
plateGrid.close() ########################################################################### ##### End GUI classes ##### ########################################################################### ########################################################################### ##### Main code ##### ########################################################################### # Set up the fields for the SWING interface minField = JFormattedTextField( 0 ) minField.addActionListener( ChangedMin(minField) ) maxField = JFormattedTextField( 255 ) maxField.addActionListener( ChangedMax(maxField) ) scoreField = JTextField( "" ) scoreField.addActionListener( NextImage(scoreField) ) scoreField.addActionListener( WriteScore(scoreField) ) button = JButton("Previous image") button.addActionListener( PreviousImage(scoreField) ) # Pack all the fields into a JPanel all = JPanel() layout = GridLayout(4, 1)
def numberFormatterTest(numType, expectedType, text, nullable): textField = JFormattedTextField() installNumberFormat(textField, numType, nullable=nullable) textField.setText(text) textField.commitEdit() assert type(textField.value) == expectedType
def __init__(self): nf = NumberFormat.getInstance() nf.setMinimumFractionDigits(2) nf.setMaximumFractionDigits(2) self.result = JFormattedTextField(nf)
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
def init_components(self): self.panel0 = JPanel() self.rbgPanel0 = ButtonGroup() self.gbPanel0 = GridBagLayout() self.gbcPanel0 = GridBagConstraints() self.panel0.setLayout(self.gbPanel0) self.host_L = JLabel("Host:") self.host_L.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 1 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.host_L, self.gbcPanel0) self.panel0.add(self.host_L) self.port_L = JLabel("Port:") self.port_L.setEnabled(True) self.gbcPanel0.gridx = 1 self.gbcPanel0.gridy = 1 self.gbcPanel0.gridwidth = 2 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.port_L, self.gbcPanel0) self.panel0.add(self.port_L) self.host_TF = JTextField(10) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 2 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.host_TF, self.gbcPanel0) self.panel0.add(self.host_TF) format = NumberFormat.getInstance() format.setGroupingUsed(False) port_formatter = NumberFormatter(format) port_formatter.setValueClass(Integer) port_formatter.setAllowsInvalid(False) port_formatter.setMinimum(Integer(0)) port_formatter.setMaximum(Integer(65535)) self.port_TF = JFormattedTextField(port_formatter) self.gbcPanel0.gridx = 1 self.gbcPanel0.gridy = 2 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.port_TF, self.gbcPanel0) self.panel0.add(self.port_TF) self.blank_1_L = JLabel(" ") self.blank_1_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 3 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_1_L, self.gbcPanel0) self.panel0.add(self.blank_1_L) self.image_formats_L = JLabel("Format of images (separator \";\"):") self.port_L.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 4 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.image_formats_L, self.gbcPanel0) self.panel0.add(self.image_formats_L) self.image_formats_TF = JTextField(10) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 5 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.image_formats_TF, self.gbcPanel0) self.panel0.add(self.image_formats_TF) self.blank_2_L = JLabel(" ") self.blank_2_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 6 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_2_L, self.gbcPanel0) self.panel0.add(self.blank_2_L) self.min_probability_L = JLabel("Confidence minimum (%):") self.port_L.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 7 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.min_probability_L, self.gbcPanel0) self.panel0.add(self.min_probability_L) min_probabilty_formatter = NumberFormatter(format) min_probabilty_formatter.setValueClass(Integer) min_probabilty_formatter.setAllowsInvalid(False) min_probabilty_formatter.setMinimum(Integer(0)) min_probabilty_formatter.setMaximum(Integer(100)) self.min_probability_TF = JFormattedTextField(min_probabilty_formatter) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 8 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.min_probability_TF, self.gbcPanel0) self.panel0.add(self.min_probability_TF) self.blank_3_L = JLabel(" ") self.blank_3_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 9 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_3_L, self.gbcPanel0) self.panel0.add(self.blank_3_L) self.min_file_size_L = JLabel("Minimum file size (KB):") self.min_file_size_L.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 10 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.min_file_size_L, self.gbcPanel0) self.panel0.add(self.min_file_size_L) min_file_size_formatter = NumberFormatter(format) min_file_size_formatter.setValueClass(Integer) min_file_size_formatter.setAllowsInvalid(False) min_file_size_formatter.setMinimum(Integer(0)) self.min_file_size_TF = JFormattedTextField(min_file_size_formatter) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 11 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.min_file_size_TF, self.gbcPanel0) self.panel0.add(self.min_file_size_TF) self.blank_4_L = JLabel(" ") self.blank_4_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 12 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_4_L, self.gbcPanel0) self.panel0.add(self.blank_4_L) self.detectable_obejcts_BTN = \ JButton("List of Objects to Detect", actionPerformed=self.show_detectable_objects_dialog) # self.save_Settings_BTN.setPreferredSize(Dimension(1, 20)) self.rbgPanel0.add(self.detectable_obejcts_BTN) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 13 self.gbPanel0.setConstraints(self.detectable_obejcts_BTN, self.gbcPanel0) self.panel0.add(self.detectable_obejcts_BTN) self.blank_5_L = JLabel(" ") self.blank_5_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 14 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_5_L, self.gbcPanel0) self.panel0.add(self.blank_5_L) self.error_message = JLabel("", JLabel.CENTER) self.error_message.setForeground(Color.red) self.error_message.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 15 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.error_message, self.gbcPanel0) self.panel0.add(self.error_message) self.message = JLabel("", JLabel.CENTER) self.message.setEnabled(True) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 16 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.message, self.gbcPanel0) self.panel0.add(self.message) self.save_settings_BTN = JButton("Save Settings", actionPerformed=self.save_settings) # self.save_Settings_BTN.setPreferredSize(Dimension(1, 20)) self.rbgPanel0.add(self.save_settings_BTN) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 17 self.gbPanel0.setConstraints(self.save_settings_BTN, self.gbcPanel0) self.panel0.add(self.save_settings_BTN) self.blank_6_L = JLabel(" ") self.blank_6_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 18 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_6_L, self.gbcPanel0) self.panel0.add(self.blank_6_L) self.blank_7_L = JLabel(" ") self.blank_7_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 19 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_7_L, self.gbcPanel0) self.panel0.add(self.blank_7_L) self.check_server_connection_BTN = \ JButton("Check server connection", actionPerformed=self.check_server_connection) # self.save_Settings_BTN.setPreferredSize(Dimension(1, 20)) self.rbgPanel0.add(self.check_server_connection_BTN) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 20 self.gbPanel0.setConstraints(self.check_server_connection_BTN, self.gbcPanel0) self.panel0.add(self.check_server_connection_BTN) self.blank_8_L = JLabel(" ") self.blank_8_L.setEnabled(True) self.gbcPanel0.gridx = 2 self.gbcPanel0.gridy = 21 self.gbcPanel0.gridwidth = 1 self.gbcPanel0.gridheight = 1 self.gbcPanel0.fill = GridBagConstraints.BOTH self.gbcPanel0.weightx = 1 self.gbcPanel0.weighty = 0 self.gbcPanel0.anchor = GridBagConstraints.NORTH self.gbPanel0.setConstraints(self.blank_8_L, self.gbcPanel0) self.panel0.add(self.blank_8_L) self.text_editor_BTN = \ JButton("Open config file", actionPerformed=self.open_text_editor) # self.save_Settings_BTN.setPreferredSize(Dimension(1, 20)) self.rbgPanel0.add(self.text_editor_BTN) self.gbcPanel0.gridx = 0 self.gbcPanel0.gridy = 22 self.gbPanel0.setConstraints(self.text_editor_BTN, self.gbcPanel0) self.panel0.add(self.text_editor_BTN) self.add(self.panel0)
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) self.add(JLabel('Expected total samples')) 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) else: self.mut = None 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)
def run( self ) : #--------------------------------------------------------------------------- # Name: label() # Role: Instantiate a Right aligned label with the specified text #--------------------------------------------------------------------------- def label( text ) : return JLabel( text + ' ', horizontalAlignment = SwingConstants.RIGHT ) frame = JFrame( 'PropertyListener', layout = BorderLayout(), locationRelativeTo = None, size = ( 400, 300 ), defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) pane = JPanel( layout = GridLayout( 0, 2 ) ) pane.add( label( 'Number:' ) ) pane.add( JFormattedTextField( NumberFormat.getNumberInstance(), value = 12345.67890, columns = 10, propertyChange = self.changed ) ) pane.add( label( 'Currency:' ) ) pane.add( JFormattedTextField( NumberFormat.getCurrencyInstance(), value = 12345.67890, columns = 10, propertyChange = self.changed ) ) frame.add( JSplitPane( JSplitPane.HORIZONTAL_SPLIT, pane, JButton( 'Clear', actionPerformed = self.clear ), ), BorderLayout.NORTH ) self.textArea = JTextArea( rows = 10, columns = 40, editable = 0, focusable = 0, font = Font( 'Courier' , Font.BOLD, 12 ) ) frame.add( JScrollPane( self.textArea ), BorderLayout.CENTER ) frame.setVisible( 1 )