java.awt.Window.getToolkit()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(359)

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

Window.getToolkit介绍

[英]Returns the toolkit of this frame.
[中]返回此框架的工具箱。

代码示例

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

f.setLocationByPlatform(true);
Image image = f.getToolkit().createImage(url);
ImagePanel imagePanel = new ImagePanel(image);
imagePanel.setLayout(new GridLayout(5, 10, 10, 10));

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

static void centerWindowInScreen(final Window window) {
 final Dimension screenSize= window.getToolkit().getScreenSize();
 final Dimension windowSize= window.getPreferredSize();
 window.setLocation(
  (int) (screenSize.getWidth() / 2 - windowSize.getWidth() / 2),
  (int) (screenSize.getHeight() / 2 - windowSize.getHeight() / 2));
}
/**

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

static public Insets getScreenInsets(Window wnd) {
 Insets                              si;
 try {
   if(wnd==null) { si=Toolkit.getDefaultToolkit().getScreenInsets(new Frame().getGraphicsConfiguration()); }
   else          { si=wnd.getToolkit()           .getScreenInsets(wnd.getGraphicsConfiguration());         }
   } catch(NoSuchMethodError thr) { si=new Insets(0,0,0,0); }
 return si;
 }

代码示例来源:origin: org.jdesktop.bsaf/bsaf

/**
 * Calculates default location for the specified window.
 * @return default location for the window
 * @param window the window location is calculated for.
 *               It should not be null.
 */
public static Point defaultLocation(Window window) {
  GraphicsConfiguration gc = window.getGraphicsConfiguration();
  Rectangle bounds = gc.getBounds();
  Insets insets = window.getToolkit().getScreenInsets(gc);
  int x = bounds.x + insets.left;
  int y = bounds.y + insets.top;
  return new Point(x, y);
}

代码示例来源:origin: com.samskivert/samskivert

/**
 * Center the given window within the screen boundaries.
 *
 * @param window the window to be centered.
 */
public static void centerWindow (Window window)
{
  Rectangle bounds;
  try {
    bounds = GraphicsEnvironment.getLocalGraphicsEnvironment().
      getDefaultScreenDevice().getDefaultConfiguration().getBounds();
  } catch (Throwable t) {
    Toolkit tk = window.getToolkit();
    Dimension ss = tk.getScreenSize();
    bounds = new Rectangle(ss);
  }
  int width = window.getWidth(), height = window.getHeight();
  window.setBounds(bounds.x + (bounds.width-width)/2, bounds.y + (bounds.height-height)/2,
           width, height);
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

/**
 * getScreenInsets, This returns the insets of the screen, which are defined by any task bars
 * that have been set up by the user. This function accounts for multi-monitor setups. If a
 * window is supplied, then the the monitor that contains the window will be used. If a window
 * is not supplied, then the primary monitor will be used.
 */
static public Insets getScreenInsets(Window windowOrNull) {
  Insets insets;
  if (windowOrNull == null) {
    insets = Toolkit.getDefaultToolkit().getScreenInsets(GraphicsEnvironment
        .getLocalGraphicsEnvironment().getDefaultScreenDevice()
        .getDefaultConfiguration());
  } else {
    insets = windowOrNull.getToolkit().getScreenInsets(
        windowOrNull.getGraphicsConfiguration());
  }
  return insets;
}

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

import java.awt.Frame;
import javax.swing.*;

class TestFrameSize {

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        JFrame f = new JFrame("Test Screen Size");
        f.setAlwaysOnTop(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        System.out.println(f.getToolkit().getScreenSize());
        f.setExtendedState(Frame.MAXIMIZED_BOTH);
        f.setVisible(true);
        System.out.println(f.getSize());
      }
    });
  }
}

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

/**
 * getScreenWorkingArea, This returns the working area of the screen. (The working area excludes
 * any task bars.) This function accounts for multi-monitor setups. If a window is supplied,
 * then the the monitor that contains the window will be used. If a window is not supplied, then
 * the primary monitor will be used.
 */
