public void stateChanged(ChangeEvent e) {
      JTabbedPane tabPane = (JTabbedPane) e.getSource();
      tabPane.revalidate();
      tabPane.repaint();

      if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) {
        int index = tabPane.getSelectedIndex();
        if (index < rects.length && index != -1) {
          tabScroller.tabPanel.scrollRectToVisible(rects[index]);
        }
      }
    }
 public void refresh(List<PanelCollection> collections) {
   panelCollections.clear();
   panelCollections.addAll(collections);
   int tabCount = tb_collection.getTabCount();
   for (int i = 0; i < tabCount; i++) {
     tb_collection.removeTabAt(0);
   }
   for (PanelCollection panelCollection : panelCollections) {
     tb_collection.addTab(panelCollection.getCollectionName(), panelCollection);
     tb_collection.revalidate();
   }
   this.revalidate();
 }
  /**
   * Creates the JPanels for displaying the <code>MapdustBug</code> details.
   *
   * @param mapdustBug The <code>MapdustBug</code> object
   */
  private void createPanels(MapdustBug mapdustBug) {
    /* details panel */
    if (cmpDetails == null) {
      detailsPanel = new MapdustBugDetailsPanel(mapdustBug);
      cmpDetails =
          ComponentUtil.createJScrollPane(detailsPanel, getBounds(), getBackground(), true, true);
      cmpDetails.setPreferredSize(new Dimension(100, 100));
      cmpDetails.setName("Bug Details");
    } else {
      detailsPanel.updateComponents(mapdustBug);
    }

    /* address panel */
    Address address = mapdustBug != null ? mapdustBug.getAddress() : null;
    LatLon coordinates = mapdustBug != null ? mapdustBug.getLatLon() : null;
    if (cmpAddress == null) {
      addressPanel = new MapdustAddressPanel(address, coordinates);
      cmpAddress =
          ComponentUtil.createJScrollPane(addressPanel, getBounds(), getBackground(), true, true);
      cmpAddress.setName("Address");
      cmpAddress.setPreferredSize(new Dimension(100, 100));
    } else {
      addressPanel.updateComponents(address, coordinates);
    }

    /* description panel */
    String description = mapdustBug != null ? mapdustBug.getDescription() : "";
    if (descriptionPanel == null) {
      descriptionPanel = new MapdustDescriptionPanel(description);
    } else {
      descriptionPanel.updateComponents(description);
    }

    /* comments panel */
    MapdustComment[] comments =
        mapdustBug != null ? mapdustBug.getComments() : new MapdustComment[0];
    if (commentsPanel == null) {
      commentsPanel = new MapdustCommentsPanel(comments);
    } else {
      commentsPanel.updateComponents(comments);
      mainPanel.setTitleAt(3, commentsPanel.getName());
    }

    /* the help panel */
    if (helpPanel == null) {
      helpPanel = new MapdustHelpPanel();
    }

    /* creates the main panel */
    if (mainPanel == null) {
      mainPanel = new JTabbedPane();
      mainPanel.setIgnoreRepaint(true);
      mainPanel.add(cmpDetails, 0);
      mainPanel.add(cmpAddress, 1);
      mainPanel.add(descriptionPanel, 2);
      mainPanel.add(commentsPanel, 3);
      mainPanel.add(helpPanel);
      add(mainPanel, BorderLayout.CENTER);
    } else {
      mainPanel.revalidate();
    }
  }
Example #4
0
package com.ufgov.zc.client.component.ui;