我正在选择三个单选按钮(rd_7inch,rd_9inch和rd_10inch) 改变文本框的大小
的setSize()
public void setsize()
{
if(rd_7inch.isSelected())
{ jScrollPane2.setSize(300, 300);
txt_sysnp.setSize(220,250);
System.out.println("******** 7inch : "+rd_7inch.isSelected());
}else if(rd_9inch.isSelected())
{ jScrollPane2.setSize(300, 350);
txt_sysnp.setSize(300,350);
System.out.println("******** 9inch : "+rd_9inch.isSelected());
}else
{ jScrollPane2.setSize(400,400);
txt_sysnp.setSize(400,400);
System.out.println("******** 10inch : "+rd_10inch.isSelected());
}
}
private void Cmb_CategoryActionPerformed(java.awt.event.ActionEvent evt) {
try {
String catname = Cmb_Category.getSelectedItem().toString();
int catindex = Cmb_Category.getSelectedIndex();
System.out.println(catname);
System.out.println(catindex);
String catpos = Category_list_pages.get(catindex);
System.out.println(catpos);
int catpages = Integer.parseInt(catpos);
for (int i = 1; i <= catpages; i++) {
Cmb_pageno.addItem("page" + i);
}
} catch (Exception e) {
}
setsize();
}
我点击Jtext区域更改的两个组件大小时, 1个Jcombo框和 2个按钮,对于特定结果应该是不变的。
答案 0 :(得分:0)
我认为这是因为最后的else
语句,你没有指定别的(我的意思是你只需要用rd_10inch
来指定else语句),所以你用另一个来做组件
else if (rd_10inch.isSelected())/////////////////here i specify the else on the third button only
{ jScrollPane2.setSize(400,400);
txt_sysnp.setSize(400,400);
System.out.println("******** 10inch : "+rd_10inch.isSelected());
}