static public Rectangle getScreenWorkingArea(Window windowOrNull) {
  Insets insets;
  Rectangle bounds;
  if (windowOrNull == null) {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    insets = Toolkit.getDefaultToolkit().getScreenInsets(ge.getDefaultScreenDevice()
        .getDefaultConfiguration());
    bounds = ge.getDefaultScreenDevice().getDefaultConfiguration().getBounds();
  } else {
    GraphicsConfiguration gc = windowOrNull.getGraphicsConfiguration();
    insets = windowOrNull.getToolkit().getScreenInsets(gc);
    bounds = gc.getBounds();
  }
  bounds.x += insets.left;
  bounds.y += insets.top;
  bounds.width -= (insets.left + insets.right);
  bounds.height -= (insets.top + insets.bottom);
  return bounds;
}

代码示例来源:origin: triplea-game/triplea

/**
 * Returns the standard application icon typically displayed in a window's title bar.
 */
public static Image getGameIcon(final Window frame) {
 Image img = null;
 try {
  img = frame.getToolkit().getImage(GameRunner.class.getResource("ta_icon.png"));
 } catch (final Exception ex) {
  log.log(Level.SEVERE, "ta_icon.png not loaded", ex);
 }
 final MediaTracker tracker = new MediaTracker(frame);
 tracker.addImage(img, 0);
 try {
  tracker.waitForAll();
 } catch (final InterruptedException ex) {
  Thread.currentThread().interrupt();
 }
 return img;
}

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

public class test {
 public static void main(String[] args) {
   Window wnd = new Window(new Frame());
   //wnd.setLocation(100, 100);
   wnd.setSize(wnd.getToolkit().getScreenSize());
   wnd.setBackground(Color.red);
   wnd.setVisible(true);
   }
 }

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

(state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH)
Insets screenInsets = getToolkit().getScreenInsets(getGraphicsConfiguration());         
Rectangle screenSize = getGraphicsConfiguration().getBounds();
Rectangle maxBounds = new Rectangle(screenInsets.left + screenSize.x,

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

public static void closeWindow(Window w) {
  w.getToolkit().getSystemEventQueue().postEvent(new WindowEvent(w, WindowEvent.WINDOW_CLOSING));
}

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

import java.net.*;    
import java.awt.*;

public class QueenApl { 
 Image card;
 Frame frame;

 public static void main(String[] args){
   QueenApl f = new QueenApl();
 }

 public QueenApl(){
  frame = new Frame();
  frame.setSize(400,400);
  try{
   URL u = new URL("file:/c:/windows/desktop/carn4.jpg");
   card=frame.getToolkit().getImage(u);
  } catch(MalformedURLException e){
   System.out.println("Error in URL!"); System.exit(1);
  } 
  frame.show();
 }

 public void paint(Graphics g){
  g.drawImage(card,120,50,frame);
 }   
}

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

public static void installPalettePrefsHandler(final Preferences prefs, final String name, Window window, int x) {
  GraphicsConfiguration conf = window.getGraphicsConfiguration();
  Rectangle screenBounds = conf.getBounds();
  Insets screenInsets = window.getToolkit().getScreenInsets(conf);

代码示例来源:origin: net.sf.jt400/jt400

Toolkit kit = frame.getToolkit();

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

GraphicsConfiguration conf = window.getGraphicsConfiguration();
Rectangle screenBounds = conf.getBounds();
Insets screenInsets = window.getToolkit().getScreenInsets(conf);

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

setBounds(0,0,getToolkit().getScreenSize().width,getToolkit().getScreenSize().height);
setVisible(true);
        Am_I_In_FullScreen = true;

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

setUndecorated(true);
setBounds(0, 0, getToolkit().getScreenSize().width,
    getToolkit().getScreenSize().height);
setVisible(true);
Am_I_In_FullScreen = true;

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

setBounds(-10,-100,getToolkit().getScreenSize().width+30,getToolkit()
.getScreenSize().height+110);
    setVisible(true);

代码示例来源:origin: org.jdesktop.bsaf/bsaf

(root.getY() == defaultLocation.getY())) {
Dimension screenSize = window.getToolkit().getScreenSize();
Dimension windowSIze = window.getSize();

相关文章

Window类方法