This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Frame's setSize() method is not working

 
Abhimanyus singh
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Everytime I run this code, it results into a maximised window, preventing the setSize() method from taking any effect !!! Please help
 
m Korbel
Ranch Hand
Posts: 174
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
works, no issue

- JFrame returns Dimension(200, 200)

- ContentPane returns JFrames Dimansion minus Borders and toolbar (L&F sensitive)

- read Oracles tutorial about Initial Thread

- don't extends JFrame, create this Object as an local variable
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was correect, but a bit laconic.
This is where you find out about the single thread policy. As for not extending JFrame, you should do this:-Don’t use null layout. You often do not need to get the content pane separately from the frame.
 
Abhimanyus singh
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:That was correect, but a bit laconic.
This is where you find out about the single thread policy. As for not extending JFrame, you should do this:-Don’t use null layout. You often do not need to get the content pane separately from the frame.



It's still not working...let me explain it....the moment I run the program, it opens the frame in MAXIMIZED mode.!!! Earlier it was not happening.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhimanyus singh wrote: . . .....the moment I run the program, it opens the frame in MAXIMIZED mode.!!! Earlier it was not happening.
It didn’t appear maximised when I tried it.
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhimanyus, how, exactly are you executing that code?
 
Randall Twede
Ranch Hand
Posts: 4353
2
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not sure if this will help, just a couple points. i also don't extend JFrame anymore but i used to.
first, you shouldn't have to call super() in the constructor. at least i didn't have to using no argument constructor and calling setTitle(String) in it.
second you don't have to say "this" all the time.
setSize(200, 200);
and
setVisible(true);
is sufficient.

try getting rid of the call to super(h)
 
Maneesh Godbole
Saloon Keeper
Posts: 10971
11
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randall Twede wrote:
first, you shouldn't have to call super() in the constructor. at least i didn't have to using no argument constructor and calling setTitle(String) in it.
try getting rid of the call to super(h)

The OP doesn't have a super() but rather a super(h) call which is akin to setTitle(String title).

Randall Twede wrote:
second you don't have to say "this" all the time.

Technically correct. But it is a good practice to use this.xxx and super.xxx as much as possible.

I suspect the OP is executing some old code and getting the strange results. Like Darryl said, once we know exactly, how it is being executed, we will know
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic