我的 Jython GUI 有问题。我需要使文本字段出现。我相信我遇到了布局问题,但我不确定如何在 Jython 中创建新的 FlowLayout。
#!/usr/bin/env jython
# Created by Joe Castleberry
# 2013
# Imports
from javax.swing import *
from java.awt import *
class Window:
def __init__(self):
# Global variables
global frame
global label
global container
global text
# Definition of global variables
frame = JFrame("Joe's first Java program")
label = JLabel("Hello World!", JLabel.CENTER)
container = JPanel()
text = JTextField(10)
def builder(self):
# Building container
container.setLayout(None)
container.setBackground(Color.BLACK)
# Building frame
frame.getContentPane().add(container) # Adding Container to JFrame
frame.setSize(300,300)
frame.setVisible(True)
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
# Adding components to container
container.add(text)
a = Window()
a.builder()