// 検索ウィンドウ import java.io.*; import java.lang.*; import javax.swing.*; public class SearchBox extends JFrame { public SearchBox() { getContentPane().setLayout(null); JLabel msg = new JLabel(); msg.setText("検索する文字列: "); msg.setBounds(5, 5, 100, 25); getContentPane().add(msg); // 「検索する文字列」の右側の入力欄 JTextField nameText = new JTextField(); nameText.setBounds(110, 5, 240, 25); getContentPane().add(nameText); JButton okBut = new JButton(); okBut.setText("次を検索"); okBut.setBounds(355, 5, 100, 25); getContentPane().add(okBut); JButton cancelBut = new JButton(); cancelBut.setText("キャンセル"); cancelBut.setBounds(355, 35, 100, 25); getContentPane().add(cancelBut); JCheckBox wordCheck = new JCheckBox(); wordCheck.setText("単語単位で検索する"); wordCheck.setBounds(5, 45, 150, 25); getContentPane().add(wordCheck); JCheckBox letterCheck = new JCheckBox(); letterCheck.setText("大文字と小文字を区別する"); letterCheck.setBounds(5, 70, 200, 25); getContentPane().add(letterCheck); JLabel directLabel = new JLabel(); directLabel.setText("検索する方向"); directLabel.setBounds(210, 35, 150, 25); getContentPane().add(directLabel); // ButtonGroup で JRadioButton をグループ化 ButtonGroup group = new ButtonGroup(); JRadioButton upRadio = new JRadioButton(); upRadio.setText("上へ"); upRadio.setBounds(225, 60, 70, 25); getContentPane().add(upRadio); group.add(upRadio); JRadioButton downRadio = new JRadioButton(); downRadio.setText("下へ"); downRadio.setBounds(290, 60, 70, 25); getContentPane().add(downRadio); group.add(downRadio); setTitle("検索"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(470, 130); setVisible(true); } public static void main(String[] args) { new SearchBox(); } }