javax.swing.JFrame.getSize()方法的使用及代码示例

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

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

JFrame.getSize介绍

暂无

代码示例

代码示例来源:origin: log4j/log4j

protected void centerFrame(JFrame frame) {
 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
 Dimension comp = frame.getSize();
 frame.setLocation(((screen.width - comp.width) / 2),
   ((screen.height - comp.height) / 2));
}

代码示例来源:origin: marytts/marytts

public static void centerWindow(javax.swing.JFrame window) {
  // Center window in the user's screen
  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  Dimension frameSize = window.getSize();
  window.setLocation(new Point((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2));
}

代码示例来源:origin: wildfly/wildfly

Dimension main_frame_size=mainFrame.getSize();
txtArea.setPreferredSize(new Dimension((int)(main_frame_size.width * 0.9), (int)(main_frame_size.height * 0.8)));
mainFrame.setVisible(true);

代码示例来源:origin: org.jodd/jodd-wot

/**
 * Center JFrame.
 */
public static void center(JFrame frame) {
  Dimension frameSize = frame.getSize();
  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  frame.setLocation((screenSize.width - frameSize.width) >> 1, (screenSize.height - frameSize.height) >> 1);
}

代码示例来源:origin: apache/felix

public void windowClosing(WindowEvent we) {
 JFrame jf=(JFrame) we.getWindow();
 System.out.println(" Console.gui : window closing ("+jf.getSize().height+"*"+jf.getSize().width+")");
}
public void windowClosed(WindowEvent we) {

代码示例来源:origin: org.apache.activemq/activemq-all

protected void centerFrame(JFrame frame) {
 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
 Dimension comp = frame.getSize();
 frame.setLocation(((screen.width - comp.width) / 2),
   ((screen.height - comp.height) / 2));
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

protected void centerFrame(JFrame frame) {
 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
 Dimension comp = frame.getSize();
 frame.setLocation(((screen.width - comp.width) / 2),
   ((screen.height - comp.height) / 2));
}

代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql

private Dimension getDimension(JFrame mainFrame)
{
 int prefWidth = Preferences.userRoot().getInt(PREF_KEY_SQL_HISTORY_DLG_WIDTH, 600);
 int perfHeight = Preferences.userRoot().getInt(PREF_KEY_SQL_HISTORY_DLG_HEIGHT, 600);
 return new Dimension(
   Math.min(prefWidth, mainFrame.getSize().width),
   Math.min(perfHeight, mainFrame.getSize().height)
 );
}

代码示例来源:origin: realXuJiang/bigtable-sql

private Dimension getDimension(JFrame mainFrame)
{
 int prefWidth = Preferences.userRoot().getInt(PREF_KEY_SQL_HISTORY_DLG_WIDTH, 600);
 int perfHeight = Preferences.userRoot().getInt(PREF_KEY_SQL_HISTORY_DLG_HEIGHT, 600);
 return new Dimension(
   Math.min(prefWidth, mainFrame.getSize().width),
   Math.min(perfHeight, mainFrame.getSize().height)
 );
}

代码示例来源:origin: org.fuin/utils4swing

/**
 * {@inheritDoc}
 */
public final void position(final JFrame frame) {
  final Dimension screenSize = Toolkit.getDefaultToolkit()
      .getScreenSize();
  final Dimension frameSize = frame.getSize();
  checkMaxSize(screenSize, frameSize);
  frame.setLocation(
      (screenSize.width - frameSize.width - getWidthOffset()), 0);
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

public void actionPerformed(ActionEvent e) {
    if (memoryMonitorFrame == null) {
      memoryMonitorFrame = new MemoryMonitor();
      Rectangle fr = getBounds();
      Dimension md = memoryMonitorFrame.getSize();
      memoryMonitorFrame.setLocation(fr.x + (fr.width  - md.width) / 2,
                      fr.y + (fr.height - md.height) / 2);
    }
    memoryMonitorFrame.setVisible(true);
  }
}

代码示例来源:origin: org.antlr/antlr4

@Override
  public void windowClosing(WindowEvent e) {
    prefs.putInt(DIALOG_WIDTH_PREFS_KEY, (int) dialog.getSize().getWidth());
    prefs.putInt(DIALOG_HEIGHT_PREFS_KEY, (int) dialog.getSize().getHeight());
    prefs.putDouble(DIALOG_X_PREFS_KEY, dialog.getLocationOnScreen().getX());
    prefs.putDouble(DIALOG_Y_PREFS_KEY, dialog.getLocationOnScreen().getY());
    prefs.putInt(DIALOG_DIVIDER_LOC_PREFS_KEY, splitPane.getDividerLocation());
    prefs.putDouble(DIALOG_VIEWER_SCALE_PREFS_KEY, viewer.getScale());
    dialog.setVisible(false);
    dialog.dispose();
  }
};

代码示例来源:origin: org.fuin/utils4swing

/**
 * {@inheritDoc}
 */
public final void position(final JFrame frame) {
  final Dimension screenSize = Toolkit.getDefaultToolkit()
      .getScreenSize();
  final Dimension frameSize = frame.getSize();
  checkMaxSize(screenSize, frameSize);
  frame.setLocation(
      (screenSize.width - frameSize.width - getWidthOffset()),
      (screenSize.height - frameSize.height - getHeightOffset()));
}

代码示例来源:origin: org.fuin/utils4swing

/**
 * {@inheritDoc}
 */
public final void position(final JFrame frame) {
  final Dimension screenSize = Toolkit.getDefaultToolkit()
      .getScreenSize();
  final Dimension frameSize = frame.getSize();
  checkMaxSize(screenSize, frameSize);
  frame.setLocation(
      (screenSize.width - frameSize.width - getWidthOffset()) / 2,
      (screenSize.height - frameSize.height - getHeightOffset()) / 2);
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

@Override
  public void windowClosing(WindowEvent e) {
    prefs.putInt(DIALOG_WIDTH_PREFS_KEY, (int) dialog.getSize().getWidth());
    prefs.putInt(DIALOG_HEIGHT_PREFS_KEY, (int) dialog.getSize().getHeight());
    prefs.putDouble(DIALOG_X_PREFS_KEY, dialog.getLocationOnScreen().getX());
    prefs.putDouble(DIALOG_Y_PREFS_KEY, dialog.getLocationOnScreen().getY());
    prefs.putInt(DIALOG_DIVIDER_LOC_PREFS_KEY, splitPane.getDividerLocation());
    prefs.putDouble(DIALOG_VIEWER_SCALE_PREFS_KEY, viewer.getScale());
    dialog.setVisible(false);
    dialog.dispose();
  }
};

代码示例来源:origin: org.fuin/utils4swing

/**
 * {@inheritDoc}
 */
public final void position(final JFrame frame) {
  final Dimension screenSize = Toolkit.getDefaultToolkit()
      .getScreenSize();
  final Dimension frameSize = frame.getSize();
  checkMaxSize(screenSize, frameSize);
  frame.setLocation(getWidthOffset(), (screenSize.height
      - frameSize.height - getHeightOffset()));
}

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

JFrame frame = new JFrame();
frame.setResizable(false);
frame.pack();
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setVisible(true);
frame.setMinimumSize(frame.getSize());

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

public static void saveImage(JFrame frame, File target, String extension) throws IOException{
  Point pos = frame.getLocationOnScreen();
  Dimension size = frame.getSize();
  Rectangle rect = new Rectangle(pos.x, pos.y, size.width, size.height);
  Robot robot = new Robot();
  BufferedImage bi = robot.createScreenCapture(rect);
  ImageIO.write(bi, extension, target);
}

代码示例来源:origin: com.itextpdf/itext-rups

public void run() {
    JFrame frame = new JFrame();
    // defines the size and location
    initFrameDim(frame);
    RupsController controller = new RupsController(frame.getSize(), frame, false);
    initApplication(frame, controller, onCloseOperation);
    rups.setController(controller);
    if (null != f && f.canRead()) {
      rups.loadDocumentFromFile(f, false);
    }
  }
});

代码示例来源:origin: MegaMek/megamek

/**
 * Saves the current settings to the cfg file.
 */
void saveSettings() {
  // save frame location
  GUIPreferences.getInstance().setWindowPosX(frame.getLocation().x);
  GUIPreferences.getInstance().setWindowPosY(frame.getLocation().y);
  GUIPreferences.getInstance().setWindowSizeWidth(frame.getSize().width);
  GUIPreferences.getInstance().setWindowSizeHeight(frame.getSize().height);
}

相关文章

JFrame类方法