1
我的Jython GUI有問題。我需要讓文本字段出現。我相信我遇到了佈局問題,但我不確定如何在Jython中創建新的FlowLayout。Jython GUI的問題
#!/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()
太棒了!謝謝。 –