Java Screen Size getComponentWidthForResolution(int screenWidth, int desiredSize)

Here you can find the source of getComponentWidthForResolution(int screenWidth, int desiredSize)

Description

Returns a proportional width according to screenWidth and desiredSize for the current screen resolution

License

Open Source License

Parameter

Parameter Description
screenWidth a parameter
desiredSize a parameter

Declaration

public static int getComponentWidthForResolution(int screenWidth, int desiredSize) 

Method Source Code

//package com.java2s;
/**/*from   w  w  w.j av  a 2s .co m*/
 * aTunes 1.6.0
 * Copyright (C) 2006-2007 Alex Aranda (fleax) alex.aranda@gmail.com
 *
 * http://www.atunes.org
 * http://sourceforge.net/projects/atunes
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

import java.awt.Toolkit;

public class Main {
    /**
     * Returns a proportional width according to screenWidth and desiredSize for the current screen resolution
     * @param screenWidth
     * @param desiredSize
     * @return
     */
    public static int getComponentWidthForResolution(int screenWidth, int desiredSize) {
        int currentScreenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
        int result = desiredSize * currentScreenWidth / screenWidth;
        return result;
    }
}

Related

  1. adjustPopupLocationToFitScreen(Component invoker, Dimension preferredSize, int xposition, int yposition)
  2. formatScreenSize(Dimension screenSize)
  3. getDefaultAppSize()
  4. getDefaultDeviceScreenSize()
  5. getDefaultMainFrameSize()
  6. getDefaultScreenBounds()