#author("2019-11-28T18:18:33+09:00","ocha","ocha")
[[Lecture]]

*Java プログラミング入門 [#kd7c750b]


このページは、学部2年生向け授業である、「マルチメディアプログラミング実習」
のために用意しました。

(Wikiの仕様で大文字小文字が混在した英単語に疑問符?が追加されるところがありますが、無視してください。)


**第13章 様々なコンポーネントとレイアウト [#qb662dcc]

***項目チェック機能を備えたアプリケーション [#x0af6860]

 import java.awt.*;
 import javax.swing.*;
 import java.awt.event.*;
 
 public class JRadioButtonSample extends JFrame {
 
	public void initialize() {
        this.setTitle("Radio Buttons");
 
	    JPanel panel1 = new JPanel();
	    JPanel panel2 = new JPanel();
 
        JRadioButton radio1 = new JRadioButton("for here");
        JRadioButton radio2 = new JRadioButton("to go");
        ButtonGroup group = new ButtonGroup();
        group.add(radio1);
        group.add(radio2);
    
        panel1.setLayout(new GridLayout(2,1));
        panel2.setLayout(new GridLayout(3,1));
    
        panel1.add(radio1);
        panel1.add(radio2);
    
        panel2.add(new JCheckBox("with Drink"));
        panel2.add(new JCheckBox("with Salad"));
        panel2.add(new JCheckBox("with Cake"));
    
        Container container = this.getContentPane();
        container.add(panel1,BorderLayout.WEST);
        container.add(panel2,BorderLayout.EAST);
        
        this.pack();
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
 
    public static void main (String args[]) {
        JRadioButtonSample jrbs = new JRadioButtonSample();
        jrbs.initialize();
    }
    
}


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS