「課題」以下のプログラムを、画面からはみ出さないように、折り返して表示されるように変更せよ。
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class R9_2 extends JApplet{
private JLabel lb,lb2;
private JPanel pn;
private JRadioButton rb1, rb2, rb3, tmp;
private ButtonGroup bg;
int cou=0;
String iro=new String("");
public void init(){
Container cnt = getContentPane();
lb = new JLabel("カウンター:"); lb2= new JLabel("");
pn = new JPanel();
rb1 = new JRadioButton("青"); rb2 = new JRadioButton("赤"); rb3 = new JRadioButton("黄");
bg = new ButtonGroup();
bg.add(rb1); bg.add(rb2); bg.add(rb3); pn.add(rb1); pn.add(rb2); pn.add(rb3);
cnt.add(lb, BorderLayout.NORTH); cnt.add(lb2, BorderLayout.CENTER); cnt.add(pn, BorderLayout.SOUTH);
rb1.addActionListener(new SampleActionListener()); rb2.addActionListener(new SampleActionListener()); rb3.addActionListener(new SampleActionListener());
lb2.setHorizontalAlignment(JLabel.LEFT); lb2.setVerticalAlignment(JLabel.TOP);
}
class SampleActionListener implements ActionListener{
public void actionPerformed(ActionEvent e){
tmp = (JRadioButton) e.getSource();
cou++;
lb.setText("カウンター:"+cou+"kai"); lb2.setText(iro+tmp.getText()+cou);
iro=iro+tmp.getText()+cou;
}}}
「期限」 明後日まで
「Ver」特に指定はありません
「補足」 JTextareaでは無いようです。。