小弟在ComboBox上想加个按钮,挡住右边的图,用this.add(button,-1),为什么总加在左边,换了几个参数也不行啊。帮帮忙急急急public void setComboBoxState()
{
imageSource = new String[5];
imageSource[0] = "/image/ContentTextoperate_date_click.gif";
imageSource[1] = "/image/ContentTextoperate_date_default.gif";
imageSource[2] = "/image/ContentTextoperate_date_disable.gif";
imageSource[3] = "/image/ContentTextoperate_date_hover.gif";
imageSource[4] = "/image/ContentTextoperate_date_visited.gif";
imageMatch = new ImageIcon[5];
imageMatch[0] = new ImageIcon(getClass().getResource(imageSource[0].toString()));
imageMatch[1] = new ImageIcon(getClass().getResource(imageSource[1].toString()));
imageMatch[2] = new ImageIcon(getClass().getResource(imageSource[2].toString()));
imageMatch[3] = new ImageIcon(getClass().getResource(imageSource[3].toString()));
imageMatch[4] = new ImageIcon(getClass().getResource(imageSource[4].toString()));
this.setSize(280, 19);
Width = 280 ;
Hight = 19 ;
this.setComboBoxBorder(true);
this.setBackground(new Color(255,255,255));
this.setForeground(new Color(255,255,255));
JButton button = new JButton();
button.setIcon(imageMatch[1]);
button.setPressedIcon(imageMatch[0]);
button.setDisabledIcon(imageMatch[2]);
button.setRolloverIcon(imageMatch[3]);
button.setSelectedIcon(imageMatch[4]);
button.setSize(imageMatch[0].getIconWidth()+1, imageMatch[0].getIconHeight()+1);
// this.add(button,-1);
}
{
imageSource = new String[5];
imageSource[0] = "/image/ContentTextoperate_date_click.gif";
imageSource[1] = "/image/ContentTextoperate_date_default.gif";
imageSource[2] = "/image/ContentTextoperate_date_disable.gif";
imageSource[3] = "/image/ContentTextoperate_date_hover.gif";
imageSource[4] = "/image/ContentTextoperate_date_visited.gif";
imageMatch = new ImageIcon[5];
imageMatch[0] = new ImageIcon(getClass().getResource(imageSource[0].toString()));
imageMatch[1] = new ImageIcon(getClass().getResource(imageSource[1].toString()));
imageMatch[2] = new ImageIcon(getClass().getResource(imageSource[2].toString()));
imageMatch[3] = new ImageIcon(getClass().getResource(imageSource[3].toString()));
imageMatch[4] = new ImageIcon(getClass().getResource(imageSource[4].toString()));
this.setSize(280, 19);
Width = 280 ;
Hight = 19 ;
this.setComboBoxBorder(true);
this.setBackground(new Color(255,255,255));
this.setForeground(new Color(255,255,255));
JButton button = new JButton();
button.setIcon(imageMatch[1]);
button.setPressedIcon(imageMatch[0]);
button.setDisabledIcon(imageMatch[2]);
button.setRolloverIcon(imageMatch[3]);
button.setSelectedIcon(imageMatch[4]);
button.setSize(imageMatch[0].getIconWidth()+1, imageMatch[0].getIconHeight()+1);
// this.add(button,-1);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货