请帮我看看我的简单测试用例:
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
,图标可以正确显示,但问题是用户必须点击小三角形才能查看菜单,而不是整个按钮,这对我来说不是很方便用户。
有人对此有什么想法吗?
任何评论或建议将不胜感激。