Google Tag Manager

2021/10/31

Add the JTabbedPane tab component to the JSplitPane and layout in different sizes

Code

public void tabComponentResized(ComponentEvent e, JTabbedPane tabs) {
  Component c = e.getComponent();
  if (c.equals(tabs.getSelectedComponent())) {
    Dimension d = c.getPreferredSize();
    if (isTopBottomTabPlacement(tabs.getTabPlacement())) {
      d.height = splitPane.getDividerLocation() - tabAreaSize.height;
    } else {
      d.width = splitPane.getDividerLocation() - tabAreaSize.width;
    }
    c.setPreferredSize(d);
  }
}

public void updateDividerLocation(JTabbedPane tabs) {
  Component c = tabs.getSelectedComponent();
  int loc; 
  if (isTopBottomTabPlacement(tabs.getTabPlacement())) {
    loc = c.getPreferredSize().height + tabAreaSize.height);
  } else {
    loc = c.getPreferredSize().width + tabAreaSize.width;
  }
  splitPane.setDividerLocation(loc);
}

References

No comments:

Post a Comment