How to fix height on JPanel?

Hello,
I have three subPanels, all sitting on a JFrame.
I want to fix the height of the top and bottom panels, but have the middle panel always be the max allowed space.
For example, top Panel is always 50 pixels tall, bottom panel is always 30 pixels tall. Depending on the size of the main panel, the middle panel will always be:
JFrameHeight-50-30=middlePanelHeight.
I don't want to use setMaximumSize or setPreferred size, because that will fix my width, and I don't want to fix the width. I want it to grow as wide as the JFrame itself. The only thing I want to fix is the HEIGHT of the top and bottom panels on the JFrame.
I am using BoxLayout (with Y_AXIS). Right now, I am using setMaximumSize - that will fix my height - but also fixes my width (because it takes dimension(width,height), which I don't want to do.
Can anyone help me?
If you need code, please request, and I will post.
Apologies if this question already answered, I couldn't find it answered anywhere. :)
Nina.

Hello,
Yes, you are all correct, BorderLayout should work.
You guys really did get me closer to the solution.
Now, I think it's the topPane's Layout Manager
that keeps it from working right.
What I want to do, is the top panel (outlined in
the black box) to always stretch so that the words
are always fully justified at the left and right
edge. That means, the word "Age: 3",
"NinaCute", "Pet Name", "Nina Screen" are all
flushed to the sides.
Posted below is code. You'll see that if you
make the window wider, the words don't remain
flushed with the edges.
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.text.*;
import javax.swing.event.*;
import java.awt.*;              //for layout managers
import java.awt.event.*;        //for action and window events
import java.util.*;
public class NinaDialog extends JDialog
          public NinaDialog(JFrame frame)
                    super(frame, true);
          public void buildWindow()
                    Container contentPane=this.getContentPane();
                    BorderLayout bord=new BorderLayout();
                    contentPane.setLayout(bord);
                    this.setSize(600, 500);
                    JPanel topPane=createHeaderPane();
                    contentPane.add(topPane, bord.NORTH);
                    // create the reservation tab panel and add it
                    JPanel midPane=createMiddlePane();
                    contentPane.add(midPane, bord.CENTER);
                    JPanel btnPane=createButtonPane();
                    contentPane.add(btnPane, bord.SOUTH);
                    this.addWindowListener(new WindowAdapter()
                              public void windowClosing(WindowEvent e)
                              } // end windowCloseing
                    }); // end windowListener
          } // end buildWindow
          public JPanel createHeaderPane()
                    JPanel topPane=new JPanel();
                    topPane.setBorder(new LineBorder(Color.black));
                    GridBagLayout gb=new GridBagLayout();
                    GridBagConstraints gc=new GridBagConstraints();
                    topPane.setLayout(gb);
                    JLabel label=new JLabel(htmlIt("<b>Nina Screen</b> | "+
                    "<b>Folder:</b> Images"+
                    " | <b>Current Status:</b> FULL"));
                    gc.gridx=0; gc.gridy=0; gc.gridwidth=3;
                    gc.anchor=gc.NORTHWEST; gc.insets=new Insets(0,2,4,50);
                    gb.setConstraints(label,gc);
                    topPane.add(label);
                    label=new JLabel(htmlIt("<b>User Id:</b> NinaCute"));
                    gc.gridx+=3; gc.gridwidth=1; gc.anchor=gc.NORTHEAST;
                    gc.insets=new Insets(0,0,4,2);
                    gb.setConstraints(label,gc);
                    topPane.add(label);
                    gc.gridy++; gc.insets=new Insets(0,2,2,20);
                    label=new JLabel(htmlIt("<b>Pet Name:</b> Joe"));
                    gc.gridx=0; gc.anchor=gc.NORTHWEST;
                    gb.setConstraints(label,gc);
                    topPane.add(label);
                    label=new JLabel(htmlIt("<b>Type:</b> Bunny"));
                    gc.gridx++; gc.insets=new Insets(0,0,2,20);
                    gb.setConstraints(label,gc);
                    topPane.add(label);
                    label=new JLabel(htmlIt("<b>Color:</b> Black/White"));
                    gc.gridx++; gc.insets=new Insets(0,0,2,20);
                    gb.setConstraints(label,gc);
                    topPane.add(label);
                    gc.insets=new Insets(0,0,2,2);
                    label=new JLabel(htmlIt("<b>Age:</b> 3"));
                    gc.gridx++; gc.anchor=gc.NORTHEAST;
                    gb.setConstraints(label,gc);
                    topPane.add(label);
                    return topPane;
          } // end createHeaderPane
          public JPanel createMiddlePane()
                    // add in closeButton
                    JPanel pane=new JPanel();
                    //pane.setBorder(new LineBorder(Color.black));
                    GridBagLayout gb=new GridBagLayout();
                    GridBagConstraints gc=new GridBagConstraints();
                    pane.setLayout(gb);
                    JLabel label=new JLabel("this window should stretch "+
                    "and resize horizontally and vertically.");
                    gc.gridx=0; gc.gridy=0; gc.anchor=gc.NORTH;
                    gb.setConstraints(label,gc);
                    pane.add(label);
                    return pane;
          } // end createMiddlePane
          public JPanel createButtonPane()
                    // add in closeButton
                    JPanel btnPane=new JPanel();
                    btnPane.setAlignmentX(JComponent.LEFT_ALIGNMENT);
                    //btnPane.setBorder(new LineBorder(Color.black));
                    GridBagLayout gb=new GridBagLayout();
                    GridBagConstraints gc=new GridBagConstraints();
                    btnPane.setLayout(gb);
                    gc.gridx=0; gc.gridy=0; gc.anchor=gc.EAST; gc.ipadx=8;
                    gc.weightx=1.0; gc.insets=new Insets(0,0,0,4);
                    JButton closeButton=new JButton("Close Window");
                    closeButton.addActionListener(new CancelListener());
                    gb.setConstraints(closeButton, gc);
                    btnPane.add(closeButton);
                    return btnPane;
          } // end createButtonPane
          private String htmlIt(String text)
                    if(text==null) return "";
                    String ret="<HTML>"+
                    "<font face=\"arial, helvetica\" size=\"2\">"+
                    text+
                    "</font>"+
                    "</HTML>";
                    return ret;
          } // end niceFormatLabel
          class CancelListener implements ActionListener
                    public void actionPerformed(ActionEvent e)
                              closeWindow();
                    } // end actionPerformed
          } // end CancelListener
          public void closeWindow()
                    WindowEvent we = new WindowEvent(this, WindowEvent.WINDOW_CLOSING);
                    this.processWindowEvent(we);
          } // end closeWindow
          public void showDialog()
                    this.show();
                    return;
          public void show()
                    this.setTitle("Fulillment | Reservation | Cruise");
                    super.show(); // makes it block until it gets some closeevent
          public static void main(String[] args)
                    JFrame frame=new JFrame();
                    NinaDialog dig=new NinaDialog(frame);
                    // build the UI
                    dig.buildWindow();
                    // show the Dialog and don't close until closewindow clicked
                    dig.showDialog();
          } // end main
} // end class

