【问题标题】:store string from 3 jcombobox's in one jtextfield将来自 3 个 jcombobox 的字符串存储在一个 jtextfield 中
【发布时间】:2018-10-02 09:21:06
【问题描述】:
目前点击jButton时,jComboBox1 Text会出现在jTextArea1中,但是jComboBox2中的文本不会出现。关于如何让两个组合框中的文本出现在 1 个文本字段中的任何指示?
私人无效 jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jTextArea1.setText(jComboBox1.getSelectedItem().toString());
jTextArea1.setText(jComboBox2.getSelectedItem().toString());
【问题讨论】:
标签:
string
jtextfield
jcombobox
【解决方案1】:
我想通了。考虑到总共有大约 15 个组合框,不确定这是否是最有效的,但就是这样。
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String severity1;
String s1 = s1ComboBox.getSelectedItem() + " ";
String timing1;
String t1 = t1ComboBox.getSelectedItem() + " ";
jTextField2.setText(s1 + t1);
如果有人知道更有效的方法,请告诉我。