当前位置: 首页>>代码示例>>Java>>正文


Java Toolkit.getScreenSize方法代码示例

本文整理汇总了Java中java.awt.Toolkit.getScreenSize方法的典型用法代码示例。如果您正苦于以下问题:Java Toolkit.getScreenSize方法的具体用法?Java Toolkit.getScreenSize怎么用?Java Toolkit.getScreenSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Toolkit的用法示例。


在下文中一共展示了Toolkit.getScreenSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.awt.Toolkit; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        Frame frame = new Frame();
        Robot robot = new Robot();
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
        final GraphicsEnvironment graphicsEnvironment =
                GraphicsEnvironment.getLocalGraphicsEnvironment();
        final GraphicsDevice graphicsDevice =
                graphicsEnvironment.getDefaultScreenDevice();

        final Dimension screenSize = toolkit.getScreenSize();
        final Insets screenInsets = toolkit.getScreenInsets(
                graphicsDevice.getDefaultConfiguration());

        final Rectangle availableScreenBounds = new Rectangle(screenSize);

        availableScreenBounds.x += screenInsets.left;
        availableScreenBounds.y += screenInsets.top;
        availableScreenBounds.width -= (screenInsets.left + screenInsets.right);
        availableScreenBounds.height -= (screenInsets.top + screenInsets.bottom);

        frame.setBounds(availableScreenBounds.x, availableScreenBounds.y,
                availableScreenBounds.width, availableScreenBounds.height);
        frame.setVisible(true);
        robot.waitForIdle();

        Rectangle frameBounds = frame.getBounds();
        frame.setExtendedState(Frame.MAXIMIZED_BOTH);
        robot.waitForIdle();

        Rectangle maximizedFrameBounds = frame.getBounds();

        frame.dispose();
        if (maximizedFrameBounds.width < frameBounds.width
                || maximizedFrameBounds.height < frameBounds.height) {
            throw new RuntimeException("Maximized frame is smaller than non maximized");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:MaximizedToMaximized.java

示例2: ClientApp

import java.awt.Toolkit; //导入方法依赖的package包/类
public ClientApp() {
	imagepanel = new ImagePanel();
	
	// layout UI View
	this.getContentPane().setLayout(new BorderLayout());
	this.getContentPane().add(imagepanel, BorderLayout.CENTER);
	this.getContentPane().add(createMenus(), BorderLayout.NORTH);
	
	// size
	Toolkit toolkit = Toolkit.getDefaultToolkit();
	Dimension d = toolkit.getScreenSize();
	setSize(d.width-100, d.height - 80);
}
 
开发者ID:imageprocessor,项目名称:cv4j-desktop,代码行数:14,代码来源:ClientApp.java

示例3: setLocation

import java.awt.Toolkit; //导入方法依赖的package包/类
/**
* 
* @Title: setLocation 
* @Description: set component's location
* @param @param c 
* @return void
* @throws
 */
public static void setLocation(Component c)
{
    int winWidth = c.getWidth();
    int winHeight = c.getHeight();

    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension screenSize = kit.getScreenSize();

    int screenWidth = screenSize.width;
    int screenHeight = screenSize.height;

    c.setLocation(screenWidth / 2 - winWidth / 2, screenHeight / 2 - winHeight / 2);
}
 
开发者ID:wisdomtool,项目名称:formatter,代码行数:22,代码来源:FormatUtil.java

示例4: checkConfigs

import java.awt.Toolkit; //导入方法依赖的package包/类
private static GraphicsDevice checkConfigs(GraphicsDevice[] devices) {

        GraphicsDevice correctDevice = null;
        if (devices.length < 2) {
            return correctDevice;
        }

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds = new Rectangle(toolkit.getScreenSize());
        int halfScreen = screenBounds.height/2;

        for(int i = 0; i < devices.length; i++) {
            if(devices[i].getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
                GraphicsConfiguration conf =
                        devices[i].getDefaultConfiguration();
                Rectangle bounds = conf.getBounds();
                if (bounds.y >= halfScreen) {
                    // found
                    correctDevice = devices[i];
                    break;
                }
            }
        }
        return correctDevice;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:bug8071705.java

示例5: printScreen

import java.awt.Toolkit; //导入方法依赖的package包/类
/**
 * Salva uma imagem .png com o printscreen da tela atual
 *
 * @param file local a ser salva a imagem
 * @return {@code true} para imagem salva. {@code false} para erro ao salvar
 * imagem.
 */
public static boolean printScreen(File file) {
    try {
        Robot robot = new Robot();
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension d = toolkit.getScreenSize();
        BufferedImage bi = robot.createScreenCapture(new Rectangle(0, 0, d.width, d.height));
        ImageIO.write(bi, "PNG", file);
        return true;
    } catch (Exception ex) {
        return false;
    }
}
 
开发者ID:limagiran,项目名称:hearthstone,代码行数:20,代码来源:Img.java

示例6: getY

import java.awt.Toolkit; //导入方法依赖的package包/类
public int getY(int y) {
    int divy = y / 2;
    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension dim = kit.getScreenSize();
    int height = dim.height / 2;
    y = height - divy;
    return y;
}
 
开发者ID:Obsidiam,项目名称:joanne,代码行数:9,代码来源:ScreenCenter.java

示例7: showCreate

import java.awt.Toolkit; //导入方法依赖的package包/类
/**
 * 屏幕中间显示对话窗口
 * 
 * @param i_JDialog
 */
public void showCreate(JDialog i_JDialog)
{
    Toolkit v_Toolkit = Toolkit.getDefaultToolkit(); 
    int     v_X       = (v_Toolkit.getScreenSize().height - i_JDialog.getHeight()) / 2;
    int     v_Y       = (v_Toolkit.getScreenSize().width  - i_JDialog.getWidth() ) / 2;
    
    i_JDialog.setLocation(v_Y ,v_X);
    i_JDialog.setVisible(true);
}
 
开发者ID:HY-ZhengWei,项目名称:HBaseClient,代码行数:15,代码来源:BaseEvent.java

示例8: getDeviceDimension

import java.awt.Toolkit; //导入方法依赖的package包/类
private Dimension getDeviceDimension() {
    Dimension deviceDimension = null;
    try {
        Toolkit tool = Toolkit.getDefaultToolkit();
        deviceDimension = tool.getScreenSize();
    } catch (AWTError e) {
        System.out.println(CLASS_NAME+": ERROR! "+ e.getMessage());
        e.printStackTrace();
    }
    return deviceDimension;
}
 
开发者ID:adbenitez,项目名称:jNotifyOSD,代码行数:12,代码来源:ServerOSD.java

示例9: getBestSize

import java.awt.Toolkit; //导入方法依赖的package包/类
private void getBestSize(){
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    screenSize = toolkit.getScreenSize();
    canvasWidth = GAME_WIDTH*1;
    scale = canvasWidth/GAME_WIDTH;
    canvasHeight = scale*GAME_HEIGHT;
}
 
开发者ID:dstallenberg,项目名称:NormalFeedForwardNeuralNet,代码行数:8,代码来源:Unit.java

示例10: setHomeLocation

import java.awt.Toolkit; //导入方法依赖的package包/类
private void setHomeLocation()
{
    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension screenSize = kit.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    setSize(screenWidth / 3, screenHeight / 3);
    setLocation((screenWidth - getWidth()) / 2, (screenHeight - getHeight()) / 2);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-I,代码行数:10,代码来源:Home.java

示例11: getCenterPoint

import java.awt.Toolkit; //导入方法依赖的package包/类
private Point getCenterPoint() {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension screenSize = toolkit.getScreenSize();
    int x = (screenSize.width - getWidth() - getInsets().left - getInsets().right) / 2;
    int y = (screenSize.height - getHeight() - getInsets().top - getInsets().bottom) / 2;
    return new Point(x, y);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:ProxySettingsDialog.java

示例12: getX

import java.awt.Toolkit; //导入方法依赖的package包/类
public int getX(int x) {
    int divx = x / 2;
    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension dim = kit.getScreenSize();
    int width = dim.width / 2;
    x = width - divx;
    return x;
}
 
开发者ID:Obsidiam,项目名称:joanne,代码行数:9,代码来源:ScreenCenter.java

示例13: _addPair

import java.awt.Toolkit; //导入方法依赖的package包/类
/** Add a label and a widget to the panel.
 *  @param name The name of the entry.
 *  @param label The label.
 *  @param widget The interactive entry to the right of the label.
 *  @param entry The object that contains user data.
 */
protected void _addPair(
    String name,
    JLabel label,
    Component widget,
    Object entry) {
    // Surely there is a better layout manager in swing...
    // Note that Box and BoxLayout do not work because they do not
    // support gridded layout.
    _constraints.gridwidth = 1;
    _constraints.insets = _leftPadding;
    _grid.setConstraints(label, _constraints);
    _entryPanel.add(label);

    _constraints.insets = _noPadding;
    if (_columns > 1 && ((_entries.size() + 1) % _columns != 0)) {
        _constraints.gridwidth = 1;
    } else {
        _constraints.gridwidth = GridBagConstraints.REMAINDER;
    }
    _grid.setConstraints(widget, _constraints);
    _entryPanel.add(widget);

    _entries.put(name, entry);
    _labels.put(name, label);
    _previous.put(name, getStringValue(name));

    Dimension preferredSize = _entryPanel.getPreferredSize();
    // Add some slop to the width to take in to account
    // the width of the vertical scrollbar.
    preferredSize.width += 25;

    // Applets seem to need this, see CT/SigmaDelta
    _widgetsHeight += widget.getPreferredSize().height;
    preferredSize.height = _widgetsHeight;

    Toolkit tk = Toolkit.getDefaultToolkit();
    if (preferredSize.height > tk.getScreenSize().height) {
        // Fudge factor to keep this window smaller than the screen
        // height.  CGSUnitBase and the Code Generator are good tests.
        preferredSize.height = (int) (tk.getScreenSize().height * 0.75);
        _entryScrollPane.setPreferredSize(preferredSize);
    }

    _entryScrollPane.setPreferredSize(preferredSize);
    // Call revalidate for the scrollbar.
    _entryPanel.revalidate();
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:54,代码来源:Query.java

示例14: setExecutePageLocation

import java.awt.Toolkit; //导入方法依赖的package包/类
private void setExecutePageLocation()
{
    Toolkit kit = Toolkit.getDefaultToolkit(); 
    Dimension screenSize = kit.getScreenSize(); 
    int screenHeight = screenSize.height; 
    int screenWidth = screenSize.width; 
    setSize(screenWidth / 2, screenHeight / 2);
    setLocation((screenWidth - getWidth()) / 2, (screenHeight - getHeight()) / 2);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-I,代码行数:10,代码来源:ExecutePage.java

示例15: setHomeLocation

import java.awt.Toolkit; //导入方法依赖的package包/类
private void setHomeLocation()
{
    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension screenSize = kit.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    setSize(screenWidth / 3, screenHeight / 3);
    setLocation((screenWidth - getWidth())/ 2, (screenHeight - getHeight() )/ 2);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-I,代码行数:10,代码来源:Home.java


注:本文中的java.awt.Toolkit.getScreenSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。