コード例 #1
0
ファイル: GenericListener.java プロジェクト: q1051278389/HMCL
 protected boolean accept(Component jc) {
   if (extListener != null && extListener.accept(jc)) {
     return true;
   }
   if (!(jc instanceof JComponent)) {
     return false;
   }
   if (jc instanceof TableCellEditor
       || jc instanceof TreeCellEditor
       || SwingUtilities.getAncestorOfClass(JTable.class, jc) != null
       || SwingUtilities.getAncestorOfClass(JTree.class, jc) != null
       || SwingUtilities.getAncestorOfClass(JList.class, jc) != null) {
     // Don't listen to cell editors, we can end up listening to them
     // multiple times, and the tree/table model will give us the event
     // we need
     return false;
   }
   return isProbablyAContainer(jc)
       || jc instanceof JList
       || jc instanceof JComboBox
       || jc instanceof JTree
       || jc instanceof JToggleButton
       || // covers toggle, radio, checkbox
       jc instanceof JTextComponent
       || jc instanceof JColorChooser
       || jc instanceof JSpinner
       || jc instanceof JSlider;
 }
コード例 #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#getPreferredSize(javax
   * .swing.JComponent)
   */
  @Override
  public Dimension getPreferredSize(JComponent c) {
    AbstractCommandButton button = (AbstractCommandButton) c;
    SubstanceButtonShaper shaper = SubstanceCoreUtilities.getButtonShaper(button);

    Dimension superPref = super.getPreferredSize(button);
    if (superPref == null) return null;

    if (shaper == null) return superPref;

    // fix for issue 35 on Flamingo - do not enforce
    // min size on buttons in the ribbon
    // Additional fix - buttons with popup action should
    // not have min size enforced as well
    // Additional fix - buttons in popup menus and breadcrumb bars should
    // not have min size enforced
    if ((button.getDisplayState() == CommandButtonDisplayState.MEDIUM)
        && (SwingUtilities.getAncestorOfClass(AbstractRibbonBand.class, button) == null)
        && (SwingUtilities.getAncestorOfClass(JBreadcrumbBar.class, button) == null)
        && (SwingUtilities.getAncestorOfClass(JCommandPopupMenu.class, button) == null)) {
      JButton dummy = new JButton(button.getText(), button.getIcon());
      Dimension result = shaper.getPreferredSize(dummy, superPref);
      if (FlamingoUtilities.hasPopupAction(button)) {
        result.width = superPref.width;
      }
      return result;
    }
    return superPref;
  }
コード例 #3
0
ファイル: ComponentMover.java プロジェクト: ryankane/visgraph
  private void setupForDragging(MouseEvent e) {
    source.addMouseMotionListener(this);
    potentialDrag = true;

    // Determine the component that will ultimately be moved

    if (destinationComponent != null) {
      destination = destinationComponent;
    } else if (destinationClass == null) {
      destination = source;
    } else // forward events to destination component
    {
      destination = SwingUtilities.getAncestorOfClass(destinationClass, source);
    }

    pressed = e.getLocationOnScreen();
    location = destination.getLocation();

    if (changeCursor) {
      originalCursor = source.getCursor();
      source.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    }

    // Making sure autoscrolls is false will allow for smoother dragging of
    // individual components

    if (destination instanceof JComponent) {
      JComponent jc = (JComponent) destination;
      autoscrolls = jc.getAutoscrolls();
      jc.setAutoscrolls(false);
    }
  }
