java按钮背景图片
为什么背景图片把文字挤到旁边去了呀?不是“背景”图片吗?在线等!!谢啦!菜鸟所以麻烦解释详细些。附部分代码:jbs=newJButton[24];ImageIconima...
为什么背景图片把文字挤到旁边去了呀?不是“背景”图片吗?在线等!!谢啦!菜鸟所以麻烦解释详细些。
附部分代码:
jbs=new JButton[24];
ImageIcon image = new ImageIcon("1.gif");
ImageIcon image2 = new ImageIcon("2.gif");
String[] strs={"1","2","3","4","5","6","7","8","9","0","+/-",".","/","sqrt","㏑","*","sin","←","-","cos","CE","+","y^2","="};
for(int i=0; i<12; i++){
jbs[i]=new JButton(strs[i],image);
jbs[i].setContentAreaFilled(false);
jbs[i].setMargin(new Insets(0,0,0,0));
jbs[i].setBorderPainted(false);
jbs[i].setBorder(BorderFactory.createRaisedBevelBorder());
jbs[i].setFont(new java.awt.Font("华文行楷", 3, 20));
}
for(int i=12; i<24; i++){
jbs[i]=new JButton(strs[i],image2);
jbs[i].setContentAreaFilled(false);
jbs[i].setMargin(new Insets(0,0,0,0));
jbs[i].setBorderPainted(false);
jbs[i].setBorder(BorderFactory.createRaisedBevelBorder());
jbs[i].setFont(new java.awt.Font("华文行楷", 3, 20));
} 展开
附部分代码:
jbs=new JButton[24];
ImageIcon image = new ImageIcon("1.gif");
ImageIcon image2 = new ImageIcon("2.gif");
String[] strs={"1","2","3","4","5","6","7","8","9","0","+/-",".","/","sqrt","㏑","*","sin","←","-","cos","CE","+","y^2","="};
for(int i=0; i<12; i++){
jbs[i]=new JButton(strs[i],image);
jbs[i].setContentAreaFilled(false);
jbs[i].setMargin(new Insets(0,0,0,0));
jbs[i].setBorderPainted(false);
jbs[i].setBorder(BorderFactory.createRaisedBevelBorder());
jbs[i].setFont(new java.awt.Font("华文行楷", 3, 20));
}
for(int i=12; i<24; i++){
jbs[i]=new JButton(strs[i],image2);
jbs[i].setContentAreaFilled(false);
jbs[i].setMargin(new Insets(0,0,0,0));
jbs[i].setBorderPainted(false);
jbs[i].setBorder(BorderFactory.createRaisedBevelBorder());
jbs[i].setFont(new java.awt.Font("华文行楷", 3, 20));
} 展开
3个回答
展开全部
这个不是背景图片,是按钮上的图标。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
记不清楚了,加这试一下
jsb[i].setVerticalTextPosition(JButton.CENTER);
jsb[i].setHorizontalTextPosition(JButton.CENTER);
jsb[i].setVerticalTextPosition(JButton.CENTER);
jsb[i].setHorizontalTextPosition(JButton.CENTER);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询