每当我在我的应用程序上键入文本时,都无法正确呈现。该图像显示文本的一部分未正确显示。我尝试将框架设置为在Frame类中打包或设置它可见,但我得到相同的结果?有人可以解释为什么会这样吗?
代码:
class Frame(JFrame):
def __init__(self):
self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
self.setSize(800,600)
self.setTitle("Startup Error Check")
self.setLayout(BorderLayout())
#West Layout (ServerList)
self.panel_serverlist = JPanel()
self.panel_serverlist.setLayout(BorderLayout())
self.panel_serverlist.setPreferredSize(Dimension(100, self.getHeight()))
self.border_serverlist = BorderFactory.createTitledBorder("Server list")
self.border_serverlist.setTitleJustification(TitledBorder.CENTER)
self.panel_serverlist.setBorder(self.border_serverlist)
self.textarea_serverlist = JTextArea()
self.scroll_serverlist = JScrollPane(self.textarea_serverlist)
self.panel_serverlist.add(self.scroll_serverlist, BorderLayout.CENTER)
#Center Layout
self.panel_results = JPanel()
self.panel_results.setLayout(BorderLayout())
self.border_results = BorderFactory.createTitledBorder("Results")
self.border_results.setTitleJustification(TitledBorder.CENTER)
self.panel_results.setBorder(self.border_results)
self.textarea_results = JTextArea()
self.textarea_results.setEditable(False)
self.textarea_results.setBackground(Color.WHITE);
self.scroll_results = JScrollPane(self.textarea_results)
self.panel_results.add(self.scroll_results, BorderLayout.CENTER)
#North Layout
self.panel_search = JPanel()
self.panel_search.setLayout(BorderLayout())
self.panel_search.setPreferredSize(Dimension(self.getWidth(), 100))
self.border_search = BorderFactory.createTitledBorder("Search")
self.border_search.setTitleJustification(TitledBorder.CENTER)
self.panel_search.setBorder(self.border_search)
self.textarea_search = JTextArea()
self.scroll_search = JScrollPane(self.textarea_search)
self.panel_search.add(self.scroll_search, BorderLayout.CENTER)
self.add(self.panel_search, BorderLayout.NORTH)
self.add(self.panel_serverlist, BorderLayout.WEST)
self.add(self.panel_results, BorderLayout.CENTER)
#Launcher
if __name__ == '__main__':
frame = Frame()
frame.visible = True