keep the size of a line even if the screen settings are change

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: keep the size of a line even if the screen settings are change

  1. #1
    Join Date
    Sep 2002

    keep the size of a line even if the screen settings are change

    Hi, i have a weird things to do, and found nothing on google and others place...
    For example, i draw a line of 1 inch into my computer where my resolution is 96dpi and my screen area is 1024x768
    i need to made modification to this line to have a 1 inch line on every screen settings. example: my friend that are in 800x600 and have a dpi of 128 opn my program to see the line... i want him to see a 1 inch line too
    so i need to find a way to do that so when i have the screen size and the screen resolution that i could have on the screen a 1 inch (example) line for every settings...
    sorry for my english! can someone help me to find an idea...?
    thx a lot

  2. #2
    Join Date
    Nov 2002
    I came across a similar problem in that I had to find out the size of ALL monitors...including for a multiple monitor setup, so this should work all the same:

    private Vector monitors = new Vector();
        private int numOfMon;
    public void initMonitors() {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice[] gd = ge.getScreenDevices();
            for (int i = 0; i<gd.length; i++) {
                GraphicsConfiguration[]  gc = gd[i].getConfigurations();
                for (int j = 0; j<gc.length; j++) {
                    if (monitors.contains(gc[j].getBounds()) == false) {
            numOfMon = monitors.size();
    public int getNumOfMonitors() {
            return numOfMon;
        public Rectangle getSizeOfMonitor(int numOfMonitor) {
            return (Rectangle)monitors.elementAt(numOfMonitor);
    Sorry if some of the variables and stuff are missing, but the rest of it should work. I left out the code to set which monitor you want a window on...hope this helps!

  3. #3
    Join Date
    Sep 2002

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center