Esempio n. 1
0
  /** Restore the original state of the Component */
  @Override
  public void mouseReleased(MouseEvent e) {
    if (!potentialDrag) {
      return;
    }

    source.removeMouseMotionListener(this);
    potentialDrag = false;

    if (changeCursor) {
      source.setCursor(originalCursor);
    }

    if (destination instanceof JComponent) {
      ((JComponent) destination).setAutoscrolls(autoscrolls);
    }

    // Layout the components on the parent container

    if (autoLayout) {
      if (destination instanceof JComponent) {
        ((JComponent) destination).revalidate();
      } else {
        destination.validate();
      }
    }
  }
  public static void updateComponentTreeUI(final Component component) {
    updateComponentTreeUILevel(component);

    component.invalidate();
    component.validate();
    component.repaint();
  }
  public boolean editCellAt(int index, EventObject e) {
    if (editor != null && !editor.stopCellEditing()) return false;

    if (index < 0 || index >= getModel().getSize()) return false;

    if (!isCellEditable(index)) return false;

    if (editorRemover == null) {
      KeyboardFocusManager fm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      editorRemover = new CellEditorRemover(fm);
      fm.addPropertyChangeListener("permanentFocusOwner", editorRemover); // NOI18N
    }

    if (editor != null && editor.isCellEditable(e)) {
      editorComp = prepareEditor(index);
      if (editorComp == null) {
        removeEditor();
        return false;
      }
      editorComp.setBounds(getCellBounds(index, index));
      add(editorComp);
      editorComp.validate();

      editingIndex = index;
      editor.addCellEditorListener(this);

      return true;
    }
    return false;
  }
 protected void paintEditor(Graphics g) {
   Component component = grid.getEditorComponent();
   if (component == null) {
     return;
   }
   Rectangle cellBounds = grid.getCellBounds(grid.getEditingRow(), grid.getEditingColumn());
   component.setBounds(cellBounds);
   component.validate();
   component.requestFocus();
 }
Esempio n. 5
0
    /** Resets the <code>Popup</code> to an initial state. */
    void reset(Component owner, Component contents, int ownerX, int ownerY) {
      super.reset(owner, contents, ownerX, ownerY);

      Component component = getComponent();

      component.setLocation(ownerX, ownerY);
      rootPane.getContentPane().add(contents, BorderLayout.CENTER);
      contents.invalidate();
      component.validate();
      pack();
    }
 /** Computes the preferred size on the EventDispatcherThread. */
 public void run() {
   retval = null;
   try {
     final Component component = getComponent();
     if (component instanceof Window == false && isOwnPeerConnected() == false) {
       peerSupply.pack();
       contentPane.add(component);
       contentPane.validate();
       component.validate();
     } else if (isOwnPeerConnected()) {
       retval = component.getSize();
       return;
     } else {
       component.validate();
     }
     retval = component.getPreferredSize();
   } finally {
     cleanUp();
   }
 }
 public static void setRelativeBounds(
     @NotNull Component parent,
     @NotNull Rectangle bounds,
     @NotNull Component child,
     @NotNull Container validationParent) {
   validationParent.add(parent);
   parent.setBounds(bounds);
   parent.validate();
   child.setLocation(SwingUtilities.convertPoint(child, 0, 0, parent));
   validationParent.remove(parent);
 }
Esempio n. 8
0
  /**
   * Reshaping function. This is called in case the size of the render canvas changed and the
   * viewport needs to be fixed.
   *
   * @param drawable the drawable object used to change the viewport
   * @param x the x offset to the old location
   * @param y the y offset to the old location
   * @param width the new width of the canvas
   * @param height the new height of the canvas
   */
  @Override
  public void reshape(
      final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {
    setupViewport(drawable);
    ((RenderDisplayJOGL) Graphics.getInstance().getRenderDisplay()).setDisplaySize(width, height);

    final Component parent = getParent();
    if (parent != null) {
      parent.validate();
    }
  }
  public void paintEditor(Graphics g) {
    Component component = grid.getEditorComponent();
    if (component == null) {
      return;
    }

    int editingRow = grid.getEditingRow();
    int editingColumn = grid.getEditingColumn();
    Rectangle cellBounds = grid.getCellBounds(editingRow, editingColumn);
    component.setBounds(cellBounds);
    component.validate();
    component.requestFocus();
  }
  protected void changeBounds(
      Component source, int direction, Rectangle bounds, Point pressed, Point current) {
    //  Start with original locaton and size

    int x = bounds.x;
    int y = bounds.y;
    int width = bounds.width;
    int height = bounds.height;

    //  Resizing the West or North border affects the size and location

    if (WEST == (direction & WEST)) {
      int drag = getDragDistance(pressed.x, current.x, snapSize.width);
      int maximum = Math.min(width + x, maximumSize.width);
      drag = getDragBounded(drag, snapSize.width, width, minimumSize.width, maximum);

      x -= drag;
      width += drag;
    }

    if (NORTH == (direction & NORTH)) {
      int drag = getDragDistance(pressed.y, current.y, snapSize.height);
      int maximum = Math.min(height + y, maximumSize.height);
      drag = getDragBounded(drag, snapSize.height, height, minimumSize.height, maximum);

      y -= drag;
      height += drag;
    }

    //  Resizing the East or South border only affects the size

    if (EAST == (direction & EAST)) {
      int drag = getDragDistance(current.x, pressed.x, snapSize.width);
      Dimension boundingSize = getBoundingSize(source);
      int maximum = Math.min(boundingSize.width - x, maximumSize.width);
      drag = getDragBounded(drag, snapSize.width, width, minimumSize.width, maximum);
      width += drag;
    }

    if (SOUTH == (direction & SOUTH)) {
      int drag = getDragDistance(current.y, pressed.y, snapSize.height);
      Dimension boundingSize = getBoundingSize(source);
      int maximum = Math.min(boundingSize.height - y, maximumSize.height);
      drag = getDragBounded(drag, snapSize.height, height, minimumSize.height, maximum);
      height += drag;
    }

    source.setBounds(x, y, width, height);
    source.validate();
  }
Esempio n. 11
0
  /**
   * DOCUMENT ME!
   *
   * @param context DOCUMENT ME!
   * @param g DOCUMENT ME!
   * @param cellRect DOCUMENT ME!
   * @param row DOCUMENT ME!
   * @param column DOCUMENT ME!
   */
  private void paintCell(
      SeaGlassContext context, Graphics g, Rectangle cellRect, int row, int column) {
    if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) {
      Component component = table.getEditorComponent();

      component.setBounds(cellRect);
      component.validate();
    } else {
      TableCellRenderer renderer = table.getCellRenderer(row, column);
      Component component = table.prepareRenderer(renderer, row, column);

      rendererPane.paintComponent(
          g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true);
    }
  }
Esempio n. 12
0
  public void setCellPanelSize(int cellPanelSize) {
    //		cellPanelSize = cellPanelSize < 25 ? 25 : cellPanelSize;
    Dimension size = new Dimension(cellPanelSize, cellPanelSize);

    for (Component square : getComponents()) {
      JComponent squareJc = (JComponent) square;
      for (Component component : squareJc.getComponents()) {
        component.setPreferredSize(size);
        component.setSize(size);
        component.validate();
      }
    }
    JRootPane rootPane = getRootPane();
    if (rootPane != null) {
      ((JFrame) rootPane.getParent()).pack();
    }
  }
Esempio n. 13
0
 public static void resizeColumnToFit(
     PRManFrame frame, TableView view, TableColumn tc, JTable table) {
   int cIdx = table.getColumnModel().getColumnIndex(tc.getIdentifier());
   int width = tc.getWidth();
   for (int iCnt = 0; iCnt < table.getRowCount(); iCnt++) {
     if (view == null
         || !frame.isDescriptionResourceRow(view.tableModel.getModelRowForIndex(iCnt))) {
       Component comp =
           table
               .getCellRenderer(iCnt, cIdx)
               .getTableCellRendererComponent(
                   table, table.getValueAt(iCnt, cIdx), true, false, iCnt, cIdx);
       comp.invalidate();
       comp.validate();
       int cpw = comp.getPreferredSize().width;
       width = Math.max(width, cpw);
     }
   }
   tc.setPreferredWidth(width);
 }
Esempio n. 14
0
 private void paintCell(
     SynthContext context, Graphics g, Rectangle cellRect, int row, int column) {
   if (table.isEditing() && table.getEditingRow() == row && table.getEditingColumn() == column) {
     Component component = table.getEditorComponent();
     component.setBounds(cellRect);
     component.validate();
   } else {
     TableCellRenderer renderer = table.getCellRenderer(row, column);
     Component component = table.prepareRenderer(renderer, row, column);
     Color b = component.getBackground();
     if ((b == null
             || b instanceof UIResource
             || component instanceof SynthBooleanTableCellRenderer)
         && !table.isCellSelected(row, column)) {
       if (alternateColor != null && row % 2 != 0) {
         component.setBackground(alternateColor);
       }
     }
     rendererPane.paintComponent(
         g, component, table, cellRect.x, cellRect.y, cellRect.width, cellRect.height, true);
   }
 }
Esempio n. 15
0
  /*
   *  Restores this frame's bounds and visibility
   *  from its class preferences.
   *
   *  @see	#restoreAllFromPrefs()
   */
  private void restoreFromPrefs() {
    String sizeVal = classPrefs.get(KEY_SIZE, null);
    String locVal = classPrefs.get(KEY_LOCATION, null);
    String visiVal = classPrefs.get(KEY_VISIBLE, null);
    Rectangle r = c.getBounds();
    //		Insets		i		= getInsets();

    // System.err.println( "this "+getClass().getName()+ " visi = "+visiVal );

    Dimension dim = stringToDimension(sizeVal);
    if ((dim == null) || alwaysPackSize()) {
      pack();
      dim = c.getSize();
    }

    r.setSize(dim);
    Point p = stringToPoint(locVal);
    if (p != null) {
      r.setLocation(p);
      c.setBounds(r);
    } else {
      c.setSize(dim);
      final Point2D prefLoc = getPreferredLocation();
      wh.place(this, (float) prefLoc.getX(), (float) prefLoc.getY());
      //			if( shouldBeCentered() ) setLocationRelativeTo( null );
    }
    c.invalidate();
    //		if( alwaysPackSize() ) {
    //			pack();
    //		} else {
    c.validate();
    //		}
    //		lim.queue( this );
    if ((visiVal != null) && restoreVisibility()) {
      setVisible(new Boolean(visiVal).booleanValue());
    }
  }
    /** Draws the drawable. */
    public void run() {
      try {
        final Component component = getComponent();
        if (component instanceof Window) {
          final Window w = (Window) component;
          w.validate();
        } else if (isOwnPeerConnected()) {
          final Window w = ComponentDrawable.getWindowAncestor(component);
          if (w != null) {
            w.validate();
          }
        } else {
          peerSupply.pack();
          contentPane.add(component);
        }

        component.setBounds(
            (int) area.getX(), (int) area.getY(), (int) area.getWidth(), (int) area.getHeight());
        component.validate();
        component.paint(graphics);
      } finally {
        cleanUp();
      }
    }
 public void validate() {
   window.validate();
 }
 public static void validate(Component component) {
   if (component instanceof JComponent) ((JComponent) component).revalidate();
   else component.validate();
 }