コード例 #4
0
 private void adjustWindowSize(ContainerWrapper paramContainerWrapper) {
   BoundSize localBoundSize1 = this.lc.getPackWidth();
   BoundSize localBoundSize2 = this.lc.getPackHeight();
   if ((localBoundSize1 == null) && (localBoundSize2 == null)) return;
   Window localWindow =
       (Window)
           SwingUtilities.getAncestorOfClass(
               Window.class, (Component) paramContainerWrapper.getComponent());
   if (localWindow == null) return;
   Dimension localDimension = localWindow.getPreferredSize();
   int i =
       constrain(
           checkParent(localWindow),
           localWindow.getWidth(),
           localDimension.width,
           localBoundSize1);
   int j =
       constrain(
           checkParent(localWindow),
           localWindow.getHeight(),
           localDimension.height,
           localBoundSize2);
   int k =
       Math.round(
           localWindow.getX()
               - (i - localWindow.getWidth()) * (1.0F - this.lc.getPackWidthAlign()));
   int m =
       Math.round(
           localWindow.getY()
               - (j - localWindow.getHeight()) * (1.0F - this.lc.getPackHeightAlign()));
   localWindow.setBounds(k, m, i, j);
 }
コード例 #5
0
    /**
     * This method is called when the mouse is pressed in the JToolBar. If the press doesn't occur
     * in a place where it causes the JToolBar to be dragged, it returns. Otherwise, it starts a
     * drag session.
     *
     * @param e The MouseEvent.
     */
    public void mousePressed(MouseEvent e) {
      if (!toolBar.isFloatable()) return;

      Point ssd = e.getPoint();
      Insets insets = toolBar.getInsets();

      // Verify that this click occurs in the top inset.
      if (toolBar.getOrientation() == SwingConstants.HORIZONTAL) {
        if (e.getX() > insets.left) return;
      } else {
        if (e.getY() > insets.top) return;
      }

      origin = new Point(0, 0);
      if (toolBar.isShowing()) SwingUtilities.convertPointToScreen(ssd, toolBar);

      if (!(SwingUtilities.getAncestorOfClass(Window.class, toolBar) instanceof UIResource))
        // Need to know who keeps the toolBar if it gets dragged back into it.
        origParent = toolBar.getParent();

      if (toolBar.isShowing()) SwingUtilities.convertPointToScreen(origin, toolBar);

      isDragging = true;

      if (dragWindow != null)
        dragWindow.setOffset(new Point(cachedBounds.width / 2, cachedBounds.height / 2));

      dragTo(e.getPoint(), origin);
    }
コード例 #6
0
 /** Find the first ancestor <em>not</em> descending from a {@link CellRendererPane}. */
 private Component findNonRendererAncestor(Component c) {
   Component ancestor = SwingUtilities.getAncestorOfClass(CellRendererPane.class, c);
   if (ancestor != null && ancestor != c && ancestor.getParent() != null) {
     c = findNonRendererAncestor(ancestor.getParent());
   }
   return c;
 }
コード例 #7
0
  /**
   * Shows the dialog. First a dialog must be constructed using one of the constructors of this
   * class. After that this method should be called to actually show the dialog. This method returns
   * either JOptionPane.OK_OPTION if the user wants to select his choices or
   * JOptionPane.CANCEL_OPTION if he does not want to.
   *
   * @param parent The parent frame of this dialog.
   * @return int The returnvalue, can be either JOptionPane.OK_OPTION or JOptionPane.CANCEL_OPTION
   */
  public int showDialog(Component parent) {
    Frame frame =
        parent instanceof Frame
            ? (Frame) parent
            : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);

    // String title = getUI().getDialogTitle(this);

    dialog = new JDialog(frame, title, true);
    Container contentPane = dialog.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(this, BorderLayout.CENTER);

    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            cancel();
          }
        });

    dialog.pack();
    dialog.setLocationRelativeTo(parent);

    dialog.setVisible(true);
    return returnValue;
  }
コード例 #8
0
  public boolean startDragging(MouseEvent mouseEvent) {

    // Get the mouse position and the component of the mouse event.
    Component mouseComponent = (Component) mouseEvent.getSource();
    int x = mouseEvent.getX();
    int y = mouseEvent.getY();

    // Reset the fields.
    reset();

    // Initialize the fields for docking.

    // Get the origin dock.
    originDock = (LeafDock) SwingUtilities.getAncestorOfClass(LeafDock.class, mouseComponent);
    if (originDock != null) {
      // Control that the dragged dockable belongs to this dock.
      if (originDock.containsDockable(draggedDockable)) {
        // Calculate the dockable offset.
        dockableOffset.setLocation(x, y);
        dockableOffset =
            SwingUtilities.convertPoint(
                mouseComponent, dockableOffset, draggedDockable.getContent());

        // We could find a dockable for dragging.
        return true;
      }
    }

    // We could not find a dockable for dragging.
    return false;
  }
コード例 #9
0
 private void btnAbrir_actionPerformed(ActionEvent e) {
   GeopistaMap selectMap = (GeopistaMap) lstListaMapas.getSelectedValue();
   mapGeopistaSelected = selectMap;
   if (selectMap != null) {
     JDialog dialogPadre = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, this);
     dialogPadre.setVisible(false);
   }
 }
コード例 #10
0
ファイル: JSheet.java プロジェクト: karlvr/Quaqua
  /**
   * Displays a custom file chooser sheet with a custom approve button.
   *
   * @param chooser the chooser
   * @param parent the parent component of the dialog; can be {@code null}
   * @param approveButtonText the text of the {@code ApproveButton}
   * @param listener The listener for SheetEvents.
   */
  public static void showSheet(
      final JFileChooser chooser,
      Component parent,
      String approveButtonText,
      SheetListener listener) {
    if (approveButtonText != null) {
      chooser.setApproveButtonText(approveButtonText);
      chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
    }

    // Begin Create Dialog
    Frame frame =
        parent instanceof Frame
            ? (Frame) parent
            : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);

    String title = chooser.getUI().getDialogTitle(chooser);
    chooser.getAccessibleContext().setAccessibleDescription(title);

    final JSheet sheet = new JSheet(frame);
    sheet.addSheetListener(listener);

    Container contentPane = sheet.getContentPane();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(chooser, BorderLayout.CENTER);
    // End Create Dialog

    final ActionListener actionListener =
        new ActionListener() {

          public void actionPerformed(ActionEvent evt) {
            int option;
            if (evt.getActionCommand().equals("ApproveSelection")) {
              option = JFileChooser.APPROVE_OPTION;
            } else {
              option = JFileChooser.CANCEL_OPTION;
            }
            sheet.hide();
            sheet.fireOptionSelected(chooser, option);
            chooser.removeActionListener(this);
          }
        };
    chooser.addActionListener(actionListener);
    sheet.addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            sheet.fireOptionSelected(chooser, JFileChooser.CANCEL_OPTION);
            chooser.removeActionListener(actionListener);
          }
        });
    chooser.rescanCurrentDirectory();
    sheet.pack();
    sheet.show();
    sheet.toFront();
  }
コード例 #11
0
ファイル: MartComponent.java プロジェクト: JoeCarlson/BioMart
 private void clearOthers(Component comp) {
   Container c =
       SwingUtilities.getAncestorOfClass(
           org.biomart.configurator.view.idwViews.McViewSourceGroup.class, comp);
   if (c != null) {
     McViewSourceGroup sgview = (McViewSourceGroup) c;
     sgview.unselectOthers((MartComponent) comp);
   }
 }
コード例 #12
0
  /**
   * Folgendes Szenario. Der User gibt einen Wert in eine {@link JComboBox} ein, und bevor er auf
   * eine andere {@link Component} klickt, klickt er in der Toolbar auf "Speichern".<br>
   * Der eingegebene Wert ist in diesem Moment noch nicht als <em>selectedItem</em> in der {@link
   * JComboBox} festgelegt worden.<br>
   * Aus diesem Grund prŸft diese Methode, ob momentan eine {@link JComboBox} den Fokus hat, und
   * speichert ggf. den eingegebenen Wert dieser als <em>selectedItem</em><br>
   * <br>
   * WŸrde dies nicht gemacht, ginge der eingegebene Wert aus dem Szenario oben verloren.
   *
   * @see #editTags(ArrayList)
   */
  private void saveValueFromEditedComboBox() {
    Component currentFocusOwner =
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    Component combo = SwingUtilities.getAncestorOfClass(JComboBox.class, currentFocusOwner);

    if (combo != null && combo instanceof JComboBox) {
      JComboBox comboBox = (JComboBox) combo;
      comboBox.setSelectedItem(comboBox.getEditor().getItem());
    }
  }
コード例 #13
0
ファイル: SearchFile.java プロジェクト: rfabbri/scilab
 /** Try to add a SciNotes toolbar */
 public void changeToolBar() {
   SwingScilabWindow win =
       (SwingScilabWindow) SwingUtilities.getAncestorOfClass(SwingScilabWindow.class, this);
   Set<SwingScilabTab> set = win.getDockingPort().getDockables();
   for (SwingScilabTab tab : set) {
     if (tab == editor) {
       addToolBar(editor.getToolBar());
       break;
     }
   }
 }
コード例 #14
0
ファイル: PSEGantt.java プロジェクト: rpgoldman/europa-pso
  protected MouseEvent getTranslatedMouseEvent(MouseEvent evt, Rectangle cellRect) {
    Point location = new Point(evt.getPoint());
    location.translate(-cellRect.x, -cellRect.y);

    Component component =
        SwingUtilities.getAncestorOfClass(GanttTable.class, evt.getComponent()) != null
            ? SwingUtilities.getAncestorOfClass(GanttTable.class, evt.getComponent())
            : evt.getComponent();
    return location != null
        ? new MouseEvent(
            component,
            evt.getID(),
            evt.getWhen(),
            evt.getModifiers(),
            location.x,
            location.y,
            evt.getClickCount(),
            evt.isPopupTrigger(),
            evt.getButton())
        : null;
  }
コード例 #15
0
ファイル: ExportTaskDlg.java プロジェクト: projectestac/jclic
  private void cancelBtnActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cancelBtnActionPerformed

    if (sw != null) {
      ProjectFileUtils.interrupt = true;
    } else {
      JDialog myDlg = (JDialog) javax.swing.SwingUtilities.getAncestorOfClass(JDialog.class, this);
      if (myDlg != null) {
        myDlg.dispose();
      }
    }
  } // GEN-LAST:event_cancelBtnActionPerformed
コード例 #16
0
  public static boolean isShowingMinimizedRibbonInPopup(JRibbon ribbon) {
    List<PopupPanelManager.PopupInfo> popups = PopupPanelManager.defaultManager().getShownPath();
    if (popups.size() == 0) return false;

    for (PopupPanelManager.PopupInfo popup : popups) {
      JComponent originator = popup.getPopupOriginator();
      if (originator instanceof JRibbonTaskToggleButton) {
        return (ribbon == SwingUtilities.getAncestorOfClass(JRibbon.class, originator));
      }
    }
    return false;
  }
コード例 #17
0
 /**
  * Execute the code in example
  *
  * @param pre the preformatted Element containing Scilab's code
  */
 public void execExample(Element pre) {
   String code = getCode(pre);
   try {
     ScilabConsole.getConsole()
         .getAsSimpleConsole()
         .sendCommandsToScilab(code, true /* display */, false /* store in history */);
   } catch (NoClassDefFoundError e) {
     ScilabModalDialog.show(
         (SimpleTab) SwingUtilities.getAncestorOfClass(SimpleTab.class, x),
         Messages.gettext("Feature not available in this mode..."));
   }
 }
コード例 #18
0
  protected void handleAdd() {
    // don't need to check the section as only the direct imports can be added
    OntologyImportWizard wizard =
        new OntologyImportWizard(
            (Frame) SwingUtilities.getAncestorOfClass(Frame.class, editorKit.getWorkspace()),
            editorKit);
    int ret = wizard.showModalDialog();

    if (ret == Wizard.FINISH_RETURN_CODE) {
      AddImportsStrategy strategy = new AddImportsStrategy(editorKit, ont, wizard.getImports());
      strategy.addImports();
    }
  }
