private DisplayMode findDisplayModeInternal(DisplayMode[] displayModes, int requestedWidth, int requestedHeight, int requestedDepth, int requestedRefreshRate) {
        DisplayMode displayModeToUse = null;
        for (int i = 0; i < displayModes.length; i++) {
            DisplayMode displayMode = displayModes[i];
            if ((requestedWidth == DONT_CARE || displayMode.getWidth() == requestedWidth) &&
                    (requestedHeight == DONT_CARE || displayMode.getHeight() == requestedHeight) &&
                    (requestedHeight == DONT_CARE || displayMode.getRefreshRate() == requestedRefreshRate) &&
                    (requestedDepth == DONT_CARE || displayMode.getBitDepth() == requestedDepth)) {
                displayModeToUse = displayMode;
            }
        }

        return displayModeToUse;
    }