将图标添加到gwt中的按钮 [英] Adding icons to an button in gwt
问题描述
我有按钮,并且希望 在其中为其设置一个图标以及文本 。他们是没有财产添加图标按钮像在smartGwt ..任何想法如何实现它,请帮助。
有很多方法可以达到这个目的。
方法1:简单方法
背景图片通过代码。
myButton.getElement()。getStyle()。setBackgroundImage(path);
2:另一个简单的方法
设置您自己的html
myButton.setHtml(传递html字符串);
方式3:简单但给予更多控制
myButton.addStylename (buttonStyle)
使用css来设置它的样式
.buttonStyle {
颜色:红色;
}
方式4:根据我的最佳方式
创建您自己的拆分按钮,将其围绕 flowpanel 或 horizontalPanel ,将图片作为您的第一个小部件和按钮作为您的另一个小部件。这使您可以更好地控制图像和按钮。您可以在图像和按钮上使用您的点击处理程序,并且可以单独对其中的每一个进行设置。
i have button and want to set an icon to it along with the text inside it. their is no property to add icon to button like in smartGwt .. any idea how to achieve it please help.
There are many ways of achieving this.
Way 1 : Easy way
Just set the background image via code.
myButton.getElement().getStyle().setBackgroundImage("path");
Way 2: Another easy way
Set your own html
myButton.setHtml("Pass the html string");
Way 3: Easy but gives more control
myButton.addStylename("buttonStyle")
Use css to style this
.buttonStyle{
color : red;
}
Way 4: Best way according to me
Create your own split button wrapping it around a flowpanel or horizontalPanel, with image as your first widget and button as your another widget. This gives you additional control on image and as well as button. You can have your click handler on image as well as button and you can style each one of them individually.
这篇关于将图标添加到gwt中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!