Stupid Swing/AWT question..

I kno this question is probably very noobish but i’m stuck and i need to figure out how to make my application start-up maximised (covering the whole screen, not windowed…)?

Is it a method of the JFrame class or the Frame class?

Can anybody help me please!!

There is no easy way with Java. Since that is not cross-platform behaviour, it was not built into the API. You would have to use:

GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode()

This will return a DisplayMode object which has the width, height, bits per pixel and refresh rate of the current screen settings. You can then set your JFrame to the size of the entire window.

Oops I don’t think I was very clear in my question:

I don’t mean “Full-screen” as in the kinda full-screen u’d be looking at if you was making a game fior example,

I mean not windowed by default, like when u click on the little ‘maximise’ button in the top-right-hand-corner of a windows application and it can either make it ‘maximised’, ‘windowed’ or send it to the bar at the bottom…

Like I said, noobish question… :-[

Hope someone can help?

on a JFrame : setExtentedState(JFrame.MAXIMIZED_BOTH);

Lilian

I love u man!!!

Thanx sooooo much!!

;D ;D ;D

Your’re welcome… but let’s just stay friends :wink:

Lilian

Also if i wanna change the ImageIcon for the JFrame once it’s been iconised then what method do I call?

well, add a windowListener (or a windowStateListener) to the frame, and
setIconImage() on state change.

You’d better have a look at the java tutorial on www.java.sun.com

Lilian

I’ve just been taking a look now and it seems as though the setIconImage() method takes in an Image object…

does this mean I can still use my ImageIcon object with the method or do I have to create a seperate Image object?

If so then how do I use the Image class to reference an Image file such as a Gif or BMP?

Is it the same as using an ImageIcon or do I have to do it a different way?

I’ve tried to figure it out looking at the methods/consructors etc… of the Image class but I can’t seem to make head’s or tails of any of it…

(I’m sorry I must apologise at my lack of knowledge of GUI programming in Java… I’m very new to the whole thing so…)

ImageIcon icon;
Image i = icon.getImage(); and that’s it !

Lilian

Ur such a god-send!!

Thanks soo much!!