现在faf 为JTextArea ,zdy为JComboBox,run为测试JButton
JButton run = new JButton("测试")//JButton
faf = new JComboBox<Object>();//JTextArea
faf.setModel(new DefaultComboBoxModel<Object>(new String[] {}));
zdy = new JTextArea();//JComboBox
JTextArea 内容输出至 JComboBox
run.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//多选框
int dj=faf.getSelectedIndex()+1;
String nr=(String)faf.getSelectedItem();
System.out.println("你选中的是第"+dj+"项"+",内容是:"+nr);
//多文本
System.out.println(zdy.getText());//可以输出文本框
}
});
文本框的内容按行处理一下,应该是一行一项吧。
zdy.addItem(nr);
String[] lineString = faf.getText().split("\n");
for(int i=0;i<lineString.length;i++)
{