Я новичок в GWT, поэтому, пожалуйста, помогите мне. У меня возникла проблема с GWT
MenuBar
, как getSelectedItem()
.
Вот мой код:
public class Menu extends Composite implements Command {
private MenuBar menu = new MenuBar();
private MenuBar priceMgt = new MenuBar( true );
private MenuBar salesReport = new MenuBar( true );
// and a lot more menubars
private String[] itemPriceMgt = {
"Manage Price List", "Print Product Pricing", "Price Proof List"
};
private String[] itemSalesReport = {
"Sales Transaction List", "Cashier Report", "Media Tender Report",
"Sales Report by Employee", "Sales Warranty Tracking", "Sales Report by Product",
"Sales Summary by Branch", "Sales Summary by Product", "Sales Summary by Period",
"Product Movement Analysis", "Sales Comparison",
"Sales Book", "Download eSales"
};
public Menu() {
loadMenu();
}
private void loadMenu() {
addSubMenuItem( priceMgt, itemPriceMgt );
addSubMenuItem( salesReport, itemSalesReport );
menu.addItem( "Home", false, this );
menu.addItem( "Price Management", priceMgt );
menu.addItem( "Sales Report", salesReport );
menu.addItem( "Logout", false, this );
initWidget( menu );
}
private void addSubMenuItem( MenuBar menubar, String[] list ) {
for( int i = 0; i < list.length; i++ ) {
menubar.addItem( list[i], this );
}
}
public void execute() {
// load the selected module
// by getting the selected item
// i can't use menu.getSelectedItem() - it's protected.
// when i extend this class to MenuBar, adding Item says ambiguous
// method addItem(String,Command) for MenuBar
// how can I get the items being selected/clicked?
}
}
Другие могут сказать, что это бесполезный пост, но я действительно не знаю, как это понять. пожалуйста, помогите мне. Заранее спасибо.