SOURCECODE |
How to... define a MenuSheet in a SalesPoint
Description:
Normally you display a SalesPoint in a new window. To add a menu to it, you simply have to redefine the method getDefaultMenuSheet of your instance of SalesPoint.
ToDo's:
- Create your own subclass of SalesPoint
- Redefine the method getDefaultMenuSheet() by creating your own MenuSheet
For more information about MenuSheets, take a look at "How to define a MenuSheet"
Uses:
SalesPoint MenuSheet
import sale.*;
import sale.events.*;
import sale.stdforms.*;
import data.events.*;
import data.ooimpl.*;
import log.*;
import log.stdforms.*;
import users.*;
import users.swing.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.io.*;
//...
1
public class Office extends SalesPoint {
2
//in order to define a new MenuSheet in a SalesPoint you have to
//overwrite the getDefaultMenuSheet method
public MenuSheet getDefaultMenuSheet() {
//create a new MenuSheet to be the horizontal menu
MenuSheet msMenu = new MenuSheet("office menu");
//create a new MenuSheet to be a submenu
MenuSheet msSubMenu = new MenuSheet("Maintenance");
//create a new MenuSheetItem to be displayed in the submenu above
MenuSheetItem msi1 = new MenuSheetItem ("Advance time", //the caption
new sale.Action() {
//the action to be performed when the MenuSheetItem is being chosen
public void doAction(SaleProcess p, SalesPoint sp) {
Shop.getTheShop().getTimer().goAhead();
}
});
//add the MenuSheetItem to the msSubMenu
msSubMenu.add(msi1);
// add the msSubMenu to the first MenuSheet
msMenu.add(msSubMenu);
//return the first MenuSheet
return msMenu;
}
}