0
  • I have a JFrame of which extended state option is set to MAXIMIZE_BOTH

  • When i want to get the width of the JFrame it returns 0.

so WHY?

MOD
  • 1,070
  • 3
  • 19
  • 41

1 Answers1

2
  • I have a JFrame of which extended state option is set to MAXIMIZE_BOTH

JFrame.getExtendedState() returns proper state

  • When i want to get the width of the JFrame it returns 0.

any coordinated are accesible after

  1. pack() is called

  2. for already visible container on the screen

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • the container is visible but getWidth() still returns 0 – MOD Mar 01 '13 at 08:57
  • then there must be two `JFrames`, one of them isn't visible or initialized, remove all code about `extends JFrame` – mKorbel Mar 01 '13 at 09:13
  • i created new application and a new JFrame set to MAXIMIZE_BOTH and after calling pack() method i called getWidth() and printed the result. It is 123. My screen width is 1440 – MOD Mar 01 '13 at 19:23
  • eeeerght you pretty ignored an [SSCCE](http://sscce.org/), [I'll edit an post with FullScreen in this thread, have to waiting](http://stackoverflow.com/questions/15164485/making-a-single-component-full-screen), really why do you shoting to the dard :-) – mKorbel Mar 01 '13 at 19:29
  • Yes it gives the width now :D. – MOD Mar 01 '13 at 20:50