/**
   * This method adds a component to the JSplitPane. The constraints object is a string that
   * identifies where this component should go. If the constraints is not a known one, it will throw
   * an IllegalArgumentException. The valid constraints are LEFT, TOP, RIGHT, BOTTOM and DIVIDER.
   *
   * @param comp The component to add.
   * @param constraints The constraints string to use.
   * @param index Where to place to component in the list of components.
   * @throws IllegalArgumentException When the constraints is not a known identifier.
   */
  protected void addImpl(Component comp, Object constraints, int index) {
    int left = 0;
    int right = 1;
    int div = 2;
    int place;
    if (constraints == null) {
      if (leftComponent == null) constraints = LEFT;
      else if (rightComponent == null) constraints = RIGHT;
    }

    if (constraints instanceof String) {
      String placement = (String) constraints;

      if (placement.equals(BOTTOM) || placement.equals(RIGHT)) {
        if (rightComponent != null) remove(rightComponent);
        rightComponent = comp;
      } else if (placement.equals(LEFT) || placement.equals(TOP)) {
        if (leftComponent != null) remove(leftComponent);
        leftComponent = comp;
      } else if (placement.equals(DIVIDER)) constraints = null;
      else throw new IllegalArgumentException("Constraints is not a known identifier.");

      // If no dividerLocation has been set, then we need to trigger an
      // initial layout.
      if (getDividerLocation() != -1) resetToPreferredSizes();

      super.addImpl(comp, constraints, index);
    }
  }
  @Override
  protected void addImpl(final Component comp, Object constraints, int index) {
    super.addImpl(comp, constraints, index);

    comp.addMouseMotionListener(
        new MouseAdapter() {
          @Override
          public void mouseMoved(MouseEvent e) {
            lastScreen =
                componentToImage(comp, new Rectangle(0, 0, comp.getWidth(), comp.getHeight()));
          }
        });
    comp.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            setBorder(new ResizableBorder(6));
          }

          @Override
          public void mousePressed(MouseEvent e) {
            mouse = true;
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            mouse = false;
          }
        });
  }
Exemple #3
0
  /**
   * Overridden to enforce the position of the glass component as the zero child.
   *
   * @param comp the component to be enhanced
   * @param constraints the constraints to be respected
   * @param index the index
   */
  protected void addImpl(Component comp, Object constraints, int index) {
    super.addImpl(comp, constraints, index);

    /// We are making sure the glassPane is on top.
    if (glassPane != null && glassPane.getParent() == this && getComponent(0) != glassPane) {
      add(glassPane, 0);
    }
  }
  /**
   * This method overrides Container's addImpl method. If a JButton is added, it is disabled.
   *
   * @param component The Component to add.
   * @param constraints The Constraints placed on the component.
   * @param index The index to place the Component at.
   */
  protected void addImpl(Component component, Object constraints, int index) {
    // XXX: Sun says disable button but test cases show otherwise.
    super.addImpl(component, constraints, index);

    // if we added a Swing Button then adjust this a little
    if (component instanceof AbstractButton) {
      AbstractButton b = (AbstractButton) component;
      b.setRolloverEnabled(rollover);
    }
  } // addImpl()