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

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

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

JFrame.setMaximizedBounds介绍

暂无

代码示例

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

JFrame frame = new JFrame();
Rectangle bounds = getmaximizedBounds(); // set your maximized bounds
frame.setMaximizedBounds(bounds);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);

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

/**
 * Constructs JFrame and displays it.
 * 
 */
private void initUI() {
  frame = new JFrame(Config.config.getProperty("Program.Name") + " - Version " + Config.config.getProperty("Program.Version") + " (build " + DesktopUtils.extractBuildNumber() + ")");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  // get screen size
  Toolkit tk = Toolkit.getDefaultToolkit();
  Dimension dim = tk.getScreenSize();
  dim.height -= 50;
  frame.setSize(dim);
  String s = File.separator;
  String imgSrc = "config" + s + "themes" + s + "default" + s + "icons" + s + "ondex16" + ".png";
  Image icon = null;
  try {
    icon = Toolkit.getDefaultToolkit().getImage(imgSrc);
  } catch (Exception e) {
    // doesn't matter, it's just an icon
  }
  if (icon != null) {
    frame.setIconImage(icon);
  }
  // maximize jframe needs java 1.4 or later
  GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
  frame.setMaximizedBounds(env.getMaximumWindowBounds());
  frame.setExtendedState(frame.getExtendedState() | Frame.MAXIMIZED_BOTH);
}

代码示例来源:origin: us.ihmc/IHMCRobotDataVisualizer

private void setFullScreen()
{
 main.setMaximizedBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
 main.setExtendedState(main.getExtendedState() | JFrame.MAXIMIZED_BOTH);
 main.setUndecorated(true);
 main.setResizable(false);
 GraphicsDevice device = GraphicsEnvironment
    .getLocalGraphicsEnvironment().getDefaultScreenDevice();
 if (device.isFullScreenSupported())
 {
   device.setFullScreenWindow(main);
 }
 else
 {
   main.setVisible(true);
 }
}

代码示例来源:origin: us.ihmc/RobotDataCommunication

private void setFullScreen()
{
 main.setMaximizedBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
 main.setExtendedState(main.getExtendedState() | JFrame.MAXIMIZED_BOTH);
 main.setUndecorated(true);
 main.setResizable(false);
 GraphicsDevice device = GraphicsEnvironment
    .getLocalGraphicsEnvironment().getDefaultScreenDevice();
 if (device.isFullScreenSupported())
 {
   device.setFullScreenWindow(main);
 }
 else
 {
   main.setVisible(true);
 }
}

代码示例来源:origin: us.ihmc/ihmc-robot-data-visualizer

private void setFullScreen()
{
 main.setMaximizedBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
 main.setExtendedState(main.getExtendedState() | JFrame.MAXIMIZED_BOTH);
 main.setUndecorated(true);
 main.setResizable(false);
 GraphicsDevice device = GraphicsEnvironment
    .getLocalGraphicsEnvironment().getDefaultScreenDevice();
 if (device.isFullScreenSupported())
 {
   device.setFullScreenWindow(main);
 }
 else
 {
   main.setVisible(true);
 }
}

代码示例来源:origin: khuxtable/seaglass

/**
 * Maximize/Restore the window.
 *
 * @param maximize iconify {@code true} if we are to maximize the window,
 *                 {@code false} if we are to restore the window.
 */
private void setParentMaximum(boolean maximize) {
  if (rootParent instanceof JFrame) {
    JFrame frame = (JFrame) rootParent;
    int    state = frame.getExtendedState();
    if (maximize) {
      GraphicsConfiguration gc = frame.getGraphicsConfiguration();
      Insets                i  = Toolkit.getDefaultToolkit().getScreenInsets(gc);
      Rectangle             r  = gc.getBounds();
      r.x      = 0;
      r.y      = 0;
      r.width  -= i.left + i.right;
      r.height -= i.top + i.bottom;
      frame.setMaximizedBounds(r);
    }
    frame.setExtendedState(maximize ? state | Frame.MAXIMIZED_BOTH : state & ~Frame.MAXIMIZED_BOTH);
  }
}

代码示例来源:origin: com.github.insubstantial/substance

/**
 * Sets maximized bounds according to the display screen insets.
 */
public void setMaximized() {
  Component tla = this.root.getTopLevelAncestor();
  // fix for defect 213 - maximizing frame under multiple
  // screens shouldn't always use insets of the primary
  // screen.
  GraphicsConfiguration gc = (currentRootPaneGC != null) ? currentRootPaneGC
      : tla.getGraphicsConfiguration();
  Rectangle screenBounds = gc.getBounds();
  screenBounds.x = 0;
  screenBounds.y = 0;
  Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
  Rectangle maxBounds = new Rectangle(
      (screenBounds.x + screenInsets.left),
      (screenBounds.y + screenInsets.top), screenBounds.width
          - ((screenInsets.left + screenInsets.right)),
      screenBounds.height
          - ((screenInsets.top + screenInsets.bottom)));
  if (tla instanceof JFrame)
    ((JFrame) tla).setMaximizedBounds(maxBounds);
  if (MemoryAnalyzer.isRunning()) {
    MemoryAnalyzer.enqueueUsage("Frame set to bounds " + maxBounds);
  }
}

代码示例来源:origin: org.java.net.substance/substance

/**
 * Sets maximized bounds according to the display screen insets.
 */
public void setMaximized() {
  Component tla = this.root.getTopLevelAncestor();
  // fix for defect 213 - maximizing frame under multiple
  // screens shouldn't always use insets of the primary
  // screen.
  GraphicsConfiguration gc = (currentRootPaneGC != null) ? currentRootPaneGC
      : tla.getGraphicsConfiguration();
  Rectangle screenBounds = gc.getBounds();
  screenBounds.x = 0;
  screenBounds.y = 0;
  Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
  Rectangle maxBounds = new Rectangle(
      (screenBounds.x + screenInsets.left),
      (screenBounds.y + screenInsets.top), screenBounds.width
          - ((screenInsets.left + screenInsets.right)),
      screenBounds.height
          - ((screenInsets.top + screenInsets.bottom)));
  if (tla instanceof JFrame)
    ((JFrame) tla).setMaximizedBounds(maxBounds);
  if (MemoryAnalyzer.isRunning()) {
    MemoryAnalyzer.enqueueUsage("Frame set to bounds " + maxBounds);
  }
}

相关文章

JFrame类方法