javax.swing.JInternalFrame.setLocation()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中javax.swing.JInternalFrame.setLocation()方法的一些代码示例,展示了JInternalFrame.setLocation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JInternalFrame.setLocation()方法的具体详情如下:
包路径:javax.swing.JInternalFrame
类名称:JInternalFrame
方法名:setLocation

JInternalFrame.setLocation介绍

暂无

代码示例

代码示例来源:origin: pentaho/mondrian

private void cascadeMenuItemActionPerformed(
  ActionEvent evt)
{
  try {
    int sfi = 1;
    for (JInternalFrame sf : getAllFrames()) {
      if (sf != null && !sf.isIcon()) {
        sf.setMaximum(false);
        sf.setLocation(30 * sfi, 30 * sfi);
        sf.moveToFront();
        sf.setSelected(true);
        sfi++;
      }
    }
  } catch (Exception ex) {
    LOGGER.error("cascadeMenuItemActionPerformed", ex);
    // do nothing
  }
}

代码示例来源:origin: antlr/antlrworks

public void setLocation(Point loc) {
  if(useDesktop) {
    jInternalFrame.setLocation(loc);
  } else {
    jFrame.setLocation(loc);
  }
}

代码示例来源:origin: org.cytoscape/swing-application-impl

@Override
  public void mouseReleased(MouseEvent e) {
    final Point originalPoint = iframe.getLocation();
    if (originalPoint.y < 0)
      iframe.setLocation(originalPoint.x, 0);
  }
});

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

