我正在尝试为小命令行程序创建GUI。我在Jython中这样做,因为我对Python比Java更熟悉。
我的代码看起来像是:
self.f = JFrame("Demultiplex the data")
self.f.setSize(900, 500)
self.f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
#Create a Text Area
self.txtArea = JPanel(GridLayout(15,0))
self.txtArea.setPreferredSize(Dimension(150, 150))
self.textAreaForSheet = JTextField(30)
self.textAreaInputForFolder = JTextField(30)
self.textAreaOutPutFolder= JTextField(30)
self.txtArea.add(self.textAreaForSheet)
self.txtArea.add(self.textAreaInputForFolder)
self.txtArea.add(self.textAreaOutPutFolder)
#Create Buttons
self.buttonArea = JPanel(GridLayout(15,15))
self.buttonArea.setPreferredSize(Dimension(150, 150))
self.sampleSheetBtn = JButton("SampleSheet", actionPerformed=self.onClickSample)
self.runOutPutFolder = JButton("RUN Folder",actionPerformed=self.onClickRun)
self.DemultiplexOutPutFolder = JButton("Output Folder",actionPerformed=self.onClickOut)
self.buttonArea.add(self.sampleSheetBtn)
self.buttonArea.add(self.runOutPutFolder)
self.buttonArea.add(self.DemultiplexOutPutFolder)
#Create Check Boxes
self.CheckBox = JPanel(GridLayout(15,15))
self.buttonArea.setPreferredSize(Dimension(150, 150))
self.Iter1 = JCheckBox("01_0M_NY", True,)
self.Iter2 = JCheckBox("02_0M_N", True,)
self.Iter3 = JCheckBox("03_1M_NY", True,)
self.Iter4 = JCheckBox("04_1M_N", True,)
self.CheckBox.add(self.Iter1)
self.CheckBox.add(self.Iter2)
self.CheckBox.add(self.Iter3)
self.CheckBox.add(self.Iter4)
#Create a Run button "Demultiplex"
self.ExecutePanel = JPanel()
self.console=JTextArea(10,80)
self.RunBtn = JButton("Demultiplex",actionPerformed= self.performDemultiplex)
self.ExecutePanel.add(self.RunBtn)
self.ExecutePanel.add(self.console)
#Add everything to JFrame
self.f.add(self.txtArea, BorderLayout.CENTER)
self.f.add(self.buttonArea, BorderLayout.WEST)
self.f.add(self.CheckBox, BorderLayout.EAST)
self.f.add(self.ExecutePanel, BorderLayout.SOUTH)
但我想要控制台' self.console = JTextArea(10,80)'占据中心的主要区域。我是生物学家,请帮助我。
它现在的样子: