例題で学ぶ Jython/Swing フレームワーク #3: JPanel

前の記事記事一覧次の記事
Java.use(better, Jython=Swing);


例題で学ぶ Jython/Swing フレームワーク Episode#03

JPanel


《関連記事》

■ 事例:モジュールを起動する

$ jython2.5.0 -i swing_tips.py 
    
0: step00 -- from javax.swing import JFrame 1: step01 -- from javax.swing import JButton 2: step02 -- class TIPS() 3: step03 -- from javax.swing import JPanel 4: step04 -- def command(self, *args) 5: step05 -- from random import randint 6: step06 -- from javax.swing import JList 7: step07 -- from javax.swing import DefaultListModel 8: step08 -- from javax.swing import JScrollPane 9: step09 -- class Command(object) 10: step10 -- def addElement(self, obj) 11: step11 -- from java.awt import GridLayout 12: step12 -- from javax.swing import JLabel >>> do(3)
次のようなウィンドウが現れます。
  • ウィンドウ内の最上部に、ボタンが配置されます。

■ 事例:コードの解説

from javax.swing import JPanel

def step03():
    """from javax.swing import JPanel"""

    class TIPS():
        def __init__(self, master):
            panel = JPanel()     #1:
            master.add(panel)
            comp = JButton()
            panel.add(comp)
        
    ## ----------------------------------------
    frame = JFrame(
        title = "swing: step03",
        size = (180,100),
        )
    TIPS(master=frame)
    frame.visible = True
》こちらに移動中です《
■ #1: JPanel を配置する
            panel = JPanel()     #1:
。 ↑TOP
Last updated♪2009/09/30