java swing 图片按钮的使用
1 JButton 图片和文字按钮的实现
JButton btn1 = new JButton("打开", new ImageIcon(ImageView.class.getResource("10.png"))) ;
btn1.setHorizontalTextPosition(SwingConstants.CENTER);
btn1.setVerticalTextPosition(SwingConstants.BOTTOM);
?
效果图 :

2 JButton 图片透明按钮的实现
setLayout(new FlowLayout(FlowLayout.RIGHT, 30, 0));
btn1.setIcon(UIConfig.getImgUrl("常用交易字.png"));
btn1.setRolloverIcon(UIConfig.getImgUrl("常用交易.png"));
btn1.setBorderPainted(false);
btn1.setFocusPainted(false);
btn1.setContentAreaFilled(false);
btn1.setFocusable(true);
btn1.setMargin(new Insets(0, 0, 0, 0));
btn1.setText("常用交易");
?
![]()
3JRadioButton 图片透明按钮的实现
JRadioButton radio = new JRadioButton(UIConfig.getImgUrl("常用交易字.png") );
radio.setContentAreaFilled(false);
radio.setRolloverIcon(UIConfig.getImgUrl("常用交易.png"));
radio.setSelectedIcon(UIConfig.getImgUrl("常用交易.png"));
![]()