请帮我看看我的简单测试用例:
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.widgets.menu.IMenuButton;
import com.smartgwt.client.widgets.menu.Menu;
import com.smartgwt.client.widgets.menu.MenuItem;
public class Test1 implements EntryPoint {
private static final int MENU_ICON_SIZE = 50;
public void onModuleLoad() {
// HLayout buttonLayout = new HLayout();
//
// IconButton printButton = new IconButton("");
// printButton.setIcon("icons/16/print.png");
// printButton.setIconSize(MENU_ICON_SIZE);
Menu menu = new Menu();
menu.setShowShadow(true);
menu.setShadowDepth(10);
MenuItem csvExport = new MenuItem("Export as CSV",
"icons/16/csv_file.png");
MenuItem pdfExport = new MenuItem("Export as PDF",
"icons/16/pdf_file.png");
MenuItem xmlExport = new MenuItem("Export as XML",
"icons/16/xml_file.png");
MenuItem jsonExport = new MenuItem("Export as JSON",
"icons/16/json_file.png");
csvExport.setIconWidth(MENU_ICON_SIZE);
pdfExport.setIconWidth(MENU_ICON_SIZE);
xmlExport.setIconWidth(MENU_ICON_SIZE);
jsonExport.setIconWidth(MENU_ICON_SIZE);
csvExport.setIconHeight(MENU_ICON_SIZE);
pdfExport.setIconHeight(MENU_ICON_SIZE);
xmlExport.setIconHeight(MENU_ICON_SIZE);
jsonExport.setIconHeight(MENU_ICON_SIZE);
menu.setItems(csvExport, pdfExport, xmlExport, jsonExport);
IMenuButton exportButton = new IMenuButton("", menu);
exportButton.setIcon("icons/16/download.png");
exportButton.setIconSize(MENU_ICON_SIZE);
// buttonLayout.setMembers(printButton, exportButton);
//
// RootPanel.get().add(buttonLayout);
RootPanel.get().add(exportButton);
}
}
该图标未显示,我只能看到菜单下拉菜单的小三角形。同样的问题也适用MenuButton
。
但是,如果我从 切换IMenuButton
到IconMenuButton
,图标可以正确显示,但问题是用户必须单击小三角形才能查看菜单,而不是整个按钮,这对我来说不太友好。
有人对此有想法吗?
任何意见或建议将不胜感激。