Пример #1
0
 public void mouseDragged(MouseEvent e) {
   Point newPos = e.getPoint();
   SwingUtilities.convertPointToScreen(newPos, SizeGrip.this);
   int xDelta = newPos.x - origPos.x;
   int yDelta = newPos.y - origPos.y;
   Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this);
   if (wind != null) { // Should always be true
     if (getComponentOrientation().isLeftToRight()) {
       int w = wind.getWidth();
       if (newPos.x >= wind.getX()) {
         w += xDelta;
       }
       int h = wind.getHeight();
       if (newPos.y >= wind.getY()) {
         h += yDelta;
       }
       wind.setSize(w, h);
     } else { // RTL
       int newW = Math.max(1, wind.getWidth() - xDelta);
       int newH = Math.max(1, wind.getHeight() + yDelta);
       wind.setBounds(newPos.x, wind.getY(), newW, newH);
     }
     // invalidate()/validate() needed pre-1.6.
     wind.invalidate();
     wind.validate();
   }
   origPos.setLocation(newPos);
 }
Пример #2
0
 /**
  * This method sets the floating location of the JToolBar.
  *
  * @param x The x coordinate for the floating frame.
  * @param y The y coordinate for the floating frame.
  */
 public void setFloatingLocation(int x, int y) {
   // x,y are the coordinates of the new JFrame created to store the toolbar
   // XXX: The floating location is bogus is not floating.
   floatFrame.setLocation(x, y);
   floatFrame.invalidate();
   floatFrame.validate();
   floatFrame.repaint();
 }