final JComboBox comboBox_1 = new JComboBox(); comboBox_1.addItem("默认背景"); comboBox_1.addItem("卡通背景"); comboBox_1.addItem("美女背景"); comboBox_1.addItem("帅哥背景");
comboBox_1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // TODO Auto-generated method stub if (e.getStateChange()==ItemEvent.SELECTED) { if (comboBox_1.getSelectedIndex()==1) {
在事件处理中去修改背景图片。
comboBox_1.addItem("默认背景");
comboBox_1.addItem("卡通背景");
comboBox_1.addItem("美女背景");
comboBox_1.addItem("帅哥背景");
comboBox_1.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
if (e.getStateChange()==ItemEvent.SELECTED) {
if (comboBox_1.getSelectedIndex()==1) {
}else if(comboBox_1.getSelectedIndex()==2) {
}
}
}
});
comboBox_1.setBounds(136, 11, 100, 30);
frame.getContentPane().add(comboBox_1);
JLabel lblNewLabe2 = new JLabel();
ImageIcon ii=new ImageIcon("img/1.jpg");
Image img=ii.getImage();
ii.setImage(ii.getImage().getScaledInstance(950, 550,Image.SCALE_DEFAULT));
lblNewLabe2.setIcon(ii);
lblNewLabe2.setBounds(0, 0,944,527);
frame.getContentPane().add(lblNewLabe2);
谢谢 我是用的seing 而且我是获取的下标 但是在那个if 里面该怎么写, 最下面的我背景该怎么放