Java.use(better, Swing) #Color Chart, JRadioButton

記事一覧 Java.use(better, Swing) #color chart《Jython2.5》

Java の素描 〜 Swing 弾丸ツアー:時短プログラミング生活のすすめ 〜

《著》小粒ちゃん@湘南組《監修》タマゴ倶楽部

How to Use the Common Button API

■ アプリケーションを起動する
$ jython -i chart_swing.py 

  • タブ[JRadioButton]を選択します。

  • 〔右側〕項目(ボタン)を選択すると、
  • 〔左側〕パネルの色が変化します。

コードの解説

## ---------------------------------------- JRadioButton
from javax.swing import JRadioButton
from javax.swing import ButtonGroup

class Tab_JRadioButton(TabbedComponent):
    species = Color
    selector = "actionCommand"

    def __init__(self, command):
        self.container = self.create(command)
        
    def create(self, command):
        container = JPanel()
        group = ButtonGroup()

        for e in self.items:
            comp = JRadioButton(
                text = e,
                actionCommand = e,
                actionPerformed = command,
                )
            container.add(comp)
            group.add(comp)
        return container

》作業中です《


関連記事

  • INDEX《Swing》ButtonGroup
  • INDEX《Swing》JRadioButton

TOP

Last updated♪2009/10/17