def run(self): frame = JFrame('List6', size=(200, 220), layout=GridLayout(1, 2), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) panel = JPanel(layout=GridLayout(0, 1)) self.buttons = {} for name in 'First,Last,Before,After,Remove'.split(','): self.buttons[name] = panel.add(self.button(name)) self.text = panel.add(JTextField(10)) self.addInputMethodListener(self) # self.addTextListener( self ) frame.add(panel) data = ('Now is the time for all good spam ' + 'to come to the aid of their eggs').split(' ') model = DefaultListModel() for word in data: model.addElement(word) self.info = JList(model, valueChanged=self.selection, selectionMode=ListSelectionModel.SINGLE_SELECTION) frame.add(JScrollPane(self.info, preferredSize=(200, 100))) frame.setVisible(1)
def __init__(self): #Class variable declarations self.mainPanel = JPanel(GridLayout(1, 2)) self.subPanel1 = JPanel(BorderLayout()) self.subPanel2 = JPanel(GridLayout(5, 1)) self.userText = JTextArea(' ') self.emoticonFeedback = JTextArea( 'This will consider your emoticon usage.') self.curseFeedback = JTextArea( 'This will consider your use of profanity.') self.styleFeedback = JTextArea('This will consider your general tone.') self.overallFeedback = JTextArea('This will be your overall score.') self.button = JButton("Score my email!", actionPerformed=self.updateScores) self.initGUI() self.add(self.mainPanel) self.setSize(800, 500) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setVisible(True)
def createMainWindow(): # Create window frame = JFrame('Epiphany Core Visualisation', defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(660, 675)) # Main layout mainLayout = JPanel() frame.add(mainLayout) # Title #title = JLabel('hello', JLabel.CENTER) #mainLayout.add(title) # Cores corepanel = JPanel(GridLayout(8, 8)) global cores cores = [] for i in range(0, 64): core = JPanel(GridLayout(2, 1)) core.setPreferredSize(Dimension(80, 80)) corename = '(' + str(i % 8) + ',' + str(i / 8) + ')' namelabel = JLabel(corename, JLabel.CENTER) namelabel.setFont(Font("Dialog", Font.PLAIN, 18)) portname = str(i + MINPORT) portlabel = JLabel(portname, JLabel.CENTER) portlabel.setFont(Font("Dialog", Font.PLAIN, 16)) core.add(namelabel) core.add(portlabel) core.setBackground(Color.BLACK) corepanel.add(core) cores.append(core) mainLayout.add(corepanel) frame.visible = True
def buildpane(self): gw = JPanel(GridLayout(1, 2), doublebuffered) gw.add(JLabel("Gateway")) self.gwlist = JComboBox( self.gateways.keys()) #, actionPerformed=self.changegw) self.gwlist.setSelectedItem("Twisted") gw.add(self.gwlist) stdoptions = JPanel(GridLayout(2, 2), doublebuffered) stdoptions.border = TitledBorder("Standard Options") stdoptions.add(JLabel()) stdoptions.add(self.autologin) stdoptions.add(JLabel("Account Name")) stdoptions.add(self.acctname) buttons = JPanel(FlowLayout(), doublebuffered) buttons.add(JButton("OK", actionPerformed=self.addaccount)) buttons.add(JButton("Cancel", actionPerformed=self.cancel)) mainpane = self.mainframe.getContentPane() mainpane.layout = BoxLayout(mainpane, BoxLayout.Y_AXIS) mainpane.add(gw) mainpane.add(self.gwoptions) mainpane.add(stdoptions) mainpane.add(buttons)
def __init__(self,main_loop_controller): self.main_loop_controller = main_loop_controller self.setLayout(GridLayout(3,1,1,1)) self.setBorder(BorderFactory.createEtchedBorder()) start_button = JButton("Start") start_button.addActionListener(Start_Button_Listener(self.main_loop_controller)) start_selected_button = JButton("Start Selected Cavs.") start_selected_button.addActionListener(Start_Selected_Cavs_Button_Listener(self.main_loop_controller)) stop_button = JButton("Stop") stop_button.addActionListener(Stop_Button_Listener(self.main_loop_controller)) send_amp_phase_to_EPICS_button = JButton("Send New Amp&Phase to EPICS for Selected Cavs") send_amp_phase_to_EPICS_button.addActionListener(Send_Amp_Phase_to_EPICS_Button_Listener(self.main_loop_controller)) restore_amp_phase_to_EPICS_button = JButton("Restore Init Amp&Phase to EPICS for Selected Cavs") restore_amp_phase_to_EPICS_button.addActionListener(Restore_Amp_Phase_of_Selected_Cavs_to_EPICS_Button_Listener(self.main_loop_controller)) correct_phase_shifts_button = JButton("Correct Phase Shifts for 360 deg Scans") correct_phase_shifts_button.addActionListener(Correct_Phase_Shifts_for_360deg_Scans_Button_Listener(self.main_loop_controller)) self.keepAllCavParams_RadioButton = JRadioButton("Keep Cavs' Amps&Phases") self.keepAmps_RadioButton = JRadioButton("Keep Cavities' Amplitudes") self.status_text = JTextField(30) self.status_text.setForeground(Color.red) self.status_text.setText("Not running.") status_text_label = JLabel("Loop status:",JLabel.RIGHT) status_panel_tmp0 = JPanel(GridLayout(2,1,1,1)) status_panel_tmp0.add(status_text_label) status_panel_tmp0.add(self.main_loop_controller.main_loop_timer.time_estimate_label) status_panel_tmp1 = JPanel(GridLayout(2,1,1,1)) status_panel_tmp1.add(self.status_text) status_panel_tmp1.add(self.main_loop_controller.main_loop_timer.time_estimate_text) status_panel = JPanel(BorderLayout()) status_panel.add(status_panel_tmp0,BorderLayout.WEST) status_panel.add(status_panel_tmp1,BorderLayout.CENTER) status_panel.setBorder(BorderFactory.createEtchedBorder()) buttons_panel0 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) buttons_panel0.add(start_button) buttons_panel0.add(start_selected_button) buttons_panel0.add(stop_button) buttons_panel1 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) buttons_panel1.add(self.keepAllCavParams_RadioButton) buttons_panel1.add(self.keepAmps_RadioButton) buttons_panel = JPanel(GridLayout(2,1,1,1)) buttons_panel.add(buttons_panel0) buttons_panel.add(buttons_panel1) #--------------------------------------- bottom_buttons_panel0 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) bottom_buttons_panel0.add(send_amp_phase_to_EPICS_button) bottom_buttons_panel1 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) bottom_buttons_panel1.add(restore_amp_phase_to_EPICS_button) bottom_buttons_panel2 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) bottom_buttons_panel2.add(correct_phase_shifts_button) bottom_buttons_panel = JPanel(GridLayout(3,1,1,1)) bottom_buttons_panel.add(bottom_buttons_panel0) bottom_buttons_panel.add(bottom_buttons_panel1) bottom_buttons_panel.add(bottom_buttons_panel2) #--------------------------------------- self.add(buttons_panel) self.add(status_panel) self.add(bottom_buttons_panel)
def __init__(self,transverse_twiss_analysis_Controller): self.transverse_twiss_analysis_Controller = transverse_twiss_analysis_Controller self.setLayout(BorderLayout()) #-----------dict table panel etched_border = BorderFactory.createEtchedBorder() border = BorderFactory.createTitledBorder(etched_border,"Quad and Cavities Amp.&Phases Sets") self.setBorder(border) self.quad_cav_dict_table_model = QuadCavDict_Table_Model(self.transverse_twiss_analysis_Controller.accStatesKeeper) self.dict_table = JTable(self.quad_cav_dict_table_model) self.dict_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.dict_table.setFillsViewportHeight(true) self.dict_table.setPreferredScrollableViewportSize(Dimension(120,100)) self.dict_table.getSelectionModel().addListSelectionListener(QuadCavDict_Table_Selection_Listener(self.transverse_twiss_analysis_Controller)) #--------buttons panel button_panel = JPanel(BorderLayout()) self.gaussButton = JRadioButton("Use Ext. Gauss Fit") self.custom_gaussButton = JRadioButton("Use Gauss Fit") self.custom_rmsButton = JRadioButton("Use RMS") button_group = ButtonGroup() button_group.add(self.gaussButton) button_group.add(self.custom_gaussButton) button_group.add(self.custom_rmsButton) button_group.clearSelection() self.gaussButton.setSelected(true) button_panel0 = JPanel(FlowLayout(FlowLayout.LEFT,2,2)) button_panel0.add(self.gaussButton) button_panel1 = JPanel(FlowLayout(FlowLayout.LEFT,2,2)) button_panel1.add(self.custom_gaussButton) button_panel2 = JPanel(FlowLayout(FlowLayout.LEFT,2,2)) button_panel2.add(self.custom_rmsButton) button_panel012 = JPanel(GridLayout(3,1)) button_panel012.add(button_panel0) button_panel012.add(button_panel1) button_panel012.add(button_panel2) #-------new buttons----- button_bottom_panel = JPanel(FlowLayout(FlowLayout.LEFT,2,2)) button_bottom_panel0 = JPanel(GridLayout(3,1,2,2)) dump_quad_fields_button = JButton("Dump Quad Fields to ASCII") dump_quad_fields_button.addActionListener(Dump_Quad_Fields_Button_Listener(self.transverse_twiss_analysis_Controller)) button_bottom_panel0.add(dump_quad_fields_button) dump_cav_amps_phases_button = JButton("Dump. Cav Amps. Phases to ASCII") dump_cav_amps_phases_button.addActionListener(Dump_Cav_Amps_Phases_Button_Listener(self.transverse_twiss_analysis_Controller)) button_bottom_panel0.add(dump_cav_amps_phases_button) read_cav_amps_phases_button = JButton("Read Cav Amps. Phases from ASCII") read_cav_amps_phases_button.addActionListener(Read_Cav_Amps_Phases_Button_Listener(self.transverse_twiss_analysis_Controller)) button_bottom_panel0.add(read_cav_amps_phases_button) button_bottom_panel.add(button_bottom_panel0) #----- final knobs panel button_panel.add(button_panel012,BorderLayout.NORTH) button_panel.add(button_bottom_panel,BorderLayout.SOUTH) self.gaussButton.addActionListener(FitParam_Buttons_Listener(self.transverse_twiss_analysis_Controller,0)) self.custom_gaussButton.addActionListener(FitParam_Buttons_Listener(self.transverse_twiss_analysis_Controller,1)) self.custom_rmsButton.addActionListener(FitParam_Buttons_Listener(self.transverse_twiss_analysis_Controller,2)) #---------------------------------------------------------- self.add(JScrollPane(self.dict_table), BorderLayout.WEST) self.add(button_panel, BorderLayout.CENTER)
def __init__(self,dtl_acceptance_scans_controller): self.dtl_acceptance_scans_controller = dtl_acceptance_scans_controller self.main_loop_controller = self.dtl_acceptance_scans_controller.main_loop_controller self.setLayout(GridLayout(3,1,1,1)) self.setBorder(BorderFactory.createEtchedBorder()) #----------------------------------------------------------- start_selected_button = JButton("Start Scan for Selected Cavs") start_selected_button.addActionListener(Start_Scan_Selected_Cavs_Button_Listener(self.dtl_acceptance_scans_controller)) stop_button = JButton("Stop") stop_button.addActionListener(Stop_Scan_Button_Listener(self.dtl_acceptance_scans_controller)) send_amp_phase_to_EPICS_button = JButton("Send New Amp&Phase to EPICS for Selected Cavs") send_amp_phase_to_EPICS_button.addActionListener(Send_Amp_Phase_to_EPICS_Button_Listener(self.dtl_acceptance_scans_controller)) restore_amp_phase_to_EPICS_button = JButton("Restore Init Amp&Phase to EPICS for Selected Cavs") restore_amp_phase_to_EPICS_button.addActionListener(Restore_Amp_Phase_of_Selected_Cavs_to_EPICS_Button_Listener(self.dtl_acceptance_scans_controller)) self.keepPhases_RadioButton = JRadioButton("Keep Cavities Phases") self.keepAmps_RadioButton = JRadioButton("Keep Cavities Amplitudes") self.skipAnalysis_RadioButton = JRadioButton("Skip Analysis") #----------------------------------------------------------- self.status_text = JTextField(30) self.status_text.setForeground(Color.red) self.status_text.setText("Not running.") status_text_label = JLabel("Loop status:",JLabel.RIGHT) status_panel_tmp0 = JPanel(GridLayout(2,1,1,1)) status_panel_tmp0.add(status_text_label) status_panel_tmp0.add(self.dtl_acceptance_scans_controller.acc_scan_loop_timer.time_estimate_label) status_panel_tmp1 = JPanel(GridLayout(2,1,1,1)) status_panel_tmp1.add(self.status_text) status_panel_tmp1.add(self.dtl_acceptance_scans_controller.acc_scan_loop_timer.time_estimate_text) status_panel = JPanel(BorderLayout()) status_panel.add(status_panel_tmp0,BorderLayout.WEST) status_panel.add(status_panel_tmp1,BorderLayout.CENTER) status_panel.setBorder(BorderFactory.createEtchedBorder()) #------------------------------------------------ buttons_panel0 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) buttons_panel0.add(start_selected_button) buttons_panel0.add(stop_button) buttons_panel1 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) buttons_panel1.add(self.skipAnalysis_RadioButton) buttons_panel1.add(self.keepPhases_RadioButton) buttons_panel1.add(self.keepAmps_RadioButton) buttons_panel = JPanel(GridLayout(2,1,1,1)) buttons_panel.add(buttons_panel0) buttons_panel.add(buttons_panel1) #--------------------------------------- bottom_buttons_panel0 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) bottom_buttons_panel0.add(send_amp_phase_to_EPICS_button) bottom_buttons_panel1 = JPanel(FlowLayout(FlowLayout.LEFT,3,1)) bottom_buttons_panel1.add(restore_amp_phase_to_EPICS_button) bottom_buttons_panel = JPanel(GridLayout(2,1,1,1)) bottom_buttons_panel.add(bottom_buttons_panel0) bottom_buttons_panel.add(bottom_buttons_panel1) #--------------------------------------- self.add(buttons_panel) self.add(status_panel) self.add(bottom_buttons_panel)
def __init__(self, rf_power_controller): self.rf_power_controller = rf_power_controller self.setLayout(GridLayout(3, 1, 1, 1)) self.setBorder(BorderFactory.createEtchedBorder()) start_button = JButton("Start Averaging") start_button.addActionListener( Start_Button_Listener(self.rf_power_controller)) stop_button = JButton("Stop") stop_button.addActionListener( Stop_Button_Listener(self.rf_power_controller)) n_avg_label = JLabel("N Avg.=", JLabel.RIGHT) self.n_avg_text = DoubleInputTextField(10.0, DecimalFormat("###.#"), 5) time_step_label = JLabel("Time Step[sec]=", JLabel.RIGHT) self.time_step_text = DoubleInputTextField(1.1, DecimalFormat("##.#"), 4) send_amp_phase_to_EPICS_button = JButton( "Send New Amp to Selected Cavs") send_amp_phase_to_EPICS_button.addActionListener( Send_Amp_Phase_to_EPICS_Button_Listener(self.rf_power_controller)) make_new_pwrs_as_target_button = JButton( "Make Measured Powers as New Traget for Selected Cavs") make_new_pwrs_as_target_button.addActionListener( Make_New_Pwrs_as_Target_Button_Listener(self.rf_power_controller)) self.status_text = JTextField(30) self.status_text.setForeground(Color.red) self.status_text.setText("Not running.") status_text_label = JLabel("Averaging status:", JLabel.RIGHT) status_panel = JPanel(BorderLayout()) status_panel.add(status_text_label, BorderLayout.WEST) status_panel.add(self.status_text, BorderLayout.CENTER) status_panel.setBorder(BorderFactory.createEtchedBorder()) buttons_panel = JPanel(FlowLayout(FlowLayout.LEFT, 3, 1)) buttons_panel.add(start_button) buttons_panel.add(stop_button) buttons_panel.add(n_avg_label) buttons_panel.add(self.n_avg_text) buttons_panel.add(time_step_label) buttons_panel.add(self.time_step_text) #--------------------------------------- bottom_buttons_panel = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) bottom_buttons_panel_tmp = JPanel(GridLayout(2, 1, 1, 1)) bottom_buttons_panel_tmp0 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) bottom_buttons_panel_tmp1 = JPanel(FlowLayout(FlowLayout.LEFT, 1, 1)) bottom_buttons_panel_tmp.add(bottom_buttons_panel_tmp0) bottom_buttons_panel_tmp.add(bottom_buttons_panel_tmp1) bottom_buttons_panel.add(bottom_buttons_panel_tmp) bottom_buttons_panel_tmp0.add(send_amp_phase_to_EPICS_button) bottom_buttons_panel_tmp1.add(make_new_pwrs_as_target_button) #--------------------------------------- self.add(buttons_panel) self.add(status_panel) self.add(bottom_buttons_panel)
def __init__(self): super(Table, self).__init__(GridLayout( 0, 1)) # 1 column, as many rows as necessary self.tableModel = TableModel() self.table = JTable(self.tableModel) self.table.setPreferredScrollableViewportSize(Dimension(500, 100)) self.table.setFillsViewportHeight(True) # Handle row selection #table.getSelectionModel().addListSelectionListener( RowListener()) #table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) self.table.setRowSelectionAllowed(True) #Create the scroll pane and add the table to it. scrollPane = JScrollPane(self.table) #ScrollPane scrollPane = ScrollPane() #scrollPane.add(table) #Add the scroll pane to self panel. self.add(scrollPane) # LABEL PANEL labelPanel = JPanel(GridLayout(0, 1)) #Panel labelPanel = Panel( GridLayout(0,2)) #Panel labelPanel = Panel() # looks bad when resizing # Add label labelName = JLabel("Name") labelPanel.add(labelName) self.add(labelPanel) # BUTTON PANNEL buttonPanel = JPanel(GridLayout(0, 2)) #Panel buttonPanel = Panel() # Add text field for group name self.groupField = JTextField("new group") buttonPanel.add(self.groupField) # Button "Add Row" #JButton buttonAdd = AddButton() buttonPanel.add(AddButton(self)) buttonPanel.add(JLabel()) # empty JLabel to fill the blank buttonPanel.add(DeleteButton(self)) buttonPanel.add(ImportButton(self)) buttonPanel.add(ExportButton(self)) # Finally add button panel to main panel self.add(buttonPanel)
def __init__(self): # every time the button is pressed, center the display #listener = addEventListener(searchbutton, ActionListener, 'actionPerformed', searchaction) self.searchbutton.actionPerformed = self.searchaction self.clustrbutton.actionPerformed= self.cluaction self.depthbutton.actionPerformed= self.depthaction self.betcluster.actionPerformed=self.connectaction self.minclustr.actionPerformed=self.mincluaction self.frame =JFrame('Welcome to Tree Search!', defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(300, 300), locationRelativeTo=None) self.mainPanel =JPanel(GridLayout(7,1)) self.mainPanel.add(self.searchtext) self.frame.add(self.mainPanel) self.prow =JPanel(GridLayout(1,3)) self.prow.add(self.searchbutton) self.prow.add(self.minclustr) self.prow.add(self.clustrbutton) self.frame.add(self.prow) self.mainPanel.add(self.prow) self.prow =JPanel(GridLayout(1,2)) self.prow.add(self.depthtext) self.prow.add(self.leveltext) self.frame.add(self.prow) self.mainPanel.add(self.prow) self.mainPanel.add(self.depthbutton) self.frame.add(self.mainPanel) self.prow=JPanel(GridLayout(1,2)) self.prow.add(self.node1text) self.prow.add(self.node2text) self.frame.add(self.prow) self.mainPanel.add(self.prow) self.mainPanel.add(self.betcluster) self.frame.add(self.mainPanel) self.mainPanel.add(self.textarea) self.frame.add(self.mainPanel) self.frame.visible=true #add toolbar to the main window ui.dock(self)
def run(self): #----------------------------------------------------------------------- # Name: isEven() # Role: Return true (1) if the specified value is an even integer #----------------------------------------------------------------------- def isEven(num): return not (num & 1) #----------------------------------------------------------------------- # Name: isOdd() # Role: Return true (1) if the specified value is an odd integer #----------------------------------------------------------------------- def isOdd(num): return num & 1 #----------------------------------------------------------------------- # Name: isPrime() # Role: Return true (1) if and only if the specified value is a prime # integer #----------------------------------------------------------------------- def isPrime(num): result = 0 # Default = False if num == abs(int(num)): # Only integers allowed if num == 1: # Special case pass # use default (false) elif num == 2: # Special case result = 1 # elif num & 1: # Only odd numbers... for f in xrange(3, int(num**0.5) + 1, 2): if not num % f: break # f is a factor... else: result = 1 # we found a prime return result #--------------------------------------------------------------------------- # Name: label() # Role: Instantiate a Right aligned label with the specified text #--------------------------------------------------------------------------- def label(text): return JLabel(text + ' ', horizontalAlignment=SwingConstants.RIGHT) frame = JFrame('Listen4', layout=GridLayout(0, 2), locationRelativeTo=None, size=(200, 128), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) frame.add(label('Integer:')) text = frame.add(JTextField(10)) frame.add(label('Even?')) even = frame.add(JLabel('')) text.addKeyListener(listener(text, even, isEven)) frame.add(label('Odd?')) odd = frame.add(JLabel('')) text.addKeyListener(listener(text, odd, isOdd)) frame.add(label('Prime?')) prime = frame.add(JLabel('')) text.addKeyListener(listener(text, prime, isPrime)) frame.setVisible(1)
def run( self ) : frame = JFrame( 'List3', size = ( 200, 200 ), layout = BorderLayout(), defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) data = ( 'Now is the time for all good spam ' + 'to come to the aid of their eggs' ).split( ' ' ) self.info = JList( data ) frame.add( JScrollPane( self.info, preferredSize = ( 200, 110 ) ), BorderLayout.NORTH ) panel = JPanel( layout = GridLayout( 0, 2 ) ) panel.add( JButton( 'Count', actionPerformed = self.count ) ) self.text = panel.add( JTextField( 10 ) ) frame.add( panel, BorderLayout.CENTER ) self.msg = JLabel( 'Occurance count' ) frame.add( self.msg, BorderLayout.SOUTH ) frame.setVisible( 1 )
def initComponents(self): self.panel = JPanel(GridLayout(0, 1)) self.combo = makeLanguageSelectionComboBox(self.panel, "english") #mode self.panel.add(JLabel("Choose mode: ")) self.modeGroup = ButtonGroup() rb = JRadioButton self.radioButtonTranscribed = rb( 'Generate report of files with \'Transcribed\' tag.') radioButtons = ( self.radioButtonTranscribed, rb('Transcribe files with \'Transcribe\' tag and generate report')) for a_radiobutton in radioButtons: self.modeGroup.add(a_radiobutton) self.panel.add(a_radiobutton) self.radioButtonTranscribed.selected = 1 #type self.panel.add(JLabel("Choose type: ")) self.typeGroup = ButtonGroup() self.radioButtonHTML = rb('HTML') radioButtons = (self.radioButtonHTML, rb('CSV')) for a_radiobutton in radioButtons: self.typeGroup.add(a_radiobutton) self.panel.add(a_radiobutton) self.radioButtonHTML.selected = 1 self.add(self.panel)
def addMetadata(self, objectID, project, language): """ Add a JTable at the top of the object tab containing the metadata of the object presented in that tab. """ metadataPanel = JPanel() # TODO: Need to count protocols to set up Grid dimension metadataPanel.setLayout(GridLayout(3, 2)) projectLabel = JLabel("Project: ") projectValue = JLabel(project) languageLabel = JLabel("Language: ") languageValue = JLabel(language) # If language code is in the settings, then display name instead # of code for lang, code in self.languages.iteritems(): if code == language: languageValue.setText(lang) # TODO Protocols not yet in parsed object protocolsLabel = JLabel("ATF Protocols: ") protocolsBox = JComboBox(self.protocols) metadataPanel.add(projectLabel) metadataPanel.add(projectValue) metadataPanel.add(languageLabel) metadataPanel.add(languageValue) metadataPanel.add(protocolsLabel) metadataPanel.add(protocolsBox) # Add metadataPanel to object tab in main panel self.objectTabs[objectID].add(metadataPanel)
def main_menu(): """ Main menu which is always open Parameters ---------- None Returns ------- JFrame Main menu with JButtons calling other functions """ frame = JFrame("GMM Image Quality Calculator") nButtons = 4 frame.setSize(100 * nButtons, 300) frame.setLayout(GridLayout(nButtons, 1)) # Define JButtons get_user_params_JB = JButton("Load image and settings", actionPerformed = User_Dialogs.get_user_params) fit_GMM_JB = JButton("Fit Gaussian Mixture Model", actionPerformed = User_Dialogs.fit_GMM) show_as_RT_JB = JButton("Show SNR and CNR as Results Table", actionPerformed = User_Dialogs.show_as_RT) show_thresholded_JB = JButton("Show thresholded stack", actionPerformed = User_Dialogs.show_thresholded) # Add JButtons to frame frame.add(get_user_params_JB) frame.add(fit_GMM_JB) frame.add(show_as_RT_JB) frame.add(show_thresholded_JB) frame.setVisible(True)
def __init__(self, app): strings = app.strings self.setLayout(GridLayout(3, 2, 5, 5)) userLbl = JLabel(strings.getString("osmose_pref_username")) self.userTextField = JTextField(20) self.userTextField.setToolTipText( strings.getString("osmose_pref_username_tooltip")) levelLbl = JLabel(strings.getString("osmose_pref_level")) self.levels = ["1", "1,2", "1,2,3", "2", "3"] self.levelsCombo = JComboBox(self.levels) self.levelsCombo.setToolTipText( strings.getString("osmose_pref_level_tooltip")) limitLbl = JLabel(strings.getString("osmose_pref_limit")) self.limitTextField = JTextField(20) self.limitTextField.setToolTipText( strings.getString("osmose_pref_limit_tooltip")) self.add(userLbl) self.add(self.userTextField) self.add(levelLbl) self.add(self.levelsCombo) self.add(limitLbl) self.add(self.limitTextField)
def __init__(self, frame, chart, pingFun): JDialog(frame) self.setTitle('Chart Settings') self.setModal(True) self.pingFun = pingFun pane = self.getRootPane().getContentPane() pane.setLayout(GridLayout(7, 2)) pane.add(JLabel('Marker color')) self.markerPanel = self.createColorPanel(chart.markerColor, pane) pane.add(JLabel('Positive selection color')) self.posPanel = self.createColorPanel(chart.posColor, pane) pane.add(JLabel('Neutral color')) self.neuPanel = self.createColorPanel(chart.neuColor, pane) pane.add(JLabel('Balancing selection color ')) self.balPanel = self.createColorPanel(chart.balColor, pane) self.add(JLabel('Label candidate selected loci')) self.selLabel = JCheckBox() self.selLabel.setSelected(chart.labelSelected) self.add(self.selLabel) self.add(JLabel('Label candidate neutral loci')) self.neuLabel = JCheckBox() self.neuLabel.setSelected(chart.labelNeutral) self.add(self.neuLabel) change = JButton('Change') change.setActionCommand('Change') change.addActionListener(self) pane.add(change) exit = JButton('Exit') exit.setActionCommand('Exit') exit.addActionListener(self) pane.add(exit) self.pack()
def run(self): frame = JFrame('FrameMethods', size=(1000, 500), locationRelativeTo=None, layout=GridLayout(0, 2), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) self.one = self.parse(self.textFile('JFrame Methods.txt')) self.left = JTextArea(self.one, 20, 40, editable=0, font=Font('Courier', Font.PLAIN, 12)) frame.add(JScrollPane(self.left)) self.two = self.parse(self.textFile('JInternalFrame Methods.txt')) self.right = JTextArea(self.two, 20, 40, editable=0, font=Font('Courier', Font.PLAIN, 12)) frame.add(JScrollPane(self.right)) frame.setJMenuBar(self.makeMenu()) frame.setVisible(1)
def __init__(self, frame, what, entries, pingFun): JDialog(frame, what) self.frame = frame self.entries = entries self.pingFun = pingFun pane = self.getRootPane().getContentPane() self.ent_pane, self.ent_list, self.ent = self.createList(entries) pane.add(self.ent_pane, BorderLayout.WEST) actionPanel = JPanel() actionPanel.setLayout(GridLayout(20, 1)) self.text = JTextField(20) actionPanel.add(self.text) change = JButton('Change') change.setActionCommand('Change') change.addActionListener(self) actionPanel.add(change) actionPanel.add(JLabel('')) quit = JButton('Exit') quit.setActionCommand('Exit') quit.addActionListener(self) actionPanel.add(quit) actionPanel.add(JLabel('')) pane.add(actionPanel, BorderLayout.CENTER) self.pack()
def initResultados(self): diag = JFrame() self.lineas = list() self.areaResultados = JTextArea() numLineas = self.readResultados() panelResultados = JPanel() #panelResultados.setAutoscrolls(True) panelResultados.setBorder(BorderFactory.createEtchedBorder()) panelResultados.setLayout(GridLayout(0, 1)) pane = JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) pane.viewport.view = self.areaResultados #pane.getViewport().add(panelResultados) diag.setTitle("RESULTADOS OBTENIDOS") diag.setSize(1000, 450) diag.setLayout(BorderLayout()) diag.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) diag.setLocationRelativeTo(None) diag.setVisible(True) panelResultados.add(pane) diag.add(panelResultados, BorderLayout.CENTER)
def __init__(self): # Launches the login screen, initializes self.window, the primary frame self.done = False self.friendsData = [''] self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.chatHistory = {} self.usernameField = JTextField('guest', 20) self.status = JTextField(text='setStatus', editable=True) self.portNumber = "6666" self.IP = "127.0.0.1" self.window = swing.JFrame("Catchy Messenger Name") self.chatWindow = swing.JFrame() self.window.windowClosing = self.goodbye tempPanel = swing.JPanel() tempPanel = awt.BorderLayout() loginPage = JPanel(GridLayout(0, 2)) self.window.add(loginPage) loginPage.add(JLabel("Enter today's username", SwingConstants.RIGHT)) loginPage.add(self.usernameField) textIP = swing.JTextField(text=self.IP, editable=True) #chatHistory = swing.JTextArea(text = "new chat instance!", editable = False, lineWrap = True, size = (300,1)) loginButton = JButton('Log in', actionPerformed=self.login) loginPage.add(JLabel("")) loginPage.add(loginButton) loginPage.add(textIP) loginPage.add(JLabel("Change IP from default?", SwingConstants.LEFT)) loginPage.add(swing.JTextField(text=self.portNumber, editable=True)) loginPage.add(JLabel("Change Port from default?")) self.window.pack() self.window.visible = True return
def move_script_warning(): """Warn the user to move qat_script directory into Scripting Plugin directory """ scriptingPluginDir = PluginHandler.getPlugin("scripting").getPluginDir() pane = JPanel(GridLayout(3, 1, 5, 5)) warningTitle = "Warning: qat_script directory not found" pane.add( JLabel( "Please, move qat_script directory to the following location and start the script again:\n" )) defaultPathTextField = JTextField(scriptingPluginDir, editable=0, border=None, background=None) pane.add(defaultPathTextField) if not Desktop.isDesktopSupported(): JOptionPane.showMessageDialog(Main.parent, pane, warningTitle, JOptionPane.WARNING_MESSAGE) else: #add a button to open default path with the files manager pane.add(JLabel("Do you want to open this folder?")) options = ["No", "Yes"] answer = JOptionPane.showOptionDialog(Main.parent, pane, warningTitle, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, None, options, options[1]) if answer == 1: Desktop.getDesktop().open(File(scriptingPluginDir))
def initMenuPanel(self): buttonPanel = JPanel(GridLayout(10, 1, 5, 5)) addAdmin = JButton('Add Admin', actionPerformed=self.addAdminPanel) deleteAdmin = JButton('Delete Admin', actionPerformed=self.addDeleteAdminPanel) regUser = JButton('Register User', actionPerformed=self.addRegPanel) deRegUser = JButton('De-Register User', actionPerformed=self.addDeregisterPanel) emgBypass = JButton('Emergency Bypass', actionPerformed=self.addEmergencyPanel) viewLogs = JButton('View Logs', actionPerformed=self.addViewLogsPanel) login = JButton('Login', actionPerformed=self.addLoginForm) logout = JButton('Logout', actionPerformed=self.logout) quit = JButton('Quit', actionPerformed=dialog.quitApplicationMsg) about = JButton('About', actionPerformed=self.addDefaultPanel) # buttonPanel.setPreferredSize(Dimension(200,350)) # self.setPreferredSize(Dimension(250,250)) #add widgets buttonPanel.setBackground(Color.decode('#3d4968')) buttonPanel.add(addAdmin) buttonPanel.add(deleteAdmin) buttonPanel.add(regUser) buttonPanel.add(deRegUser) buttonPanel.add(emgBypass) buttonPanel.add(viewLogs) buttonPanel.add(login) buttonPanel.add(logout) buttonPanel.add(quit) buttonPanel.add(about) self.menuPanel.add(buttonPanel)
def __init__(self): # constructor #origing of coordinates self.coordx = 10 self.coordy = 10 #inintialize values self.Canvas = None #create panel (what is inside the GUI) self.panel = self.getContentPane() self.panel.setLayout(GridLayout(9, 2)) self.setTitle('Subdividing ROIs') #define buttons here: self.Dapi_files = DefaultListModel() mylist = JList(self.Dapi_files, valueChanged=self.open_dapi_image) #mylist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mylist.setLayoutOrientation(JList.VERTICAL) mylist.setVisibleRowCount(-1) listScroller1 = JScrollPane(mylist) listScroller1.setPreferredSize(Dimension(300, 80)) self.output_files = DefaultListModel() mylist2 = JList(self.output_files) #mylist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mylist2.setLayoutOrientation(JList.VERTICAL) mylist2.setVisibleRowCount(-1) listScroller2 = JScrollPane(mylist2) listScroller2.setPreferredSize(Dimension(300, 80)) quitButton = JButton("Quit", actionPerformed=self.quit) selectInputFolderButton = JButton("Select Input", actionPerformed=self.select_input) cubifyROIButton = JButton("Cubify ROI", actionPerformed=self.cubify_ROI) saveButton = JButton("Save ROIs", actionPerformed=self.save) summsaveButton = JButton("Save Summary", actionPerformed=self.save_summary) self.textfield1 = JTextField('500') #add buttons here self.panel.add(listScroller1) self.panel.add(listScroller2) self.panel.add(selectInputFolderButton) self.panel.add(Label("Adjust the size of the ROIs")) self.panel.add(self.textfield1) self.panel.add(cubifyROIButton) self.panel.add(saveButton) self.panel.add(summsaveButton) self.panel.add(quitButton) #self.panel.add(saveButton) #self.panel.add(Zslider) #other stuff to improve the look self.pack() # packs the frame self.setVisible(True) # shows the JFrame self.setLocation(self.coordx, self.coordy)
def __init__(self): JPanel() self.setLayout(GridLayout(1, 1)) #self.add(JLabel('SELWB 1.0')) self.statusLabel = JLabel('Idle', SwingConstants.CENTER) self.statusLabel.setBackground(Color.GREEN) self.statusLabel.setOpaque(True) self.add(self.statusLabel)
def __init__(self): self.setName('Jython Floating') self.setLayout(GridLayout(-1, 1)) self.add(JButton('Action 1')) self.add(JButton('Action 2')) self.add(JButton('Action 3')) self.setLocation(200, 200) self.setSize(100, 100)
def make_tree(self): print('make_tree') root = DefaultMutableTreeNode(self.exper.name) sb = br.SimilarityBuilder() for hseg in self.exper.hsegs(): all_file_dict = hseg.file_dict() all_file_dict.update(hseg.cell_file_dict()) all_file_dict.update(hseg.bin_file_dict()) sb.add_group(hseg.name, all_file_dict) simprofile, comparisons = sb.simprofile_comparison() sim_str = '' for val in simprofile: sim_str += str(val) + '\n' tp = JTextArea(sim_str) stp = JScrollPane() stp.getViewport().setView(tp) # # stp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); # stp.setPreferredSize(Dimension(250, 250)); # tp.setPreferredSize(Dimension(250, 250)) stp_panel = JPanel(BorderLayout()) stp_panel.add(tp, BorderLayout.CENTER) # self.add(stp_panel, 'grow') for hseg in self.exper.hsegs(): hseg_node = DefaultMutableTreeNode(hseg.name) root.add(hseg_node) if len(comparisons[hseg.name]) > 0: for definer, file_names in comparisons[hseg.name].items(): for file_name in file_names: node_str = definer + ': ' + file_name hseg_node.add(DefaultMutableTreeNode(node_str)) # for file_suf in hseg.file_dict() : # hseg_node.add(DefaultMutableTreeNode(file_suf)) self.tree = JTree(root) scrollPane = JScrollPane() scrollPane.getViewport().setView((self.tree)) # scrollPan # scrollPane.setPreferredSize(Dimension(300,250)) tree_panel = JPanel(BorderLayout()) tree_panel.add(scrollPane, BorderLayout.CENTER) combo_panel = JPanel(GridLayout(0, 2, 10, 10)) # combo_panel.setLayout(BoxLayout(combo_panel, BoxLayout.X_AXIS)) combo_panel.add(stp_panel) #, BorderLayout.LINE_START) combo_panel.add(tree_panel) #, BorderLayout.LINE_END) self.panel.add(combo_panel) # self.add(scrollPane, 'grow') self.revalidate()
def create_cont_panel (self,layout): titles = self._info['title'] self.compartment = swing.JPanel() self.compartment.setBorder(EtchedBorder(EtchedBorder.RAISED)) self.compartment.setLayout(BoxLayout(self.compartment, layout)) self.compartment.setLayout(GridLayout()) for title in titles: content = ContentView(title,self._contents[title]) self.compartment.add(content.fetch_content())
def __init__(self, message, options): self._selection_list = JList(options) self._selection_list.setVisibleRowCount(4) selected_message = JLabel(message) panel = JPanel(layout=GridLayout(2, 1)) panel.add(selected_message) panel.add(JScrollPane(self._selection_list)) pane = WrappedOptionPane(panel, PLAIN_MESSAGE, OK_CANCEL_OPTION) _SwingDialog.__init__(self, pane)
def callBoss(self, event): self.chatWindow = swing.JFrame("Incoming message!") newPanel = JPanel(GridLayout()) self.chatWindow.add(newPanel) newPanel.add(swing.JLabel("New message from The Boss. Accept?")) newPanel.add(JButton("Yes", actionPerformed=self.launchChatIn)) newPanel.add(JButton("No", actionPerformed=self.hide)) self.chatWindow.pack() self.chatWindow.show()