import javax.swing.JList; //导入方法依赖的package包/类
/**
* Creates an instance of this class.
* @param menu the menu that will be edited by the user
* @param indexOffset the offset of the editable area
* @param indexLimit the limit of the editable area
*/
public MenuManagementWindow(JMenu menu,int indexOffset,int indexLimit) {
this.setBounds(250,200,400,300);
this.setTitle("Menu management");
this.setResizable(false);
this.setModal(true);
this.managedMenu = menu;
this.emptyMenu = false;
this.offset = indexOffset;
this.limit = indexLimit;
itemsList = buildListFromComponents(
trimComponentsByOffsets(menu.getMenuComponents(),offset,limit)
);
removedItemsList = new JList();
removedItemsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
removedItemsList.setListData(removedItems = new Vector());
removedItemsList.setSize(100,200);
buildButtons();
JPanel okCancelPanel = new JPanel(new FlowLayout());
okCancelPanel.add(okButton);
okCancelPanel.add(cancelButton);
JPanel separatorButtonsPanel = new JPanel(new FlowLayout());
separatorButtonsPanel.setBorder(BorderFactory.createTitledBorder("Separator"));
separatorButtonsPanel.add(insertSeparatorButton);
separatorButtonsPanel.add(removeSeparatorButton);
JPanel itemsPanel = new JPanel();
itemsPanel.setLayout(new BoxLayout(itemsPanel,BoxLayout.Y_AXIS));
itemsPanel.setPreferredSize(new Dimension(175,200));
itemsPanel.add(new JLabel("Menu items:"));
JScrollPane listScroll = new JScrollPane(itemsList);
itemsPanel.add(listScroll);
itemsPanel.add(separatorButtonsPanel);
JPanel removedItemsPanel = new JPanel();
removedItemsPanel.setLayout(new BoxLayout(removedItemsPanel,BoxLayout.Y_AXIS));
removedItemsPanel.setPreferredSize(new Dimension(175,200));
removedItemsPanel.add(new JLabel("Removed items:"));
JScrollPane removedListScroll = new JScrollPane(removedItemsList);
removedItemsPanel.add(removedListScroll);
JPanel itemsButtonsPanel = new JPanel();
itemsButtonsPanel.setLayout(new BoxLayout(itemsButtonsPanel,BoxLayout.Y_AXIS));
itemsButtonsPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
itemsButtonsPanel.add(removeItemButton);
itemsButtonsPanel.add(retrieveButton);
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel,BoxLayout.X_AXIS));
centerPanel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
centerPanel.add(itemsPanel);
centerPanel.add(itemsButtonsPanel);
centerPanel.add(removedItemsPanel);
JPanel southPanel = new JPanel(new BorderLayout());
southPanel.add(okCancelPanel,BorderLayout.EAST);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(centerPanel,BorderLayout.CENTER);
this.getContentPane().add(southPanel,BorderLayout.SOUTH);
}