How do I position to panels in a single frame?

Hi,
Can someone tell me how i can position two panels in a single frame using the BorderLayout class.
I have included my code below. When it is run it shows two JPanels positioned at the top and the bottom, a text area to the right, a panel in the center and a panel on the left. I want to get the panel on the left - the yellow panel - to be positioned in the lower third of the center panel. I have tried to use the BorderLayout.SOUTH statement - but this positions the panel across the very bottom which causes the bottom JPanel and part of the text area to disappear.
Can anyone help with this please???
Many thanks
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Panels extends JFrame implements ActionListener
     private TopPanel topPanel;
     private BottomPanel bottomPanel;
     private JButton open;
     private JButton close;
     private JButton connect;
     boolean openClicked = false;
     boolean closeClicked = false;
     public Panels()
          super("Panels");
          setSize(1000,600);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setVisible(true);
          Container contentArea = getContentPane();
          topPanel = new TopPanel();
          bottomPanel = new BottomPanel();
          JTextArea textArea = new JTextArea("Text Area",20,20);
          JScrollPane textScroller = new JScrollPane(textArea);
          open = new JButton("Open");
          open.addActionListener(this);
          close = new JButton("Close");
          close.addActionListener(this);
          connect = new JButton("Connect");
          connect.addActionListener(this);
          JPanel topBar = new JPanel();
          topBar.setBackground(Color.red);
          topBar.add(open);
          topBar.add(close);
          JPanel lowerBar = new JPanel();
          lowerBar.setBackground(Color.red);
          lowerBar.add(connect);
          bottomPanel.setPreferredSize(new Dimension(100,100));
          contentArea.add(topPanel);
     contentArea.add(bottomPanel,BorderLayout.WEST);
          contentArea.add(textScroller,BorderLayout.EAST);
          contentArea.add(lowerBar,BorderLayout.SOUTH);
          contentArea.add(topBar,BorderLayout.NORTH);
          setContentPane(contentArea);
