我為了實現:

RolloverButton ib1=new RolloverButton("房產管理",MyPluginRes.getImageIcon(MyPluginRes.ESTATERES));
ib1.setVerticalTextPosition(SwingConstants.BOTTOM); //必須設置文字樹直方向位置
ib1.setHorizontalTextPosition(SwingConstants.CENTER);//必須設置文字水平方向位置
摘自: http://blog.chinaunix.net/uid-22375044-id-3086641.html
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"));