Screen resolution in Java

Hi, I am trying to determine the current resolution om my monitor. I remember there was a function waaaaaay back when I programmed with Borland C++, which was getWidth, or getScreenWidth... how can I get the screen resolution in Java? Does anyone know?

You can get the screen dimensions using the toolkit.
Eg.
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;
The toolkit is in java.awt package.
Hope this helps
Regards
Graham Humphries

Similar Messages

  • Change Screen Resolution or not Change Screen Resolution?

    I mean is it possible to change screen resolution with Java?
    I read some topics (not in this forum) that is impossible. I know there is a method to set at full screen a frame with the favourite resolution but does it effectively exist a method to set the screen with a favourite resolution?
    For example:
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setUndecorated(true);
            frame.setIgnoreRepaint(true);
            device.setFullScreenWindow(frame);
            if (displayMode != null && device.isDisplayChangeSupported()) {
                try {
                    device.setDisplayMode(displayMode);
                } catch (IllegalArgumentException iae) {
                    System.err.println("EX: " + iae);
            ...the device.setDisplayMode(displayMode) always throw me an exception: Invalid Display Mode (or something like that) with all permitted display modes (640by480, 800by600, 1024by768, etc...), with all permitted refresh rates, with all permitted color depths.
    Illuminate me please!
    Thanx in advance!

    Hi,
    I think i you should check this link
    http://forum.java.sun.com/thread.jspa?threadID=624649&messageID=3554316
    with help of above link you solve your problem of screen resolution
    but problem with above code is when you apply on frame that's ok but is you add any JDialog to that frame then JDialog and move JDialog with mouse dragged and dropped
    then dialog is invisibly run .
    you check this i you find any solution please post that it's urgent

  • Screen Resolution at Runtime

    Hello Everbody,
    Is it possible for me to change screen resolution from java? I am using JDK 1.3 .
    Thanks ..any help would be Great!!!!!!

    Anything is possible, but for this, you'll probably have to write some JNI code

  • IS IT POSSIBLE to change SCREEN's RESOLUTION thru JAVA code?

    Can I change the screen resolution of the PC (through my Java code) where my application will run? is there any possible way to do this?

    Hi.
    Sure it's possible if you use JDK 1.4, you can switch to fullscreen mode and change the displayModes throug methods like :
    java.awt.GraphicsDevice :
    public void setDisplayMode(DisplayMode dm)
    public DisplayMode getDisplayMode()
    public DisplayMode[] getDisplayModes()
    You can browse to for more information
    http://java.sun.com/j2se/1.4/docs/guide/awt/AWTChanges.html
    Regards, Mart�n

  • Screen resolution in 10G and converison from 6i

    Scenario is something like this:
    We are converting forms from 6i to 10G.
    We have designed forms in 6i for 1024x768 screen resolution. We don't have any issues in 6i for screen resolution of 1024x768.
    We converted the form to 10G. Screen resolution is still 1024x768 in 10G. We are using separateFrame=true in formsweb.cfg to make sure we don't show the Applet in browser window. separateFrame=true opens the application in new window and this new window can use entire screen resolution.
    Applet in new window is bigger than the screen resolution and we see scroll bars in main window when we open a child window. Obviously the applet is showing bigger footprint than client server form.
    Why is this so? Is there a way to fix this?

    If you will bring up a client-server form and a Web separate-frame form and compare them side-by-side, you can easily see the difference.
    The height and width of the actual space used by the form is identical. In fact, in my comparison, both window widths are exactly the same number of pixels. I used snagit to compare the sizes.
    However, if you compare the heights, you will see the difference. The web forms window has three bands above the actual Form canvas:
    1. The main window bar with the java icon on the left, window title, and the three windows icons for minimize, maximize and close.
    2. The pull-down menu choices on the left and the "Oracle" logo on the right. (Look-and-feel generic removes the Oracle logo, I believe.)
    3. The Window0 bar, blank except an icon on the left (right click shows Restore, Move, Size,... CLose) and an icon on the right, which clicking causes the inside window to maximize or restore.
    The Client/Server window has two bands:
    1. Main window bar, similar to 1 above, except the icon on the left is a Forms icon instead of java.
    2. Combination of 2 and 3 above: Contains both the icons in 3 above plus the pull-down menu choices. It is also about 8 pixels shorter than the web forms bar 2.
    In addition, comparing the bar with the message and status lines at the bottom of both versions, you can see that the web forms bar is about 9 more pixels higher.
    It is possible to position the Window0 at a y_pos of about -20 to regain some of the lost height (this causes the third bar described above to be hidden behind the second). But you cannot get all the height back, because of the additional height taken by Web Forms for the second bar and the bottom area.
    So what is left is to reduce the height of the canvas area used by your forms by about 20 pixels.
    I believe these heights are determined by the java runtime used by web forms rather than Oracle, so there is nothing Oracle can do about it.

  • Change Screen resolution in solaris

    Hi
    How can I change the screen resolution in either cde/java desktop? I remember setting the resolution to 800*600. But after installation the screen resolution has become 640*480 and everything is big.

    How`s about a little more info ?
    Are you running a SPARC machine or a PC ?
    If you have installed on a PC, simply bring up a terminal window and type : kdmconfig
    A little more involved if installed on a SPARC machine.
    Good luck .................JRH.

  • How to get more independent of screen resolution

    Read already a number of topics about this in this forum. But I still wonder
    how to set up ones Swing components for different screen resolutions. What
    I did up to now is checking for the current screenwidth and setting sizes for
    each resolution. Worked OK. But nowadays there are so many different
    screen sizes, this is getting too complex.
    I mean, one has to set the component's size, its location, the fonts used,
    possible Icons in the Toolbar, the size of the components internal panels,
    the insets, border sizes, and many other things. So, assuming ones window
    with all the components looks great in one resolution, the developer still has
    to check whether it all looks so great as well in any other thinkable screen
    resolution. Even in those which the developer isn't even able to create using
    his graphics card.
    So, my question is: Is there somewhere a clever tool inside Java which makes
    the total layout of components and their sizes inside the user's main window
    more independent of the screen resolution?
    For instance, it would be great to be able to define the component's size,
    location, and so on, using the actual size it should appear on any screen.

    You are right. For those using advanced high resolution
    monitors, this will be a disadvantage. However, I'm quite
    sure, the average user I'm aiming for, still uses rather
    standard type of monitors. Of, course, in the (near?)
    future, everybody may be using high resolution (same
    progress as with our tv-screens). So I may have to include
    these screen sizes as well later.
    Your presentation made me aware of the great need for
    everybody in the graphics business for a solution for this.
    Still think, this can be automated in a not too difficult way.
    I mean, if I can hard code this in such a way, that nobody
    is able to see the difference of the program running on a
    different resolution, it must be possible to include an
    option in whatever programming language, to create ones
    graphics components in a resolution independent way.
    At least, I think. May be a good starting point for my next
    project.
    Thanks anyway for your help an remark. I think you still
    deserve your dukes. Here they are.

  • URGENT: How to fix an application with the screen resolution?

    HI everyone,
    I am desprate and need help.. I have developed an application with Java swing and awt (JFrames, JPanels and...). This application displays perfectly with 1280 x 1024 screen resolution but in a situation where the screen does not support this resolution, a part of my application will not appear. I can not even scroll down to see the reste of the components. Does any one has any idea that how I can resolve this problem! I mean how either I can make my JFrame or panel to scroll down or to change the size of the components according to the resolution!
    Thank you very much and wait for a reply :)

    One of the possible reason of the problem is you must have hardcoded the size of panels and other container that is just right for the screen resolution 1280 x 1024.
    The solution is set the size of the containers that depends on the resolution of the screen.
    You have not explained much detail about the scrolling problem. But I suppose that you have a scrollpane in you GUI and you want to scroll the component inside it even at another resolution.
    try using this
    if p is the panel that is added in the scrollpane then set its prefered size.
    p.setPreferredSize(resolution dependant size).

  • Changing screen resolution

    Hi Everyone,
    I'm quite sure that it is not possible to change the screen resolution from within a running java program. The problem is that my boss won't believe it until he reads it in the spec. Does anyone out there know where to find a anything about it the specs?
    Thanks in advance
    jan

    Hi! The screen resolution is a function of the underlying OS and cannot be changed from a Java program, unless one resorts to JNI. However, the screen resolution can be retrieved from a Java program. Look at the docs for the getScreenSize() and getScreenResolution() methods in the java.awt.Toolkit packges. Note that these methods are abstract. The actual implementation depends upon the vendor.
    Perhaps you can ask your boss to search the Java docs for methods that allow Java code to change the resolution w/o resorting to JNI. We'll all be glad to know! :-)
    Hope this helps!
    Cheers!

  • How can I set the screen resolution ?

    hello brothers.
    my program works ultimately at 1024/768 screen resolution.
    since I want to make sure that peaple who using that program will see it correct, I want to explicitly change the resolution of the screen.
    how can I do that? please..

    I believe you use the setDisplayMode() method of the GraphicsDevice object to do this.
    If you go to http://www.scottshaver2000.com/ and download the source code to H.E.A.T., you will find a nice example of video mode switching. His game pops up a window showing the available configurations, then lets you select the one you want and switch to it.
    The applicable classes are in his com.sas.gui package: FullScreenJFrame.java and VideoModeSelector.java.
    Rick

  • How to control the printing resolution in JAVA

    Do we have any control on printing resolution in JAVA?
    If yes, how?
    Because I can print out the component but its resolution is same as screen or even less.

    Hi,
    Maybe you have to be more explicit. What do you want to print? What Component? Only a image? A Swing component (JTree, JTable, JPanel, etc)?

  • Max. screen resolution of secure desktop

    Hi there.
    I have access to the notebook at my office via Secure Global Desktop. Normally my notebook has a screen resolution of 1280x1024. If I try to access it with this resolution from home I indeed can log on but I only get a blue screen (for about one second I can see the icons on my notebook's desktop).
    Using a resolution of 1024x768 everything seems to work fine. But this resolution is too low to work with so that I would have to switch it every evening when I leave the office (to ensure that I could have access in case of emergency).
    Is there really a limit concerning the screen resolution? Does anyone know anything about that? Or if not, how would it be possible to access my notebook with the higher resolution!? What would I have to configure in the administration area?
    Thanks for every hint.
    Regards,
    Stephan

    I work with 1280x800 and it works perfectly.
    One thing you can try is to increase the memory assigned to java to see if it helps.
    /opt/tarantella/bin/tarantella config edit --tuning-jvm-initial <MB>
    /opt/tarantella/bin/tarantella config edit--tuning-jvm-scale <percent>
    /opt/tarantella/bin/tarantella config edit--tuning-jvm-max <MB>
    I normally set the initial to 60% of the systems memory, the scale to 150 and the max to 80% of the systems memory.
    I this won't help is will make the performance a bit better if the jvm memory was set very low.
    - Remold @ Everett

  • Retrieving screen-resolution for GUI:s

    I'm confused and frustrated cause I'm sitting here trying to develop a simple application (a GUI) and I would like it to "fit" any screen, that is, I wan't to be able to set the size of the window (frame) to the current screen-resolution.
    Like, say that I'm running on a 800x600 resolution and my friend has a 1280x800 (if that's possible) I would still like to have the same program consume the entire screen on both our machines.
    So I went looking all over for such a method that returns this Dimension of the screen.
    My guess was the java.system classes but that gave nothing and so did the rest.
    Can anyone please help me with this, I can't sleep at night. IT MUST BE POSSIBLE TO OBTAIN!!!!
    Andreas

    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension screenSize = kit.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;

  • Screen resolution on Boot Camp

    Hi
    I bought a macbook whitch Screen resolution is 2650 x 1600, and installed Windows 8 by bootcamp so I expected to see very small screen of my apps. For my surprise  most screens are too large.
    But Java script application screen its so high resolution that I cant read fonts.
    Is there a way to solve it ?
    Moises

    In Windows 8 use the help menu and search for external display.

  • Store a URL with given screen resolution

    I need to Save the web page with the GIVEN screen resolution in my local machine.
    The input i receive are URL and the screen resolution parameters.
    I figured that i can extract data from the URL by using the *URL Class and
    using readers* Now i have the data ,i am not sure how to store the data with the
    given screen resolution?? Any help would be greatly appreciated?
    Thnak you

    Do you think i should use applet to render the page
    first and then use the robot class to "Capture" the
    page. Thank you once againIf you want to convert HTML into an image, you are going to need something which renders HTML. Since you are asking on this forum, I'm assuming you want to use Java to do it. You could use a JTextPane, but it doesn't display HTML 2 very well. There are third party components which do it better. If you used some Java component, you wouldn't have to display the page, you could get it's graphics object and create and image, then save it too a file.
    To display a browser or take a snapshot of it with the robot class, your applet is going to have to be signed. Since you haven't given me any information about what it is you are trying to accomplish, I'm not sure any of this is relevant.

Maybe you are looking for

  • How do I restore files from TM backups with broken links?

    I have Time Machine backups with broken links all over the more recent backups. I get the message "The alias “xxx” can’t be opened because the original item can’t be found." whenever I click on one of the links. I have made the backups on my external

  • Populating dynamic values in the combobox with XML form Builder.

    I am trying to  populate dynamic value in the combobox with xml form builder. I  see the document saying create property group and document property Id with respecitive values.  I am able to create the property group with system admin -> System confi

  • No DNS settings when using built-in (hardwired) ethernet

    Iv'e never had an issue with wireless operation, but now that a wired connection is necessary, I've run into something strange. When connecting to a LAN with a DHCP source providing IP, router, DNS settings and more, the ibook fails to populate the D

  • Understanding how interfaces work

    I am new and trying to understand the magic of interfaces. I understand that you can declare an interface as follows: public interface MyInterface {       public abstract thisHereMethod(); } But what I don't understand is how the compiler properly fi

  • Installing CRS

    I have a 3 node Win2003 and i'm trying to install CRS (10.2.0.1 to be patched) This is my problem: Net Admin created TEAM-PRIVATE and TEAM-PUBLIC when i'm prompted to Specify Network Interface Usage i have this: Interface name | Subnet | Interface Ty