code: public void setTriggerContainer (JComponent comp, JPanel content, boolean collapsed)
      {
          // these are our only two components.
          add(comp);
          add(_content = content);
  
          // When the content is shown, make sure it's scrolled visible
          _content.addComponentListener(new ComponentAdapter() {
              @Override public void componentShown (ComponentEvent event)
              {
                  // we can't do it just yet, the content doesn't know its size
                  EventQueue.invokeLater(new Runnable() {
                      public void run () {
                          // The content is offset a bit from the trigger
                          // but we want the trigger to show up, so we add
                          // in point 0,0
                          Rectangle r = _content.getBounds();
                          r.add(0, 0);
                          scrollRectToVisible(r);
                      }
                  });
              }
          });
  
          // and start us out not showing
          setCollapsed(collapsed);
      }
docs: Set a component which contains the trigger button.