Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JInternalFrame inital size  RSS feed

 
Eli Howard
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How do I set the initial size of a JInternalFrame? I have two in my desktop, but they start out small enough you have to drag the corner of the frame to see anything. I looked for a setSize() type method in the API and could not find anything.

Thanks
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked for a setSize() type method in the API and could not find anything.

Ahh, the power of inheritance. JInternalFrame gets many of it's properties from other classes. Like Component. This way many common methods can be used from a single class rather than re-writing those methods for every new class. If you look at the API for JInternalFrame you'll notice it lists all the methods from it's super classes.

In the Component class, which is one of the class JInternalFrame inherits, we find 2 methods that could suit your needs.

  • setSize(int xpos, int ypos)
  • setBounds(int xpos, int ypos, int width, int height)


  • Those methods are also overridden so you could supply setBounds a Rectangle object instead of each individaul point or you could give setSize a Point object.

    Also note that if you are using a LayoutManager (BorderLayout, GridLayout, etc) in your JInternalFrame, simply calling pack() on the internal frame will size it appropriatly to fit all the components.

    Anyway, there you go.
    [ July 01, 2004: Message edited by: Gregg Bolinger ]
     
    Eli Howard
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Of course! Inheritance. I took my first java class last fall, but I'm still working on getting my thinking patterns down for it.

    Many, many thanks.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!