The Artima Developer Community
Sponsored Link

Java Answers Forum
setting Windows screen resolution from Java

8 replies on 1 page. Most recent reply: Sep 14, 2006 9:43 PM by shyam shridhar

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 8 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

setting Windows screen resolution from Java Posted: Jul 30, 2003 6:05 PM
Reply to this message Reply
Advertisement
Hi,

I'm trying to find out how to set the Windows screen resolution from a Java program. For instance, if the user's screen resolution is set to 800x600, I would like to find out (from a Java program) if the screen supports 1280x1024, and then ask the user if it's OK to set the resolution to those higher values. If the user agrees, I'd like the Java program to affect that change. I suspect I will have to use native methods. Does anyone have experience with this?

Thanks


David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: setting Windows screen resolution from Java Posted: Jul 31, 2003 6:07 AM
Reply to this message Reply
To find out the current settings use:

Toolkit.getDefaultToolkit().getScreenSize();
Toolkit.getDefaultToolkit(). getScreenResolution();

With regards to actually setting the values, I agree with you, you're probably going to have to use JNI.

Slager .

Posts: 16
Nickname: slager
Registered: May, 2003

Re: setting Windows screen resolution from Java Posted: Jul 31, 2003 9:19 AM
Reply to this message Reply
Are you sure you need to change the resolution?

If you are using 1.4 java you may consider using fullscreen mode instead. Much more user-friendly I think.

Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Re: setting Windows screen resolution from Java Posted: Jul 31, 2003 2:01 PM
Reply to this message Reply
> Are you sure you need to change the resolution?

The application I have requires a UI to display lots of fields at once to the user (i.e., the users want to be able to see all that data at once). But the only way to fit all those fields in view is to have a resolution at least 1024x768. If the resolution is set to less than that, I'd like to be able to offer the user to have the app change the resolution (right now I just display a message, asking the user to make this change himself, but many of our users are not sophisticated enough to know how to do that).

>
> If you are using 1.4 java you may consider using
> fullscreen mode instead. Much more user-friendly I think.

I looked a bit into the full-screen mode, by my understanding is that it wouldn't work well for Swing-based apps. For instance, I'd have to tweak the drawing routines of the components, something that I'd really won't want to do. Also, the users in our case are allowed to resize/minimize/maximize the app, and my understanding is that that just doesn't work well with full-screen mode.

Do people use full-screen mode for regular desktop-style apps?

Greg Lehane

Posts: 33
Nickname: glehane
Registered: Jun, 2003

Re: setting Windows screen resolution from Java Posted: Jul 31, 2003 2:36 PM
Reply to this message Reply
IMHO

Whatever about full-screen mode, I would seriously advise against changing the native screen resolution from your application. Too many unknowns, let the operating system UI handle it, that's what it's there for.

Is it even possible to "suggest" to your users that placing all components on the same page isn't the preferred design method? Maybe you could make the components themselves smaller & use smaller fonts? Although, admittedly, it seems easier to change the screen res.

=- Greg

Hiran

Posts: 41
Nickname: jclu
Registered: Mar, 2002

Re: setting Windows screen resolution from Java Posted: Jul 31, 2003 3:00 PM
Reply to this message Reply
What about writing either a JNI component or a small C++ app to change the screensize and if the user agrees to change the size, calling that component/app? I'm not sure how you'd do it, but I'm sure you can. I've come across apps that sometimes change the screensize in order to run better and then change the screensize back after the app's done.

God bless
Hiran

Slager .

Posts: 16
Nickname: slager
Registered: May, 2003

Re: setting Windows screen resolution from Java Posted: Aug 1, 2003 1:15 AM
Reply to this message Reply
I didn't right Swing apps in full-screen mode myself, but I don't know of any limitation. One of the examples supplied by sun actually is a fullscreen swing app.

See here: http://java.sun.com/docs/books/tutorial/extra/fullscreen/example-1dot4/DisplayModeTest.java

Slager .

Posts: 16
Nickname: slager
Registered: May, 2003

Re: setting Windows screen resolution from Java Posted: Aug 1, 2003 1:16 AM
Reply to this message Reply
right=write of course

shyam shridhar

Posts: 1
Nickname: shyam001
Registered: Sep, 2006

Re: setting Windows screen resolution from Java Posted: Sep 14, 2006 9:43 PM
Reply to this message Reply
Hi,

I have try to make my project specific to single resolution.
That mean, I want to run my application always on 1024*768 screen resolution.
But facing some problem.
When i open any JDialog from clicking on button and moving that JDialog that dialog in hide(invisible). after moving mouse over that location where it hide JDialog again visible in installment not fully

I suck from this problem.please send any response as soon as possible.
my code for screen resolution is:

GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
GraphicsConfiguration graphConfig = graphicsDevice.getDefaultConfiguration();
DisplayMode displayMode = new DisplayMode(1024, 768, 32,DisplayMode.REFRESH_RATE_UNKNOWN);

mainframe = new JFrame("",graphConfig);


graphicsDevice.setFullScreenWindow(mainframe);

if(graphicsDevice.isDisplayChangeSupported()){
graphicsDevice.setDisplayMode(displayMode);
}

Flat View: This topic has 8 replies on 1 page
Topic: project topic Previous Topic   Next Topic Topic: Text floating around image in Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use