Maximizing a JFrame by default when it comes up

I’ve been playing around with JFreeCharts for a while.  The API’s perfect; the only problem is with the amount of data with labels that I wanted to show… it didn’t just fit in the dictionary of aesthetics. Best way to delude my users was to show the stuff maximized. I wanted to show a JFrame maximized by default. Here is what I did:

….

setExtendedState(getExtendedState()|MAXIMIZED_BOTH);

……

Here I am assuming that you wrote a class by extending from JFrame itself. If this is not the case, you need to use the instantiated object to call the ‘getExtendedState’ method. Also use JFrame to call ‘MAXIMIZED_BOTH’:

…..

JFrame fr = …

fr.setExtendedState(fr.getExtendedState()|JFrame.MAXIMIZED_BOTH);

….

Have fun 😉

Advertisements

One Response to “Maximizing a JFrame by default when it comes up”

  1. wooow….!!! good solution, thanks 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: