File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JFrame size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFrame size" Watch "JFrame size" New topic
Author

JFrame size

joseph dela cruz
Ranch Hand

Joined: May 17, 2012
Posts: 38

sorry guys if im going to put some dirt in the ranch but i cant figure out how to match the designer size to runtime size. im just a student and im doing self study to further my knowledge in java
this is the code that i did to atleast prevent the JFrame under other components from preventing it to run at a very small size

frmMain.setSize(frmMain.getPreferredSize());

Product Version: NetBeans IDE 7.0 (Build 201104080000)
Java: 1.6.0_25; Java HotSpot(TM) Client VM 20.0-b11
System: Windows 7 version 6.1 running on x86; Cp1252; en_US (nb)
Userdir: C:\Users\Annalene Dela Cruz\.netbeans\7.0

this is what im using btw


[Thumbnail for fack.png]

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

That won't prevent the frame from being made smaller. You need to set the minimum size for that.

I actually suggest you stop using a GUI editor, and learn how to program user interfaces by hand. It gives you more control, and you will better understand how Swing works internally.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
joseph dela cruz
Ranch Hand

Joined: May 17, 2012
Posts: 38

but is there a way to make netbeans run perfectly like visual studio?
btw can you give me a link on a swing tutorial because tutorials on the net are too short and not that broad or im just stupid lol
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4522
    
    5

joseph dela cruz wrote:can you give me a link on a swing tutorial because tutorials on the net are too short and not that broad or im just stupid


What's the first hit when you search Google for 'Swing Tutorial?'


luck, db
There are no new questions, but there may be new answers.
joseph dela cruz
Ranch Hand

Joined: May 17, 2012
Posts: 38

zetcode xD anyway im trying to learn swing through netbeans im messing around the imodifyable generated code xD T T and trying it in a different main class xD and some sample from the net apparently im not learning fast haha xD any way thanks guys for the reply
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
joseph dela cruz wrote:zetcode xD . . . xD T T . . . xD . . .
What on earth does that mean?

And you are right; you can’t learn Swing coding with the GUI builder on NetBeans. Use NetBeans as a text editor, or get a decent text editor, eg jEdit, NotePad2 or NotePad++.
joseph dela cruz
Ranch Hand

Joined: May 17, 2012
Posts: 38

oops sorry ...
xD is cross face like dead eyes (imo) T T is cry ( Y . Y ) i use to spend my time in online games but now im shifting my focus since im too old to spend the whole day playing xD
anyway thanks to the replies what i did is

final int a = 27;
frmMain.setSize(frmMain.getPreferredSize());
frmMain.setSize(frmMain.getWidth(),frmMain.getHeight()+a);

i found out that during runtime it doenst count the header in size so i played a bit on the methods and this is what i got. i just dont know if its a good practice.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4522
    
    5

No, it's not the best practice. You can set a preferredSize for the contentPane and call pack().

Better still, don't set any custom size. Just call pack() and let the layout managers do their stuff.

If you want to prevent subsequent resizing, there's a method for that.
joseph dela cruz
Ranch Hand

Joined: May 17, 2012
Posts: 38

i called frmMain.pack(); and it answered all my problems thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JFrame size
 
Similar Threads
android
Encountering problems in displaying the amount in label
Java 7
How can I use Struts 2 with Netbeans 6.9
beginner of beginner