コード例 #1
0
  private void rebuildTabs() {

    rebuildingTabs = true;
    for (int i = 0; i < tabbedPane.getTabCount(); i++) {
      SheetPanel sheetPanel = (SheetPanel) tabbedPane.getComponentAt(i);
      sheetPanel.dispose();
    }
    tabbedPane.removeAll();
    Workbook workbook = manager.getWorkbook();
    for (Sheet sheet : workbook.getSheets()) {
      if (!sheet.isHidden()) {
        SheetPanel sheetPanel = new SheetPanel(manager, sheet);
        tabbedPane.add(sheet.getName(), sheetPanel);
      }
    }
    rebuildingTabs = false;
  }
コード例 #2
0
  public WorkbookPanel(WorkbookManager workbookManager) {
    this.manager = workbookManager;
    tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
    setLayout(new BorderLayout());
    add(tabbedPane, BorderLayout.CENTER);
    workbookChangeListener = new WorkbookChangeListenerImpl();
    manager.getWorkbook().addChangeListener(workbookChangeListener);
    rebuildTabs();
    tabbedPane.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            transmitSelectionToModel();
          }
        });
    workbookManager
        .getSelectionModel()
        .addCellSelectionListener(
            new CellSelectionListener() {
              public void selectionChanged(Range range) {
                updateSelectionFromModel(range);
              }
            });
    workbookManager.addListener(
        new AbstractWorkbookManagerListener() {

          @Override
          public void workbookCreated() {
            rebuildTabs();
            transmitSelectionToModel();
          }

          @Override
          public void workbookLoaded() {
            rebuildTabs();
            transmitSelectionToModel();
          }
        });
  }