aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes BackgroundPanel.java cannot be placed in BorderLayout.NORTH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "BackgroundPanel.java cannot be placed in BorderLayout.NORTH" Watch "BackgroundPanel.java cannot be placed in BorderLayout.NORTH" New topic
Author

BackgroundPanel.java cannot be placed in BorderLayout.NORTH

chop ficaro
Ranch Hand

Joined: May 02, 2010
Posts: 30
i am trying to put a picture on the top of my swing GUI that stretches horizontally to fit the width of the window as it resizes

http://www.camick.com/java/source/BackgroundPanel.java
this is the code for a commonly used function that scales images to their components size. it works by overloading the paintcontainer class, which is called every time the window resizes, which then calls the paint class. they simply grab the size of the container and draw the image to those dimensions

the image that needs to be resized must be placed in BorderLayout.NORTH, because the rest of my GUI is in BorderLayout.CENTER, but BackgroundPanel cant be placed in NORTH, the image disappears, even with a minimum size set. it cant be placed inside a panel inside a panel inside NORTH either. ive been reading over the code for BackgroundPanel and its driving me crazy i cant figure out why

here is some short example code, not my program but it simplifies the problem:
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4544
    
    5

chop ficaro wrote:

Puh-lease!


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

chop ficaro wrote:

I really suggest you name your variables differently. Never use a class name as variable name. It makes your code confusing to read; when I first glanced over your code I thought I saw a few static calls:

Anyway, I see one problem with your BackgroundPanel. It has no children, so its size will be 0x0. Try giving it a preferred size.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4544
    
    5

Cross posted
http://www.javaprogrammingforums.com/java-theory-questions/5107-backgroundpanel-java-cannot-placed-borderlayout-north.html

edit
http://www.java-forums.org/new-java/31999-backgroundpanel-java-cannot-placed-borderlayout-north.html
http://forums.devshed.com/java-help-9/backgroundpanel-java-cannot-be-placed-in-borderlayout-north-739999.html
http://www.javakb.com/Uwe/Forum.aspx/java-programmer/49800/BackgroundPanel-java-cannot-be-placed-in-BorderLayout
http://java.net/story/backgroundpaneljava-cannot-be-placed-borderlayoutnorth
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

Chop, you've been informed by both Darryl and me back in May that you should BeForthrightWhenCrossPostingToOtherSites.
chop ficaro
Ranch Hand

Joined: May 02, 2010
Posts: 30
Rob Prime wrote:
chop ficaro wrote:

I really suggest you name your variables differently. Never use a class name as variable name. It makes your code confusing to read; when I first glanced over your code I thought I saw a few static calls:

Anyway, I see one problem with your BackgroundPanel. It has no children, so its size will be 0x0. Try giving it a preferred size.



thats what this is
//panel.setMinimumSize( new Dimension( 224, 224 ) );
it doesnt work remove the comment mark and see
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2182
    
    7
Why don't you actually try doing what the suggestion was? We don't have time to keep repeating the same suggestion over and over (especially when you don't bother to reply to other postings when you get help).
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

The minimum size is not the preferred size.
chop ficaro
Ranch Hand

Joined: May 02, 2010
Posts: 30
tyvm! your suggestion fixed my problem!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38865
    
  23
chop ficaro wrote:tyvm
Read this ( )
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BackgroundPanel.java cannot be placed in BorderLayout.NORTH