Similar Messages

  • How could i set fixed heights for all of my web pages?

    I want fixed heights for all of my web pages.Do i have to set any margins for my footer?Because by adding some contents in between header and footer ,then the footer goes down.How could i have fixed height pages?

    You may like to have a fixed footer as in
    #footer {
       position:fixed;
       left:0px;
       bottom:0px;
       height:30px;
       width:100%;
       background:#999;

  • How to fix the height of the details section in crystal reports.

    hi all
    How to fix the height of the details section in crystal reports.

    Thanks for your reply
    i didnt get the clear idea about your answer can you explain it once with example
    why iam asking is when i add a new details section according to you answer maintaining same height of the two details sections and i see the preview the iam getting gap between each record. this is so because one record from details section1 and another empty space from details section2
    like
    Details section A-contains records
    Details section B- no records
    Details section A-contains records
    Details section B-no records
    Then how will i solve my issue
    Thanks in advance

  • How to set up fixed height in ADF layout component

    I try to create a page by having my main content at the center of page within a box using a fixed height. The idea is when the content is too long, a vertical scrollbar should show up for that box instead of stretching that box. I tried to use trh:tableLayout and set height attribute for trh:cellFormat component. However, instead of showing a vertical scrollbar, it just stretches table cell. Does anyone have a solution to this issue? Thanks.

    Thanks for your fast reply. Yes, I already tried layout="vertical" which is not help. I am using JDeveloper 11.1.1.2.0. Actually what I want to do is I will display a block of information in a box area at the center of screen. If the information become too big for that box, I want a scrollbar to show up for that box instead of stretching that box to fit the content.

  • Dreamweaver: How do I ensure my video is always the full browser width, but a fixed height?

    I don't care if the video crops vertically or horizontally, but I want to it be responsive to the full browser width, yet a fixed height (400px or so). Like this: http://www.anthonydesigner.com/
    Thank you kindly.

    Apply style rules as in
    video {
      position: fixed;
      top: -100px;
      right: 0px;
      bottom: 0px;
      min-width: 100%;
      min-height: 100%;
      width: auto;
      height: auto;

  • How to fix objects below repeating frame?

    hello all! I wonder how to fix the last elements such as signature area of a sale order report to the bottom of the last page?
    i find the area always appear closely after the detail lines...i don't want this
    Thanks for any help!

    hi philipp!Thanks for your reply.
    I am meaning that a have some text objects lower than a repeating frame which height is variable and i want to have the distance between the text objects and the bottom of the page to be fixed,instead of varying according to the height of the repeating frame.The text objects and the repeating frame are in a same container frame so i can't set the vertical elasticity of the frame to fixed.
    Any idea?

  • How to fix Online help issue with F1

    Dear All,
    I think you already know this issue : when using a proxy, Online help is not working on Adobe Reader XI.
    message displayed : "Online Help content cannot be displayed. Verify you can launch your web browser and have access to the Internet."
    I already checked on this forum and tried some things to fix this, but without any success :
    - try to add the registry key FeatureState -> not working
    - check if IE is correctly defined as default browser -> it is
    Accessing Online help from the Help menu was by passed by the following .js :
    app.addMenuItem({
    cName: "MyHelp", cUser: "Adobe Reader XI Help...",
    cParent: "Help",
    cExec: "app.launchURL('http://helpx.adobe.com/reader.html');",
    nPos: 0
    But, the message still appears when pressing F1 shortcut.
    Details : Adobe reader 10.0.06 packaged through an administrative installation et customized with Adobe Customisation Tool
    I tried to install directly from the setup.exe to be sure that was not caused by my package, and the issue is still the same.
    I'm an application packager for the European Court of Auditors and we want that Help works through F1 shortcut. This is mandatory for me.
    Thank you in advance for your help.

    Timo Hahn wrote:
    There is a problem with autoHeightRows and columnStretching used together in 11gR1.
    Have you tried without columnStretching?
    Or have you tried if it works in 11gr2?
    TimoHi Timo, Thank you very much for taking time to respond to my question.. :)
    Back to my question...
    I tried removing the columnStretching although my requirement really requires this but no effect really happens even if I remove this.
    Based on my investigation on the generated HTML, I notice the following items:
    1. A table is being wrapped in a div that is being set at a fixed height.
    2. On first load, if your autoheight rows is set to 6, the framework is setting a height of 96px to the div. This height would almost cut the last row of the table.
    3. If you try to refresh the page or try to re-PPR the component, the framework resets it to 102px which causes the last row to be fully displayed.
    My only concern is that IE is perfectly displaying this while Chrome and FF are having problem.
    Based on my understanding, the framework is messing up the height only on first load. Not sure but this is how I see it. I am really not confident also on my findings
    and I would most likely hear other's comment.
    Thanks.

  • Why do i keep getting these errors and how to fix them?!?!?

    first time i tried inserting a spry data set using a XML source i got the message "expected equal sign(7,10)".  since i could not figure out how to fix it a started a new.  this time i am getting the message "unterminated entity reference, 'm'(25,27)".  i really want to get the 2nd message fixed because the xml sheet is exactly how i want it.
    also is there a place where i can look up what all these messages mean and get a clue as to what is wrong?
    thanks.
    Mori Lina

    i don't have <td> anywhere.  here is the 2 sets of code that i am using.
    XML
    <e-coupons>
    <coupon>
    <store>Joanne's Clothing</store>
    <image><img src="joannescoupon.jpg"/></image>
    <description>Custom made clothing.</description>
    </coupon>
    <coupon>
    <store>Mommy + Me</store>
    <image><img src="mommycoupon.jpg"/></image>
    <description>Whether you're getting ready for a baby, or trying to keep up with an infant, we have everything that you need.</description>
    </coupon>
    <coupon>
    <store>Music Haven</store>
    <image><img src="havencoupon.jpg"/></image>
    <description>We know better than anyone else that everyone needs a soundtrack to their life. Come visit us and we'll start you on your way to walking to your own drummer.</description>
    </coupon>
    </ecoupons>
    HTML  (this is only the body part of it)
    <body>
    <div spry:region="ds1" class="SpotlightAndStacked">
      <div spry:repeat="ds1" class="SpotlightAndStackedRow">
        <div class="SpotlightContainer">
          <div class="SpotlightColumn"> {image}</div>
        </div>
        <div class="StackedContainer">
          <div class="StackedColumn"> {store}</div>
          <div class="StackedColumn"> {description}</div>
        </div>
        <br style="clear:both; line-height: 0px" />
      </div>
    </div>
    </body>

  • How to fix the Timing issue in Discoverer reports

    Hi,
    While running the discoverer report in Discoverer plus is taking more than 1 hour to complete( Gen.time + Extract to excel)
    where as the same report completes quickly in discoverer desktop.
    how to fix the timing issue in discoverer plus 
    Thanks
    Srinivas

    Timo Hahn wrote:
    There is a problem with autoHeightRows and columnStretching used together in 11gR1.
    Have you tried without columnStretching?
    Or have you tried if it works in 11gr2?
    TimoHi Timo, Thank you very much for taking time to respond to my question.. :)
    Back to my question...
    I tried removing the columnStretching although my requirement really requires this but no effect really happens even if I remove this.
    Based on my investigation on the generated HTML, I notice the following items:
    1. A table is being wrapped in a div that is being set at a fixed height.
    2. On first load, if your autoheight rows is set to 6, the framework is setting a height of 96px to the div. This height would almost cut the last row of the table.
    3. If you try to refresh the page or try to re-PPR the component, the framework resets it to 102px which causes the last row to be fully displayed.
    My only concern is that IE is perfectly displaying this while Chrome and FF are having problem.
    Based on my understanding, the framework is messing up the height only on first load. Not sure but this is how I see it. I am really not confident also on my findings
    and I would most likely hear other's comment.
    Thanks.

  • How to fix the memory usage of Ely`s FlexBook is insanely increasing when turn page that contains large images?

    Hi,
         I am using flexbook for newspaper project. We have lots of huge size images in our app,all more than 1 MB. I use SuperImage as flexbook content,I also noticed that the application was using huge amounts of memory and crashed IE6, IE7,IE8 and Firefox. I found that flexbook updateDisplayList method call many times and each time flexbookpage call copyInto method when turg page,this cause memory growing. And memory not released when call commitProperties method.
    I would really appriciate any help because I have no clue how to fix it.(我的英语不好,但是我真的很着急。)
    See my partial code below how I am using the flexbook.
         //从后台Java代码得到报纸页面集合
         var list_pages: ArrayCollection = event.result as ArrayCollection;
         pageList = list_pages.toArray();
         //显示右侧报纸版面列表
         getPageListDisp();
         //画布擦除所有子元素
         can.removeAllChildren();
         //创建FlexBook
         var book:FlexBook =new FlexBook();
         book.height=0.9*h;
         book.width=0.8*w;
        //FlexBook需要配置的属性
         book.itemSize="halfPage";
         book.animateCurrentPageIndex=false;
         book.animatePagesOnTurn=false;
         book.setStyle("edgeAndCornerSize",120);//翻动的页脚大小
         book.setStyle("activeGrabArea",1);//把翻动的范围设置为页边
         book.scaleX=sldrb.value;//设置book的放大比例
         book.scaleY=sldrb.value;
        var con:Array = book.content;//为book添加报纸版面
        con.push(new Image());
         for(var i:int=0;i<pageList.length;i++){
         var img:Image=new Image();
         img.source=pageList[i].pageBigImgUrl;
         img.maintainAspectRatio=true;
         con.push(img);
        book.content = con;
         can.addChild(book);
    <mx:Panel id="test1" width="80%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off" paddingTop="15" paddingBottom="15">
        <mx:Canvas id="can" scaleX="{sldrb.value}" scaleY="{sldrb.value}" click="MouseEventFunc(event)" borderColor="#8EC7EF" backgroundColor="#FFFFFF" horizontalScrollPolicy="off" verticalScrollPolicy="off" alpha="1.0" buttonMode="true" mouseDown="MouseEventFunc(event)" mouseUp="MouseEventFunc(event)">
          </mx:Canvas>
       </mx:Panel>

    Or you could include a width to your body style:
    body {
    background-image: url(Logo/sky1.jpg);
    background-position: center center;
    background-attachment: fixed;
    width: 75%;}
    It might work or not depending on your other color scheme.

  • How to fix my converted files which come out unlegible mixed with letters and symbols?

    how to fix my converted documents which look unlegible, mixed with numbers and symbols?

    Suggest you first validate the code
    http://validator.w3.org/check?uri=http%3A%2F%2Fwww.sainttims.com%2F&charset=%28detect+auto matically%29&doctype=Inline&group=0
    The Float drop issue on the News page could also be related to invalid code
    http://validator.w3.org/check?uri=http%3A%2F%2Fwww.sainttims.com%2Fnews.php&charset=%28det ect+automatically%29&doctype=Inline&group=0
    Fix lots of similar odd code like
    <p span class="BlueType">
    which should read
    <p><span class="BlueType">\
    The code for the sidebar photos reads
    <img src="images/photos/2012DOKSpringAssembly/Bishop-Susan-Boat.jpg" align="center" width="190" height="" />
    where height="", IE seems to rendering them at a height of 0px (i.e. invisible).

  • How to fix IE/Opera swf issue?

    Hello
    Wonder how to fix that IE 7 issue of having to click on the
    flash file/banner in order to activate it...Opera also has this
    issue as well. Thing is I need a fix that will be easy in one go -
    I've got a rotation/random array/series of banners on this home
    page -
    http://www.enhancedwireless.net/index.html
    4 of which are Flash - so how can I script it to where all 4
    swf files will be taken care of...that they'll be activated in
    Opera and IE?
    Thanks much
    KB

    Well, I just spent a while trying to make this work - but
    there's no difference on Opera or IE 7 - my banner still won't work
    unless you click on the banner to activate it...I stripped out
    quite a bit of the html that Flash puts on the file (it didn't work
    even when I did leave all that js in) and put in the following -
    what's wrong? This is the entire html now for my banner...
    =====================
    <!-- saved from url=(0013)about:internet -->
    <html lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=ISO-8859-1" />
    <title>HigherThroughputRO</title>
    <script type="text/javascript"
    src="swfobject.js"></script>
    <style type="text/css">
    <!--
    a:link {
    color: #CCCCCC;
    -->
    </style></head>
    <body bgcolor="#1246b4">
    <!--url's used in the movie-->
    <a href="
    http://www.enhancedwireless.net/Technology/ODMA.shtml"></a>
    <a href="
    http://www.enhancedwireless.net/Technology/NewProds.shtml"></a>
    <a href="
    http://www.enhancedwireless.net/Company/who.shtml"></a>
    <!--text used in the movie-->
    <div id="flashcontent">Please update your <a href="
    http://www.adobe.com/products/flashplayer/">Flash</a>
    Player.</div>
    <script type="text/javascript">
    var so = new SWFObject("HigherThroughputRO.swf", "HT", "800",
    "212", "8", "#1246b4");
    so.addParam("quality", "best");
    so.addParam("wmode", "window");
    so.write("flashcontent");
    </script>
    </body>
    </html>
    ===================
    This is how the banner appears on my index page in the array
    of 7 files:
    ==========================
    myAd[0] = "<object
    data='images/bnrs/HigherThroughputRO.swf'
    type='application/x-shockwave-flash' width='800'
    height='212'><param name='movie'
    value='images/bnrs/HigherThroughputRO.swf'><param name='loop'
    value='flase'><param name='quality'
    value='high'></object>"
    ===========================
    Thanks much
    KB

  • A movie I bought a while ago will no longer play, instead it just shows a black screen and no audio. All of the other movies in my library play fine. Any ideas as to whats going on or how to fix it? Thanks for any help.

    A movie I bought a while ago will no longer play, instead it just shows a black screen and no audio. All of the other movies in my library play fine. Any ideas as to whats going on or how to fix it? Thanks for any help.

    Hi 22chill,
    I recommend that we delete and re-download the movie from your purchase history:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    http://support.apple.com/kb/HT2519
    Thanks,
    Matt M.

  • How I fixed my iTunes 7 / Nano 1.2 problem.

    Like so many of you, I too lost the ability to connect my 4gb Nano to my iTunes when I upgraded to v7. Of course, Apple hasn't figured this out yet, but several here have.
    Here is how I fixed mine. Once you connect the Nano (after the firmware upgrade), iTunes 7 reports it as corrupt and in need of a restore. The problem is that it won't. Try the following to fix the problem:
    (note: this will reset your Nano entirely, and you WILL lose any music which is loaded on it. You will not lose whatever you have in iTunes).
    1. Unplug the Nano USB cable and perform a reset on the Nano.
    2. Restart your computer to ensure all services are running correctly.
    3. Once restarted, open My Computer and plug in your Nano. Wait until it show's up as a disk drive (this can take several minutes).
    4. Right-click on the drive which represents the Nano and wait again (up to several minutes) for the menu to pop up.
    5. Select Format and (you guessed it) wait for the format utility to appear.
    6. Make sure the File System is set to FAT32 then click Start. Do not click Quick Format. Wait some more (up to ten minutes. You'll see the progress bar move after a while).
    7. Once finished, the Nano should now be recognized by iTunes. If it isn't, unplug it, wait a minute and replug it.
    BTW, this retains the 1.2 firmware. I think the 1.2 firmware is incompatible with the data which written by previous versions. The format clears this data out.
    As always, YMMV.
    Good Luck,
    Steve
    HP   Windows XP Pro   P4 H/T

    bump
    I was having trouble seeing my Nano 2nd in iTunes and was afraid to do this step; but it works. My Nano was updated to version 1.1.1 and now everything seems to work perfectly. Keep in mind you will lose everything that is stored on your Nano when you format it.
    Gateway 733mhz   Windows XP  

  • How to fix applepushservice.dll issues for downloading iTunes on Windows 7 64 bit

    I recently had iTunes crash on my home PC, Windows 7 64-bit.  I have tried several attempts to uninstall and reinstall the program and it still does not work and I receive error messages.  The latest:  The program can't start because ApplePushService.dll is missing from your computer.  Try reinstalling the program to fix the problem.  Problem is, the articles that I have seen state this is an Unknown source and my firewall will not allow it to be installed.  The original error was a Windows Error 7 (registry & .dll issues).  Any suggestions on how to fix this problem?

    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    Your library should be unaffected by these steps but there is backup and recovery advice elsewhere in the user tip.
    tt2

Maybe you are looking for