public void setConstraints(Object... constraints) {
  if (constraints.length > 0) {
    if (constraints[0] instanceof Point) {
      internalFrame.setLocation((Point) constraints[0]);
    } else if (constraints[0] instanceof Rectangle) {
      internalFrame.setBounds((Rectangle) constraints[0]);
    }
  }
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

private static void centerWindow(JInternalFrame w, Component owner) {
  //center based on the owner component, if it is not null
  //otherwise, center based on the center of the screen
  if (owner != null) {
    Point p = owner.getLocation();
    p.x += owner.getWidth()/2;
    p.y += owner.getHeight()/2;
    SwingUtilities.convertPointToScreen(p, owner);
    w.setLocation(p);
  } else {
    w.setLocation(WindowUtils.getPointForCentering(w));
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

private static void centerWindow(JInternalFrame w, Component owner) {
  //center based on the owner component, if it is not null
  //otherwise, center based on the center of the screen
  if (owner != null) {
    Point p = owner.getLocation();
    p.x += owner.getWidth()/2;
    p.y += owner.getHeight()/2;
    SwingUtilities.convertPointToScreen(p, owner);
    w.setLocation(p);
  } else {
    w.setLocation(WindowUtils.getPointForCentering(w));
  }
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

private static void centerWindow(JInternalFrame w, Component owner) {
  //center based on the owner component, if it is not null
  //otherwise, center based on the center of the screen
  if (owner != null) {
    Point p = owner.getLocation();
    p.x += owner.getWidth()/2;
    p.y += owner.getHeight()/2;
    SwingUtilities.convertPointToScreen(p, owner);
    w.setLocation(p);
  } else {
    w.setLocation(WindowUtils.getPointForCentering(w));
  }
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

private static void centerWindow(JInternalFrame w, Component owner) {
  //center based on the owner component, if it is not null
  //otherwise, center based on the center of the screen
  if (owner != null) {
    Point p = owner.getLocation();
    p.x += owner.getWidth()/2;
    p.y += owner.getHeight()/2;
    SwingUtilities.convertPointToScreen(p, owner);
    w.setLocation(p);
  } else {
    w.setLocation(WindowUtils.getPointForCentering(w));
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

private static void centerWindow(JInternalFrame w, Component owner) {
  //center based on the owner component, if it is not null
  //otherwise, center based on the center of the screen
  if (owner != null) {
    Point p = owner.getLocation();
    p.x += owner.getWidth()/2;
    p.y += owner.getHeight()/2;
    SwingUtilities.convertPointToScreen(p, owner);
    w.setLocation(p);
  } else {
    w.setLocation(WindowUtils.getPointForCentering(w));
  }
}

代码示例来源:origin: antlr/antlrworks

public void center() {
  if(useDesktop) {
    Dimension s = desktopFrame.getSize();
    Dimension id = jInternalFrame.getSize();
    jInternalFrame.setLocation(s.width/2 - id.width/2, s.height/2 - id.height/2);
  } else {
    jFrame.setLocationRelativeTo(null);
  }
}

代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf

public void setLocation(int x, int y) {
  Point old = internalFrame.getLocation();
  Point location = new Point(x, y);
  if (old.equals(location))
    return;
  internalFrame.setLocation(location);
  firePropertyChangeEvent("location", old, location);
}

代码示例来源:origin: stackoverflow.com

private int count;

desktop.add(createInternalFrame(++count));

private JInternalFrame createInternalFrame(int number) {
  JInternalFrame jif = new JInternalFrame(
    "F" + number, true, true, true, false);
  int topLeft = 25 * number;
  jif.add(new JTextField(String.valueOf(number), 8));
  jif.pack();
  jif.setLocation(topLeft, topLeft);
  jif.setVisible(true);
  return jif;
}

代码示例来源:origin: com.numdata/numdata-swing

/**
 * Center the specified internal frame on it's container (don't modify
 * size).
 *
 * @param window Target window.
 */
public static void center( @NotNull final JInternalFrame window )
{
  final Container parent = window.getParent();
  if ( parent != null )
  {
    final Insets parentInsets = parent.getInsets();
    final int x = parentInsets.left + ( parent.getWidth() - parentInsets.left - parentInsets.right - window.getWidth() ) / 2;
    final int y = parentInsets.top + ( parent.getHeight() - parentInsets.top - parentInsets.bottom - window.getHeight() ) / 2;
    window.setLocation( x, y );
  }
}

代码示例来源:origin: com.jalalkiswani/jk-desktop

private void setPosition(final JInternalFrame frame) {
  final Point location = frame.getLocation();
  if (location.getX() == 0 && location.getY() == 0) {
    final int length = getAllFrames().length;
    final int y = length * 20;
    int x;
    if (SwingUtility.isLeftOrientation()) {
      x = length * 20;
    } else {
      final int width = frame.getContentPane().getPreferredSize().width;
      x = (int) (getSize().getWidth() - length * 20) - width;
    }
    System.out.println("X=" + x);
    System.out.println("Y=" + y);
    System.out.println(frame.getContentPane().getPreferredSize());
    frame.setLocation(x, y);
  }
}

代码示例来源:origin: stackoverflow.com

JDesktopPane mainPanel;
JInternalFrame jif_test = new JInternalFrame();

public void centerJIF(JInternalFrame jif) {
  Dimension desktopSize = mainPanel.getSize();
  Dimension jInternalFrameSize = jif.getSize();
  int width = (desktopSize.width - jInternalFrameSize.width) / 2;
  int height = (desktopSize.height - jInternalFrameSize.height) / 2;
  jif.setLocation(width, height);
  jif.setVisible(true);
}

代码示例来源:origin: net.sf.jung/jung-samples

public void actionPerformed(ActionEvent e) {
    dialog.pack();
    dialog.setLocation(desktop.getWidth()-dialog.getWidth(),0);
    dialog.show();
    try {
      dialog.setSelected(true);
    } catch (java.beans.PropertyVetoException ex) {}
  }
});

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

public/* synchronized */void waterfall() {
 if (isTabbed()) return;
 JInternalFrame[] frames = getNormalFrames();
 int i, l, x, y;
 l = frames.length;
 if (l > 0) {
  sortFramesByTitle(frames);
  x = 74;
  y = 0; // y=5;
  for (i = l - 1; i >= 0; i--) {
   frames[i].setLocation(x, y);
   moveToFront(frames[i]);
   checkInternalFrame(frames[i]);
   x += SNAPX;// x+=25;
   y += SNAPY;// y+=25;
  }
 }
}

代码示例来源:origin: net.sourceforge.ondex.apps/ovtk2

/**
 * Adds a given JInternalFrame to the desktop and centers it.
 * 
 * @param internal
 *            JInternalFrame to be displayed centered
 */
protected void displayCentered(JInternalFrame internal) {
  // do the location calculation
  Rectangle visible = this.getDesktopPane().getVisibleRect();
  Dimension size = internal.getSize();
  internal.setLocation((visible.width / 2) - (size.width / 2), (visible.height / 2) - (size.height / 2));
  // add to desktop and show
  this.getDesktopPane().add(internal);
  internal.setVisible(true);
  internal.toFront();
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

public void checkInternalFrame(JInternalFrame _f) {
 if (!SwingUtilities.isEventDispatchThread()) throw new RuntimeException("Not in swing thread.");
 Dimension dd = getSize();
 Point pf = _f.getLocation();
 Dimension df = _f.getSize();
 if (_f.isResizable()) {
  if (df.width > dd.width) df.width = dd.width;
  if (df.height > dd.height) df.height = dd.height;
  if (!df.equals(getSize())) _f.setSize(df);
 }
 if (pf.x + df.width > dd.width) pf.x = dd.width - df.width;
 if (pf.y + df.height > dd.height) pf.y = dd.height - df.height;
 if (pf.x < 0) pf.x = 0;
 if (pf.y < 0) pf.y = 0;
 if (isTabbed() && isPalette(_f) && (pf.x < LEFT_MARGIN + 4)) pf.x = LEFT_MARGIN + 4;
 if (!pf.equals(getLocation())) _f.setLocation(pf);
 adjustSize();
}

代码示例来源:origin: Geomatys/geotoolkit

/**
 * Creates and shows a new internal frame for the given image.
 */
final void addImage(final RenderedImage image, final String title) {
  final JInternalFrame internal = new JInternalFrame(title, true, true);
  internal.add(new ImagePanel(image));
  internal.pack();
  internal.show();
  desktop.add(internal);
  if (location > min(desktop.getWidth()  - internal.getWidth(),
            desktop.getHeight() - internal.getHeight()))
  {
    location = 0;
  }
  internal.setLocation(location, location);
  location += 30;
  internal.toFront();
}

相关文章

JInternalFrame类方法