public void actionPerformed(ActionEvent e)
     if(e.getSource() == open)
     openClicked = true;
     topPanel.repaint();
     if(e.getSource() == close)
     {closeClicked = true;
     bottomPanel.repaint();
class TopPanel extends JPanel
     public TopPanel()
     public void paintComponent(Graphics painter)
          super.paintComponent(painter);
          painter.setColor(Color.white);
          painter.fillRect(0,0,getSize().width,getSize().height);
          if (openClicked == true)
          drawTopMessage(painter);
     public void drawTopMessage(Graphics painter)
          painter.setColor(Color.black);
          painter.drawString("This is the top panel", 20,20);
class BottomPanel extends JPanel
     public BottomPanel()
     public void paintComponent(Graphics painter)
          super.paintComponent(painter);
          painter.setColor(Color.yellow);
          painter.fillRect(0,0,getSize().width,getSize().height);
          if (closeClicked == true)
          drawBottomMessage(painter);
     public void drawBottomMessage(Graphics painter)
          painter.setColor(Color.black);
          painter.drawString("This is the bottom panel", 20,20);
public static void main(String[] args)
     Panels example = new Panels();

One solution would be to create a new panel, bothPanels and adding the two panels that you need to this panel.
Once you have done that, you can add bothPanels to contentArea.add( bothPanels, BorderLayout.CENTER)
hth

Similar Messages

  • How to add muliple panels to a single frame?

    How can i place my diff panels on a same frame at same location/place?
    what i need is on double clicking on each leaf node of my tree.. i need corresponding panel on frame.
    the problem is can place each panel in diff place(ie east/west/north/south in BorderLayout)
    but i cannot place 2 panels in same place.

    thanks got correct..

  • How to add JCombobox to panels and Paness to frames

    we added different items to combobox and that combobox to panels that panels is added to Jame, then we added listener to this combobox , then if we click on this combobox the list of items is appering in the back of the screen . How can i solve this probles ??.

    JComboBox box = new JComboBox();
    Container cont = getContentPane();
    box.addItem("option1");
    box.addItem("option2");
    box.addItem("option3");
    box.addItem("option4");
    box.addItem("option5");
    cont.add(box);
    setContentPane(cont);
    I hope that answers your question.
    Dunk

  • How to Measure Position and Velocity with a Single Counter with myrio

    Hi Everyone , I need your help .
    I got myrio a few days ago for my project which is a electric vehicle drived by wireless mode so first problem faces me that I have encoder and it give me counts (decreasing or icreasing) which I can't convert it to veolcity any one may help , I will be grateful ???????????????????

    Hey Hesham92,
    As you mentioned the myRIO encoder counts pulses.  These pulses will typically come from some type of encode such as a quadrature encoder.
    Look at your encoder datasheet and it should explain how it works (which mode it uses) and the resolution (ie rotation per pulse).    If the encoder is attached to a wheel you can use some simple math to determine how many cm the wheel moves per encoder pulse.
    Let us know if you have questions about this (please also post more info about your setup such as the encoder, what it's attached to and what you need to measure).
    Thanks!
    -Sam K
    LabVIEW Hacker
    Join / Follow the LabVIEW Hacker Group on google+

  • How to maintain height of panel on webpage in case of dynamic controls visibility onto it and maintain footer position according to them??

    I am using a panel on the web form to hold some more hidden panels onto it.
    But when I am making those hidden panel visible panel size remains same and footer goes down and page looks ugly then.
    How to maintain size of panel as well as footer w.r.t. it?
    Please reply asap, its urgent!!
    Thanks! :)
    KGProgrammer

    Split your unvisible DIV (for example) to 2 parts, one visible and one unvisible.
    In the visible part put onlu a space, and make it the height of the unvisible part.
    That way, the page will look the same with the uv=nvisivle part and without it.
    Noam B.
    Do not Forget to Vote as Answer/Helpful, please. It encourages us to help you...

  • TalentFramework module -  Position Details Panel General Information

    Dear Nakisa Experts,
    TalentFramework module
    I would like to know in Position Details Panel > General Information.
    May I know how:
    1.  to make field Org Unit field data unclickable.
    2.  to enable additional fields  Cost Centre and Qualification/Experience
    Please specify which folder and file need to be configure in Nakisa.
    Hope you guys could help me on this.
    Regards,
    Andi Rossi

    Hi Andi,
    1. The Position Details Panel does not have OrgUnit listed on it.
    2. To achieve this you need to follow this procedure in the AdminConsole:
    a. Create a new function in the AdminConsole in Application-wide Settings > Data Center > Edit/Create new data element joining multiple SAP Tables
    b. Navigate to Job Architecture module > Positions > Details Designer
    c. Select Create Linked Detail
    d. Enter a name, select SAPPositionDetailsConfiguration, select the data element you created in step a and then map the fields to link them together (usually ID and the key field from your new data element, possibly OBJID)
    e. Add a section in the details panel using your new linked details and au voila!
    All of this should be documented in the Admin guide in the Root\Documentation folder.
    Good luck!
    Luke

  • How to show the front panel when launching VI with Call by reference node??

    Hello!
    I just wonder how I make the front panel visible during execution when I launch the VI with CALL BY REFERENCE NODE.
    Se example.
    Could u also show me how to change different properties (window size ..) of the front panel??? (launched with CALL BY REFERENCE NODE)
    Thank you!
    Attachments:
    test.vi ‏18 KB

    In VI Properties>>Window Apperance>>Customize you can check "Show front panel when called". This will open the front panel on each call. It doesn't matter how the call was initiated.
    You can set a lot of Front panel properties during runtime. Place a Property Node in the block diagram. Change the class from App to VI. Under properties select Front Panel window>>Panel bounds to set the position and size of the front panel.
    Waldemar
    Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
    Don't forget to give Kudos to good answers and/or questions

  • How do you position tags in a spreadsheet? Can I eSign more than one tab in a spreadsheet?

    How do you position tags in a spreadsheet? Can I eSign more than one tab in a spreadsheet?

    Using text tags
    https://workspaces.acrobat.com/app.html#d=Bi-SZ3cbVCHwiWBBp-7G7g
    but spreadsheets are quite difficult to predict as they don't typically have a page size defined. If you can do this in Word it'll be easier.
    or convert to pdf before uploading to EchoSign.
    You an upload a spreadsheet with multiple tab and place tags on each tab and all will get converted.

  • How to change position for items in shopping cart

    Hello,
    I am creating shopping cart using flat file. But i am not able to change the position for items i.e. both items contain position as 0000000001.
    Following are the item details of shopping cart which is created through portal. (from tcode BBP_PD)
    Items:
    Pos Type Quantity Unit Ordered_Prod Description Gross price
    0000000001 1 EA keyboard 100,00
    0000000002 1 EA CPU 1.000,00
    Following are the item details of shopping cart which is created using flat file & BAPI BBP_PD_SC_CREATE.(from tcode BBP_PD)
    Items:
    Pos Type Quantity Unit Ordered_Prod Description Gross price
    0000000001 1 EA MONITOR 1,00
    0000000001 1 EA MONITOR 1,00
    Position is not getting changed for item 2 & only first record is getting uploaded 2 times. My code is creating Shopping cart number .
    Please tell me how to change position of each item.
    Thanks & regards,
    Edited by: Ketkee Bhale on Sep 14, 2011 3:58 PM

    Moderator message - Cross post locked
    Rob

  • How to add a navigation Panel and Zoom Slider Bar using Java API

    Hello,
    I am using Mapviewer Java bean as I have to use Oracle Mapviewer in Java Stanalone application.Please can anyone tell me how to add a Navigation panel and Zoom Slider in Java API. I found the API s for same in Java Script but not in Java.Kindly help.
    I am using Oracle Mapviewer 11g.

    This is forum sponsored by Adobe make of Acrobat and Reader. Since Chrome and FireFox web browser have chosen to use their own viewer you might get more help in their forums or customer support.

  • How to view the program panel in full screen mode?

    I know how to make the program panel full screen using the "~" key, but I would like to view my work completely without borders. Similar to using Quicktime or Windows media player. I can't imagine that this feature doesn't exist. Any help would be greatly appreciated.

    This feature is new to CS6. Hit ctrl+` (ctrl+grave).

  • How to I remove the 'panel' underneath the Header list, and above the mail Preview pane. Contains 'from' 'subject' 'reply' buttons to name a few. Takes up too much space.

    How do I remove the 'panel' underneath the Header list, and above the email Preview Pane. Contains 'from', 'subject', 'to', 'reply', 'forward' buttons to name a few. Takes up space.
    == This happened ==
    Every time Firefox opened

    setSize (600, 200);orpack ();Kind regards,
      Levi
    PS:
        int i;
    parses to
    int i;
    , but
    [code]    int i;[code[i]]
    parses to
        int i;

  • How would i move a panel in a custom component ?

    Hi All
    I have a custom VGroup component that i am using for navigation on a web application.  In the VGroup i have 6 Panels and inside each Panel between 3 & 10 LinkButtons.  How would i move a Panel to below the first Panel of the VGroup Component, based on which LinkButton the User clicked ?
    This is roughly how my component looks
    <s:VGroup id="appNav">
    <s:Panel id="p1">
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    </s:Panel>
    <s:Panel id="p2">
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    </s:Panel>
    <s:Panel id="p3">
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    </s:Panel>
    <s:Panel id="p4">
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    </s:Panel>
    <s:Panel id="p5">
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    </s:Panel>
    <s:Panel id="p5">
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    <mx:LinkButton />
    </s:Panel>
    </s:VGroup>
    Many Thanks
    Whitetimer

    in your function it should be as simple as appNav.setChildIndex(p4,1);

  • Why does the content spill over and how do I position this under the menu and title?

    I was following this tutorial on how to add a scrolling image gallery to a Flash website.
    (http://www.republicofcode.com/tutorials/flash/xmlimagegallery/index.php)
    From what I understand from this tutorial, it is just a matter of copying the Actionscript code and pasting it onto the timelines then making modifications on the XML.
    (kindly see a screenshot of timeline layers I made and as to where I put the Actionscript code:
    http://i429.photobucket.com/albums/qq19/tsujzpie/imagegalleryproblem_01.jpg )
    I pasted the code onto the blank keyframe labeled "Gallery"...
    But all I get is this weird effect when I click on the button for the gallery...
    (kindly see a screenshot of it here: http://i429.photobucket.com/albums/qq19/tsujzpie/imagegalleryproblem_02.jpg )
    When you put a blank keyframe on a timeline, any content put in there is supposed to only be contained in that very frame, right? How come then that - whenever the gallery button is clicked on - the content from that section spills out onto the other sections even when I click on other button for the other areas?
    I just really couldn't think why this is happening - any reason why this is so?
    And how do I position the gallery right under the section header and menu bar?
    Here is its AS2 code, by the way:
              import mx.transitions.Tween;
              import mx.transitions.easing.*;
              var myGalleryXML = new XML();
              myGalleryXML.ignoreWhite = true;
              myGalleryXML.load("gallery.xml");
              myGalleryXML.onLoad = function() {
                        _root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x;
                        _root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;
                        _root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;
                        _root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;
                        _root.myImages = myGalleryXML.firstChild.childNodes;
                        _root.myImagesTotal = myImages.length;
                        _root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;
                        _root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;
                        _root.full_x = myGalleryXML.firstChild.attributes.full_x;
                        _root.full_y = myGalleryXML.firstChild.attributes.full_y;
                        callThumbs();
                        createMask();
                        scrolling();
              function callThumbs() {
                        _root.createEmptyMovieClip("container_mc",_root.getNextHighestDepth());
                        container_mc._x = _root.gallery_x;
                        container_mc._y = _root.gallery_y;
                        var clipLoader = new MovieClipLoader();
                        var preloader = new Object();
                        clipLoader.addListener(preloader);
                        for (i=0; i<myImagesTotal; i++) {
                                  thumbURL = myImages[i].attributes.thumb_url;
                                  myThumb_mc = container_mc.createEmptyMovieClip(i,           container_mc.getNextHighestDepth());
                                  myThumb_mc._y = _root.thumb_height*i;
                                  clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);
                                  preloader.onLoadStart = function(target) {
                                            target.createTextField("my_txt",target.getNextHighestDepth          (),0,0,100,20);
                                            target.my_txt.selectable = false;
                                  preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
                                            target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
                                  preloader.onLoadComplete = function(target) {
                                            new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
                                            target.my_txt.removeTextField();
                                            target.onRelease = function() {
                                                      callFullImage(this._name);
                                            target.onRollOver = function() {
                                                      this._alpha = 50;
                                            target.onRollOut = function() {
                                                      this._alpha = 100;
              function callFullImage(myNumber) {
                        myURL = myImages[myNumber].attributes.full_url;
                        myTitle = myImages[myNumber].attributes.title;
                        _root.createEmptyMovieClip("fullImage_mc",_root.getNextHighestDepth());
                        fullImage_mc._x = _root.full_x;
                        fullImage_mc._y = _root.full_y;
                        var fullClipLoader = new MovieClipLoader();
                        var fullPreloader = new Object();
                        fullClipLoader.addListener(fullPreloader);
                        fullPreloader.onLoadStart = function(target) {
                                  target.createTextField("my_txt",fullImage_mc.getNextHighestDepth          (),0,0,200,20);
                                  target.my_txt.selectable = false;
                        fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
                                  target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
                        fullPreloader.onLoadComplete = function(target) {
                                  new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
                                  target.my_txt.text = myTitle;
                        fullClipLoader.loadClip("full_images/"+myURL,fullImage_mc);
              function createMask() {
                        _root.createEmptyMovieClip("mask_mc",_root.getNextHighestDepth());
                        mask_mc._x = _root.gallery_x;
                        mask_mc._y = _root.gallery_y;
                        mask_mc.beginFill(0x000000,100);
                        mask_mc.lineTo(_root.gallery_width,0);
                        mask_mc.lineTo(_root.gallery_width,_root.gallery_height);
                        mask_mc.lineTo(0,_root.gallery_height);
                        mask_mc.lineTo(0,0);
                        container_mc.setMask(mask_mc);
              function scrolling() {
                        _root.onEnterFrame = function() {
                                  container_mc._y += Math.cos(((mask_mc._ymouse)/mask_mc._height)          *Math.PI)*15;
                                  if (container_mc._y>mask_mc._y) {
                                            container_mc._y = mask_mc._y;
                                  if (container_mc._y<(mask_mc._y-(container_mc._height-mask_mc.          _height))) {
                                            container_mc._y = mask_mc._y-(container_mc._height-          mask_mc._height);

    You should create a manually movieclip symbol with nothing in it and take a copy of it from the library and place it in the frame where you intend for the gallery to display.  Give it an instance name of "container_mc" and remove the following line from your callThumbs function
    _root.createEmptyMovieClip("container_mc",_root.getNextHigh estDepth());
    You probably need to do the same for the mask and the full images since they appear to also be created using dynamic mc's.

  • How do i position a dialog popup box when it opens???

    i'm using the adf faces to follow a navigation link (dialog:addUser) to a new dialog popup page. all is working great; i am able to return the values in the popup as expected.
    what i can't find is how do i position this popup when it opens? i don't want it in the upper left over the calling page...i want to move it over and down so it appears to be more centered. can this be done? there's an attribute for height and one for width but not one for upper left X and Y positions that i can find.
    thanks for any support on this.

    apparently, i'm using the defaults as I don't have any idea as to that attribute. i searched for the showPopupBehavior and it's nowhere in my application. btw: i'm using jDeveloper 10.1.3.4

Maybe you are looking for