コード例 #19
0
ファイル: ErrorDialog.java プロジェクト: jbudynk/starjava
  /**
   * Pops up a modal dialogue displaying information about an error with an additional multi-line
   * message.
   *
   * @param parent parent component
   * @param title title of the dialogue window
   * @param error the throwable to be displayed
   * @param message an array of one or more strings providing additional information about the
   *     error. Each string is displayed as a line.
   */
  public static void showError(Component parent, String title, Throwable error, String[] message) {

    /* Get the Frame ancestor of the parent component. */
    Frame fparent =
        parent == null ? null : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);

    /* Construct and prepare the error dialogue. */
    JDialog dialog = new ErrorDialog(fparent, error, title, message);
    dialog.setLocationRelativeTo(parent);
    dialog.pack();

    /* Display the modal dialogue. */
    dialog.show();
  }
コード例 #20
0
ファイル: MartComponent.java プロジェクト: JoeCarlson/BioMart
  public List<Mart> getSelectedComponents() {
    List<Mart> martList = new ArrayList<Mart>();
    Container container =
        SwingUtilities.getAncestorOfClass(
            org.biomart.configurator.view.idwViews.McViewSourceGroup.class, this);
    if (container != null) {
      McViewSourceGroup sgview = (McViewSourceGroup) container;

      for (Mart mart : sgview.getSelectedMarts()) {
        martList.add(mart);
      }
    }
    return martList;
  }
コード例 #21
0
ファイル: PluginUtils.java プロジェクト: sefirot/androidStuff
 public void requestFocus() {
   TextArea textArea = getTextArea();
   if (textArea != null) textArea.requestFocus();
   else if (widget != null) {
     Component component = findFirstComponent(widget, FOCUS, Constraint.AMONG);
     if (component != null) {
       component.requestFocusInWindow();
       diag_println(
           DIAG_OFF,
           "focus",
           identity(component),
           identity(SwingUtilities.getAncestorOfClass(EditPane.class, component)));
     }
   }
 }
コード例 #22
0
  private String getActiveGraphicsDeviceName(Component component) {
    String deviceName = null;
    JFrame rootJFrame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, component);

    if (rootJFrame != null) {
      deviceName = rootJFrame.getGraphicsConfiguration().getDevice().getIDstring();
      if (deviceName != null) {
        deviceName = deviceName.replace("\\", "");
      }
    } else {
      logger.warn(
          "Cannot get root JFrame from SwingUtilities.getAncestorOfClass() for multi-monitor support.");
    }
    return deviceName;
  }
コード例 #23
0
  private void getPathButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_getPathButtonActionPerformed
    JFileChooser newPath = new JFileChooser();
    newPath.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    // FileDialog newPath = new FileDialog(
    //        (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, this));
    newPath.showOpenDialog((JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, this));

    if (newPath.getSelectedFile() != null) {
      if (newPath.getSelectedFile().isDirectory()) {
        parser.setMonitoredPath(newPath.getSelectedFile().getPath());
      }
    }
  } // GEN-LAST:event_getPathButtonActionPerformed
コード例 #24
0
  public static JDialog createDialog(JComponent parent, OWLEditorKit editorKit) {
    JFrame parentFrame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, parent);
    final JDialog dialog = new JDialog(parentFrame, "Search", Dialog.ModalityType.MODELESS);

    final SearchDialogPanel searchDialogPanel = new SearchDialogPanel(editorKit);
    searchDialogPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));

    searchDialogPanel
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "CLOSE_DIALOG");
    searchDialogPanel
        .getActionMap()
        .put(
            "CLOSE_DIALOG",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
              }
            });

    searchDialogPanel
        .getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "CLOSE_DIALOG_WITH_ENTER");
    searchDialogPanel
        .getActionMap()
        .put(
            "CLOSE_DIALOG_WITH_ENTER",
            new AbstractAction() {
              @Override
              public void actionPerformed(ActionEvent e) {
                dialog.setVisible(false);
                searchDialogPanel.selectEntity();
              }
            });

    dialog.setContentPane(searchDialogPanel);
    dialog.setResizable(true);
    dialog.pack();
    dialog.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowOpened(WindowEvent e) {
            searchDialogPanel.searchField.requestFocusInWindow();
          }
        });
    return dialog;
  }
