내 코드는 간단합니다 .......... 버튼을 눌러 패널의 모든 레이블에 텍스트를 설정하면 ("없음")/작업중인/모든 combobox 값 1로 // 작업이 없습니다. ArrayList amout
에서 7의 첫 번째 콤보 상자 만 설정하고 다른 값은 변경하지 않습니다!JComboBox의 setSelectedItem은 아무 작업도하지 않음
나는 만들지 않았다 modelcombobox!!
아마도 그 이유가 있습니다! 나도 몰라, 나는
내 코드는
public class Bill extends JPanel {
private JComboBox amount1=new JComboBox(new String[]{"-1","0","1", "2", "3", "4", "5", "6", "7","8","9"});
private JComboBox amount2=new JComboBox(new String[]{"-1","0","1", "2", "3", "4", "5", "6", "7","8","9"});
.........some other labels, combobox......
static ArrayList<JLabel> product=new ArrayList<JLabel>();
static ArrayList<JComboBox> amout=new ArrayList<JComboBox>();
static ArrayList<JLabel> pprice=new ArrayList<JLabel>();
static ArrayList<JLabel> prprice=new ArrayList<JLabel>();
.......ArrayList to hold labels and combobox.....
private JButton jbtView = new JButton("STAMPAJ RACUN");
//conctructor
public Bill(){
product.add(product1);
product.add(product2);
product.add(product3);
product.add(product4);
product.add(product5);
product.add(product6);
product.add(product7);
pprice.add(jlb1);
pprice.add(jlb3);
pprice.add(jlb5);
pprice.add(jlb7);
pprice.add(jlb9);
pprice.add(jlb11);
pprice.add(jlb13);
amout.add(amount1);
amout.add(amount2);
amout.add(amount3);
amout.add(amount4);
amout.add(amount5);
amout.add(amount6);
amout.add(amount7);
prprice.add(jlb2);
prprice.add(jlb4);
prprice.add(jlb6);
prprice.add(jlb8);
......add all labels, bomboboxes to ArrayList , make panels......//all works
jbtView.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
for (int j=0;j<Application.manu.size();j++){
if ((product.get(0).getText()).equals(Application.manu.get(j).getName()))//this is working
Application.manu.get(j).setCol(kol+Application.manu.get(j).getCol());//this is working
}
for (int j=0;j<prprice.size();j++){
prprice.get(j).setText("0.0");
}//this is working-set labels to ""
for (int i=0;i<product.size();i++){
product.get(i).setText("");//this is working-set labels to ""
}
for (int j=0;j<prprice.size();j++){
pprice.get(j).setText("");
}//this is working-set labels to ""
for (int j=0;j<amout.size();j++){
amout.get(j).setSelectedItem("1");//only first combobox set to value "1", others doesn't change
}
UKUPNO.setText("0.0"); // doesn't set to "0.0", doesn't change
사람이 이유는 알고 있나요 초보자입니까?
1) 더 빨리 도움을 받으려면 [SSCCE] (http://sscce.org/)를 게시하십시오. 2) * "아무도 그 이유를 알지 못합니까?"* 우리에게 큰소리를 질 필요가 없습니다. 키. –
이 코드에서 유감스럽게도 하드 코딩 된 항목이있는 JComboBox가있는 JFrame에 대해서 SSCCE, short, runnable, compilable을 게시 할 수 있습니다 ... – mKorbel
죄송합니다. 다시 미안 해요! – Mikky