How to show button's Icon and Text in ToolBar?

View: New views
2 Messages — Rating Filter:   Alert me  

How to show button's Icon and Text in ToolBar?

by jimlaren :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey all,
I need to show button's Icon and Text in ToolBar,the icon is above the
text,I tried my best to achieve this effect,but I failed.
tks in advance !


jim

Re: How to show button's Icon and Text in ToolBar?

by jimlaren :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

sorry for the duplicate messages.
I have found the solution!Share it
public class DataManageAction extends AbstractAction implements Presenter.Toolbar{
//etc
   public Component getToolbarPresenter() {
        return new ToolBarButton(this);
    }

}
public class ToolBarButton extends JButton {

    public ToolBarButton(Action a) {
        super(a);
        setBorder(javax.swing.BorderFactory.createEmptyBorder(2, 2, 2, 2));
        setMargin(new java.awt.Insets(2, 2, 2, 2));
        setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    }
}


jimlaren wrote:
Hey all,
I need to show button's Icon and Text in ToolBar,the icon is above the
text,I tried my best to achieve this effect,but I failed.
tks in advance !


jim