コード例 #25
0
ファイル: RiskUIUtil.java プロジェクト: hernol/ConuWar
  public static Frame findParentFrame(Container c) {

    return (Frame) javax.swing.SwingUtilities.getAncestorOfClass(Frame.class, c);

    /*
    		// this does not work as using the method setContentPane makes this method return null

    		while(c != null) {

    			if (c instanceof Frame) return (Frame)c;

    			c = c.getParent();
    		}
    		return (Frame)null;
    */
  }
コード例 #26
0
  /**
   * 在对话框中显示成功订单的卖家联系方式面板。
   *
   * @param parent 面板拥有者
   */
  public void showDialog(Component parent) {
    Frame owner = null;
    if (parent instanceof Frame) {
      owner = (Frame) parent;
    } else {
      owner = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
    }

    dialog = new JDialog(owner, true);
    dialog.add(this);
    dialog.setTitle("显示成功订单的卖家信息");
    dialog.setResizable(false);
    dialog.pack();
    dialog.setLocationRelativeTo(parent);
    dialog.setVisible(true);
  }
コード例 #27
0
  @Override
  protected int getMaxAvailablePageWidth(
      JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Insets insets = list.getInsets(); // OWLFrameList.ITEM_BORDER.getBorderInsets();
    int componentWidth = list.getWidth();
    JViewport vp = (JViewport) SwingUtilities.getAncestorOfClass(JViewport.class, list);
    if (vp != null) {
      componentWidth = vp.getViewRect().width;
    }

    return componentWidth
        - list.getInsets().left
        - list.getInsets().right
        - insets.left
        + insets.right
        - 20;
  }
コード例 #28
0
  private boolean canWriteFile(String name) {
    if (new File(name).exists()) {
      Component c = DrawerVisitor.getVisitor(figureUID).getComponent();
      Window parentWindow = (Window) SwingUtilities.getAncestorOfClass(Window.class, c);
      int actionDialog =
          JOptionPane.showConfirmDialog(
              parentWindow,
              Messages.gettext("Replace existing file?"),
              Messages.gettext("File already exists"),
              JOptionPane.YES_NO_OPTION);
      if (actionDialog != JOptionPane.YES_OPTION) {
        return false;
      }
    }

    return true;
  }
コード例 #29
0
  /**
   * Show tracker
   *
   * @param parent GUI parent widget
   */
  public final void show(final Component parent) {
    Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);

    dialog.getContentPane().setLayout(new BorderLayout());

    label = new JLabel(START_HTML + labelText + END_HTML);

    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new BorderLayout());
    labelPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    labelPanel.add(label, BorderLayout.CENTER);

    dialog.getContentPane().add(labelPanel, BorderLayout.CENTER);

    dialog.pack();
    Windows.centerOnScreen(dialog);
    dialog.show();
  }
コード例 #30
0
    void validate() {
      Container parent =
          SwingUtilities.getAncestorOfClass(CollapsiblePaneContainer.class, JXCollapsiblePane.this);
      if (parent != null) {
        parent = ((CollapsiblePaneContainer) parent).getValidatingContainer();
      } else {
        parent = getParent();
      }

      if (parent != null) {
        if (parent instanceof JComponent) {
          ((JComponent) parent).revalidate();
        } else {
          parent.invalidate();
        }
        parent.doLayout();
        parent.repaint();
      }
    }