Results 1 to 3 of 3
  1. #1
    MrFish is offline Member
    Join Date
    Jan 2010
    Posts
    43
    Rep Power
    0

    Default JComponents Are Wrong Size

    I'm making a program with a JFrame that has several sections separated by a JSplitPane. In the splits I'm putting my sections in their own JPanels. The problem is that I cannot size up the panels and they remain very small:



    Sample code looks like this:

    Java Code:
    JSplitPane RightColumn = new JSplitPane();
    		RightColumn.setOrientation(JSplitPane.VERTICAL_SPLIT);
    			JPanel TopRow = new JPanel();
    				EditArea EArea = new EditArea();
    				TopRow.add(EArea);
    ......
    Java Code:
    public EditArea()
    	{
    		width = height = 100;
    		setSize(width, height);
    		image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    		Graphics g = image.getGraphics();
    		g.setColor(Color.BLUE);
    		g.fillRect(0, 0, width, height);
    	}
    So what about JPanels am I not getting? Why doesn't this work the way I think it will?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You're not telling us the key information -- what layout managers are you using and how are you using them? Also, are you setting preferred size of your components?

  3. #3
    MrFish is offline Member
    Join Date
    Jan 2010
    Posts
    43
    Rep Power
    0

    Default

    I'm using a border layout. The toolbar is BorderLayout.NORTH, the left side is BorderLayout.WEST, and the right is BorderLayout.CENTER. I didn't set preferred size but I used setSize and I thought that would work. I'll try preferred size.

    Edit:

    Ok that's it. These are the things they don't tell you in tutorials :P. Thanks!
    Last edited by MrFish; 12-21-2010 at 03:17 AM.

Similar Threads

  1. Replies: 4
    Last Post: 06-11-2013, 01:37 AM
  2. Heap size
    By newbiejava in forum New To Java
    Replies: 2
    Last Post: 08-22-2010, 11:59 AM
  3. wrong size of JScrollPane
    By BigBear in forum AWT / Swing
    Replies: 6
    Last Post: 01-25-2010, 03:48 PM
  4. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  5. Object size
    By kavithas in forum New To Java
    Replies: 0
    Last Post: 11-30-2007, 12:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •