JPanel won't display in BoxLayout when adding components in different order

For some reason when I run this code, the topPanel (made up of two panels which are all JLabels, JButtons, and JTextFields) does not display on the screen, but the investmentPanel (JTable within a JScrollPane) does. But when I add them in the reverse order, they both show up, but not in the order I want them to. The JPanel I am adding to is maximized so that shouldn't be an issue. Any thoughts of why this is happening?
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
JPanel topPanel = new JPanel();
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
topPanel.add(companyInfoPanel);
topPanel.add(tradePanel);
add(topPanel);
add(investmentPanel);

Your best bet here is to show us your code. We don't want to see all of it, but rather you should condense your code into the smallest bit that still compiles, has no extra code that's not relevant to your problem, but still demonstrates your problem, in other words, an SSCCE (Short, Self Contained, Correct (Compilable), Example). For more info on SSCCEs please look here:
http://homepage1.nifty.com/algafield/sscce.html

Similar Messages

  • When added a single purchase order the order being duplicated..

    In 2007A SP01 PL10
    When added a single purchase order, the order being duplicated into two different orders numbers in the system..
    the problem is Inconsistent and occurs several times a  day.
    Does anyone know \ heard about the problem??
    Thank You!
    Meital

    Are the duplicated PO's created by the add on, or through the application?
    We do have a customer who is getting duplicated SO / PO/ Cash sale invoices at the rate of a few per month. They have an add on running as well and we have been unable to solve the issue for them.
    The rate did improve after upgrading to SP01, but the issue has not disappeared.
    There was another thread a while ago about someone getting duplicated credit notes, they also had an add on running but the add on was unrelated to credit notes.

  • JPanel won't display my custome component

    Hi,
    I made a custome component class that in its paint method at this stage is suppose to paint a white rectangle on screen. However the when I add this custome component to my JPanel it doesn't show up. Does anybody have a solution for this?
    My code for the custome component is,
    public spaceMediaDisplayObject(mediaObject mo){
         x = mo.getSpaceX();
         y = mo.getSpaceY();
         height = mo.getHeight();
         width = mo.getWidth();
         name = mo.getName();
         System.out.println("Constructor");
         this.repaint();
    public void paint(Graphics g){
         System.out.println("Draw");
         g.setColor(Color.white);
         g.drawRect(x, y, height, width);
    And the fragment of code I am using to try and display in on the panel is as follows,
    spaceMediaDisplayObject smdo = new spaceMediaDisplayObject(toDisplay);
         spaceBodyPanel.add(smdo);
    Please help if able.

    If it's null then you need to set the size of each component explicitly:
    JPanel panel = new JPanel(null);
    Component customComponent = new CustomComponent();
    panel.add(customComponent);
    customComponent.setBounds(0, 0, 100, 100); // For exampleA simple layout manager could be used to make the component fill the panel, for example:
    JPanel panel = new JPanel(new GridLayout(1, 1));
    panel.add(new CustomComponent());Hope this helps.

  • Custom JPanel won't display

    I am building a GUI in NetBeans and am running into some trouble. I have created a class that extends JPanel that I wish to display in a tabbed pane. When I add it to the tabbed pane in the GUI Builder, it adds, although it doesn't display its elements. When I run it, it doesn't display at all. I have stepped through it in the debugger, and the constructor is executed just fine. I don't want to post a bunch of code just yet, because I imagine my problem is something simple. What is the best way to create a custom JPanel like this and add it to another JPanel?

    JPanel jp = new JPanel();
    myJPanel mp = new myJPanel();
    mp.add(mp);The first thing I'll tell you is to check your code for empty catch's.

  • I have a full screen Frame that won't display a List when I add it

    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.net.Socket;
    import java.net.InetAddress;
    import java.util.Scanner;
    public class Main {
        //the Main Frame to draw to
        static Framex f = new Framex();
        //login components
        static Panel top = new Panel();
        static JTextField username = new JTextField("ajtgarber", 20);
        static JPasswordField password = new JPasswordField("garber", 20);
        static JButton login = new JButton("Logon");
        static JButton quit = new JButton("Quit");
        static Label loginM = new Label("Please enter your username and password");
        static List CharList = new List();
        //networking components
        static Socket s =  null;
        static PrintStream stringOut = null;
        static Scanner stringIn = null;
        //main method
        public static void main(String[] args) {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gd = ge.getDefaultScreenDevice();
            f.setBackground(Color.BLACK);
            f.setUndecorated(true);
            f.setResizable(false);
            f.setLayout(new BorderLayout());
            top.add(username);
            top.add(password);
            top.add(login);
            top.add(quit);
            top.add(loginM);
            f.add(top, BorderLayout.NORTH);
            Image background = Toolkit.getDefaultToolkit().getImage("lakeview.jpg");
            //f.drawImage(background);
            gd.setFullScreenWindow(f);
            logon_setup();
            f.setSize(500,500);
            f.setVisible(true);
        //method for setting up actionlisteners for the login components
        public static void logon_setup() {
            quit.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    shutdown();
                    System.exit(0);
            login.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    attempt_login();
            password.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    attempt_login();
            //quit.setForeground(Color.WHITE);
            //login.setForeground(Color.WHITE);
            loginM.setForeground(Color.WHITE);
            CharList.setVisible(false);
        //attempts to login
        public static void attempt_login() {
            loginM.setText("Logging in Please Wait...");
            f.repaint();
            try {
                s = new Socket(InetAddress.getByName("127.0.0.1"), 2000);
                stringOut = new PrintStream(s.getOutputStream());
                stringIn = new Scanner(s.getInputStream());
                stringOut.println("Login||"+username.getText()+"||"+new String(password.getPassword()));
                String str = stringIn.nextLine();
                if(str.equals("Login 0x248")) {
                    loginM.setText("");
                    char_login();
                else if(str.equals("Invalid 0x248")) {
                    loginM.setText("Invalid Username or Password!");
            } catch(IOException ex) {
                loginM.setText("Unable to Connect!");
            } catch(Exception ex) {
                ex.printStackTrace();
        //gives the user the character selection screen
        public static void char_login() {
            try {
                //username.setVisible(false);
                //password.setVisible(false);
                //quit.setVisible(false);
                //login.setVisible(false);
                loginM.setText("Getting Character List...");
                stringOut.println(username.getText()+"||charREQ"); //request character list
                ObjectInputStream ois = new ObjectInputStream(s.getInputStream());
                CharList = (List) ois.readObject();
                System.out.println("Received CharList from Server");
                loginM.setText("");
                f.remove(top);
                f.add(CharList, BorderLayout.EAST);
                System.out.println("Char: "+CharList.getItem(0));
                f.repaint();
            } catch(Exception ex) {
                ex.printStackTrace();
        //method for ending the connection
        public static void shutdown() {
            try {
                s.close();
            } catch(Exception ex) {
    class Framex extends Frame {
        private Image image = null;
        public Framex() {
           super();
        public void drawImage(Image i) {
           image = i;
           repaint();
        public void paint(Graphics g) {
            if(image != null) {
                 g.drawImage(image, 0, 0, this);
    }The Server and Client are a work in progress but Other than that why won't the List show up immediately after
    I add it to the Frame?

    Don't mix AWT and Swing widgets. Fix that, then ask again, preferably in the Swing section.

  • Tree display not updating when adding first node to expanded node

    Hi
    Please have a look at the following code. To reproduce the faulty behaviour you have to expand the item, then click "add" button and observe, that nothing happens. Collapsing, then expanding the node shows the added children. I use Flex 3.5.0
    Is this a bug in the SDK or am I missing some auto update switch?
    Thanks!!
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
         minWidth="955" minHeight="600"
         creationComplete="run()">
         <mx:Tree id="tree" width="300" height="500" labelField="name" />
         <mx:Button label="add" click="onClickAdd()" />
         <mx:Script>
              <![CDATA[
                   import mx.collections.ArrayCollection;
                   import mx.utils.ObjectProxy;
                   protected var itm1:Object;
                   protected function run() : void
                        var ac:ArrayCollection = new ArrayCollection();
                        this.itm1 = new ObjectProxy({name:"1", children:new ArrayCollection()});
                        ac.addItem(this.itm1);
                        this.tree.dataProvider = ac;
                   protected function onClickAdd() : void
                        this.itm1.children.addItem({name:"child"});
              ]]>
         </mx:Script>
    </mx:Application>

    Yep, that works! Thanks! Would have never thought of that...
    Here is my modified code:
              <mx:Tree id="tree" width="300" height="500" labelField="name"
              dataDescriptor="{new DefaultDataDescriptor2()}"
              />
    and new class
    package de.byteconsult.controls.tree
         import mx.collections.ICollectionView;
         import mx.controls.treeClasses.DefaultDataDescriptor;
         public class DefaultDataDescriptor2 extends DefaultDataDescriptor
              public function DefaultDataDescriptor2()
                   super();
              override public function hasChildren(node:Object, model:Object=null) : Boolean
                   var children:ICollectionView = this.getChildren(node, model);
                   return children != null;

  • Migration assistant won't display the 'passcode' on my old PC in order for me to continue.

    When I start migration assistant it will recognise my old PC laptop however when the passcode is displayed on my Mac it will not display it on the PC in order for me to confirm and continue. Any help? Thanks.

    See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...  Be sure to Follow ALL the Steps...
    Take your time... Pay particular attention to Steps 3 and 4.
    Make sure you have the Current Version of iTunes Installed on your computer
    iTunes free download from www.itunes.com/download
    After you have Recovered your Device...
    Re-Sync your Content or Restore from the most recent Backup...
    Restore from Backup  >  http://support.apple.com/kb/ht1766

  • Function Module for adding components to Production Order

    Is there a function module that can add components to an existing production order ?I believe CO_BC_INSERT_CMP_OF_ORDERS can do the trick but seems this alone would not suffice .Your feedback is very much appreciated

    Sudhir,
    U r right. we need to call the function module CO_BC_INSERT_CMP_OF_ORDERS with flg_banf_create  = X and apt entries in the component details table resbb_ins. Doing this is enough. I guess u have a problem passing correct data in the internal table. For the data you do not know, you will have to pass default data.
    Hope this helps.

  • Hp 110-a04 won't display video when my 5670 is plugged in.

    So here's the dealio. Bought a myself an hp 110-a04, threw in the sapphire 5670, doesn't display anything and I get a 6 long beeps beep code. Kill me.
    So, I take out the original PSU (it's only 180 watts), throw in a 400 watt power supply,  toss in the GPU aaaaannnnnnd... still won't display anything and the beep code is back (in the old PC it was in worked fine with the 250 watt psu).
    The computer works perfectly fine without the card, boots up, actaully displays stuff when plugged by VGA. Why it won't display anything is absolutely beyond me. Everything is hooked up to the new PSU, it's just that nothing works with that graphics card in.
    Halp me.

    Hello @HAIRSHAMENSTUFF,
    I understand that you are having issues getting the sapphire 5670 to work with your HP 110-a04 Desktop PC. I suspect that you will have to enable legacy devices in your BIOS. Unfortunately, I do not have access to the BIOS for your computer to provide you with step by step instructions, but if you tap F10 on startup and enter the BIOS you can browse through until you find a way of enabling legacy support or mode.
    I hope this helps. Thank you for posting on the HP Forums. Have a great day!
    Please click the "Thumbs Up" on the bottom right of this post to say thank you if you appreciate the support I provide!
    Also be sure to mark my post as “Accept as Solution" if you feel my post solved your issue, it will help others who face the same challenge find the same solution.
    Dunidar
    I work on behalf of HP
    Find out a bit more about me by checking out my profile!
    "Customers don’t expect you to be perfect. They do expect you to fix things when they go wrong." ~ Donald Porter

  • When adding bookmarks and trying to changing its name, Firefox won't allow using the mouse; Firefox will only allow using the arrow keys (MAC OS 10.5, Firefox 3.6.8)

    When adding a bookmark sometimes the web page name is too long. I used to be able to use my mouse, highlight the letters/words that I don't want, then use delete to truncate the desired bookmark name. Since the latest update/upgrade, Firefox won't let me use the mouse to click anywhere in the popup box. I can only use the arrow keys and the delete key.
    Nothing other than updates (using Mac Software Update and Firefox Update) has been done to this computer (it's a 2002 Power Mac G4-Dual 1.25GHz).

    When adding a bookmark sometimes the web page name is too long. I used to be able to use my mouse, highlight the letters/words that I don't want, then use delete to truncate the desired bookmark name. Since the latest update/upgrade, Firefox won't let me use the mouse to click anywhere in the popup box. I can only use the arrow keys and the delete key.
    Nothing other than updates (using Mac Software Update and Firefox Update) has been done to this computer (it's a 2002 Power Mac G4-Dual 1.25GHz).

  • [svn:fx-trunk] 12542: When adding a mask to the display list need to validate it and all its children .

    Revision: 12542
    Revision: 12542
    Author:   [email protected]
    Date:     2009-12-04 10:38:32 -0800 (Fri, 04 Dec 2009)
    Log Message:
    When adding a mask to the display list need to validate it and all its children.  Previously the children were not validated and their display list was updated before properties were committed or measure was done.  RichText was not set up to handle this.
    QE notes:
    Doc notes:
    Bugs: SDK-24511
    Reviewer:  Evtim, Deepa
    Tests run: checkintests, fxg, primitives, Group
    Is noteworthy for integration: no
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-24511
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/supportClasses/GroupBase.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/utils/MaskUtil.as

    AFAIK, the only way to do this is to write a system modifcation.
    The BADI is executed only once at startup of the session, so that makes it merely static. (A strange point in time, I discussed it with SAP and they just shook their heads)
    I had the same problem with some other F4-Helps and it was a big hazzle. From my experience, no straight answer.

  • Error message displayed when adding Wiki entry

    When adding a new WIKI entry in Teaming 2, this error message is sometime displayed:
    class org.kablink.teaming.module.binder.impl.WriteEntryD ataException
    Frequently, Teaming 2 seems to stop responding and the web page will time out.
    Any ideas?

    johnefleming,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://support.novell.com/forums/

  • Layered text and graphic in Word won't display when converted to PDF

    I have several simple shapes with text layered in front in my Word document. After they are converted to PDF using Acrobat XI, only the shape will display. I can tell the text is still there, because I can use my cursor tool to select it, but it won't display visually. It looks like it isn't there but it really is. One bit of text is even an internal link, and the link still works but I can't see the text I'm clicking on.
    If anyone has any suggestions I'd appreciate it.
    Thank you,

    Hi Lori - this was perfect! It was an issue with the layers being misordered. I used the Edit Text & Images tool listed under Tools > Content Editing, found the layers, then by right-clicking I was able to bring the text to the front and it all looks great now.
    I would like to know why this happened, or if not why, how I could make sure it doesn't happen again. If there's a check box or other setting I could use to remove this problem that would be fantastic.
    Thank you so much for pointing me in the right direction!
    -Scott

  • Need help:JPanel not being displayed in the JFrame

    Hello,
    I have a class called ConstructRoom.java which extends JFrame and another class called DimensionsPanel.java which extends JPanel. In the ConstructRoom class I use the following theContainer.add(new DimensionsPanel());, so I can display my JPanel. Well I get the JFrame but no JPanel. When the this call is made the DimensionsPanel.java code is cycled through, Where has my JPanel gone to?
    If I change the DimensionPanel.java extend JFrame and add the the JFrame code. Then I get the JFrame and the JPanel.
    Whats going on here?
    Thanks

    I made some of the changes with no luck. Here is some of the code:
    ---------from ConstructRoom.java--------
    //Imports
    public class ConstructRoom extends JFrame
    //----Member objects and varibles
    private static String theTitle; //Varible for title of frame
    private JFrame theFrame; //Object for the JFrame
    // ----------------------------------------------------------- ConstructRoom
    public ConstructRoom(String theTitle)
    super(theTitle); //JFrame super class
    theFrame = new JFrame("My frame");
    Container theContainer = theFrame.getContentPane(); //Frame container
    theContainer.setLayout(new FlowLayout());
    theContainer.add(new DimensionsPanel());
    theFrame.pack();
    theFrame.setBounds(10,10,400, 400);
    theFrame.addWindowListener(new WindowHandler());
    theFrame.setVisible(true);
    }//end ConstructRoom(String theTitle)
    // -------------------------------------------------------------------- main
    public static void main(String args[])
    ConstructRoom theRoom = new ConstructRoom(theTitle);
    }//end main(String args[])
    //----WindowHander
    }//end class ConstructRoom extends JFrame
    --------from DimensionsPanel.java
    //Imports
    public class DimensionsPanel extends JPanel
    //----Member objects and varibles
    private JPanel dimensionsPanel; //The main panel to hold all info
    private Box panelBox; //Box for all boxes which is added to the JPanel
    private Box furnListBox; //Box for all related items of the furnList
    private Box dimensionsBox; //Box for all dimensions (x, y, z)
    private Box xFieldBox; //Box for all related items of the xField
    private Box yFieldBox; //Box for related items of the yField
    private Box zFieldBox; //Box for related items of the zField
    private Box buttonsBox; //Box for all buttons
    private Box clearBox; //Box for related clear button items
    private Box buildBox; //Box for related build button items
    private JLabel furnListLabel; //Label for the furnList comboBox
    private JLabel xFieldLabel; //Label for the xField
    private JLabel yFieldLabel; //Label for yField
    private JLabel zFieldLabel; //Label for zField
    private JTextField xField; //Text field to enter the x dimension
    private JTextField yField; //Text field to enter the y dimension
    private JTextField zField; //Text field to enter the z dimension
    private JComboBox furnList; //List of selectable furniture objects
    private JButton clearButton; //Clear button
    private JButton buildButton; //Build button
    // --------------------------------------------------------- DimensionsPanel
    public DimensionsPanel()
    //----Setting up dimensions panel
    dimensionsPanel = new JPanel();
    dimensionsPanel.setLayout(new BorderLayout());
    dimensionsPanel.setPreferredSize(new Dimension(150,150));
    dimensionsPanel.setBorder(new TitledBorder(new EtchedBorder(),
    "Select Furniture and Enter Dimensions"));
    //----Initializing GUI components
    furnListLabel = new JLabel("Select from list ");
    furnList = new JComboBox();
    xFieldLabel = new JLabel("Enter Width ");
    xField = new JTextField();
    yFieldLabel = new JLabel("Enter Height ");
    yField = new JTextField();
    zFieldLabel = new JLabel("Enter Depth ");
    zField = new JTextField();
    buildButton = new JButton("Build Object");
    clearButton = new JButton("Clear Object");
    //-----Setting up the combo box and adding items
    furnList.addActionListener(new ComboProcessor());
    furnList.addItem(" "); //Default item
    furnList.addItem("Color Cube");
    furnList.setMaximumRowCount(6); //Max number of items before scrolling
    furnList.setSelectedItem(" "); //Set initial to default item
    //--Add the furnList to its box for placement in the JPanel
    furnListBox = Box.createHorizontalBox();
    furnListBox.add(Box.createHorizontalStrut(5));
    furnListBox.add(furnListLabel); //Adding the combo box label
    furnListBox.add(furnList); //Adding the combo box
    furnListBox.add(Box.createHorizontalStrut(5)); //Spacing
    //-------------------------------- Start Dimensions Components
    //----Setting up the xField
    xField.setEnabled(false); //Disabled at start
    xField.setFocusTraversalKeysEnabled(false); //Disabling the Tab Key
    //----Adding the event listeners
    xField.addActionListener(new XTextProcessor()); //Enter Key
    xField.addMouseListener(new ClickProcessor()); //Mouse Click
    //--Add the xField to its box for placement in the dimensionsBox
    xFieldBox = Box.createHorizontalBox();
    xFieldBox.add(Box.createHorizontalStrut(10)); //Spacing
    xFieldBox.add(Box.createGlue()); //Take up extra space
    xFieldBox.add(xFieldLabel); //Adding the text field label
    xFieldBox.add(xField); //Adding the text field
    xFieldBox.add(Box.createHorizontalStrut(100)); //Spacing
    //----Setting up the yfield
    yField.setEnabled(false); //Disabled at start
    yField.setFocusTraversalKeysEnabled(false); //Disabling TAB KEY
    //----Adding the event listeners
    yField.addActionListener(new YTextProcessor()); //Enter Key
    yField.addMouseListener(new ClickProcessor()); //Mouse Click
    //--Add the yField to its box for placement in the dimensionsBox
    yFieldBox = Box.createHorizontalBox();
    yFieldBox.add(Box.createHorizontalStrut(10)); //Spacing
    yFieldBox.add(Box.createGlue()); //Take up extra space
    yFieldBox.add(yFieldLabel); //Adding the text field label
    yFieldBox.add(yField); //Adding the text field
    yFieldBox.add(Box.createHorizontalStrut(100)); //Spacing
    //----Setting up the zfield
    zField.setEnabled(false); //Disabled at start
    zField.setFocusTraversalKeysEnabled(false); //Disabling TAB KEY
    //----Adding the event listeners
    zField.addActionListener(new ZTextProcessor()); //Enter Key
    zField.addMouseListener(new ClickProcessor()); //Mouse Click
    //--Add the zField to its box for placement in the dimensionsBox
    zFieldBox = Box.createHorizontalBox();
    zFieldBox.add(Box.createHorizontalStrut(10)); //Spacing
    zFieldBox.add(Box.createGlue()); //Take up extra space
    zFieldBox.add(zFieldLabel); //Adding the text field label
    zFieldBox.add(zField); //Adding the text field
    zFieldBox.add(Box.createHorizontalStrut(100)); //Spacing
    //----Adding all dimension components to the dimensionsBox
    dimensionsBox = Box.createVerticalBox();
    dimensionsBox.add(xFieldBox); //Adding the xFieldBox
    dimensionsBox.add(Box.createVerticalStrut(10)); //Spacing
    dimensionsBox.add(yFieldBox); //Adding the yFieldBox
    dimensionsBox.add(Box.createVerticalStrut(10)); //Spacing
    dimensionsBox.add(zFieldBox); //Adding the zFieldBox
    //-------------------------------- End Dimension Components
    //----Setting up the clearButton
    clearButton.setEnabled(false); //Disabled at start
    //----Adding the event listener
    clearButton.addActionListener(new ClearProcessor());
    //--Add the clear button to its box for placement
    clearBox = Box.createHorizontalBox();
    clearBox.add(Box.createHorizontalStrut(5)); //Spacing
    clearBox.add(clearButton); //Adding the clearButton
    //----Setting up the buildButton
    buildButton.setEnabled(false); //Disabled at start
    //--Add the action listener here
    buildBox = Box.createHorizontalBox();
    buildBox.add(buildButton); //Adding the buildButton
    buildBox.add(Box.createHorizontalStrut(5)); //Spacing
    //----Adding both buttons the buttonsBox
    buttonsBox = Box.createHorizontalBox();
    buttonsBox.add(clearBox); //Adding the clearBox
    buttonsBox.add(Box.createHorizontalStrut(10)); //Spacing
    buttonsBox.add(buildBox); //Adding the buildBox
    //----Create the JPanel (dimensionsPanel)
    //--Creating the main box to be added to the JPanel
    panelBox = Box.createVerticalBox();
    panelBox.add(furnListBox); //Adding the furnListBox components
    panelBox.add(Box.createVerticalStrut(10)); //Spacing
    panelBox.add(dimensionsBox); //Adding the dimensionBox components
    panelBox.add(Box.createVerticalStrut(10)); //Spacing
    panelBox.add(buttonsBox); //Adding the buttonsBox components
    panelBox.add(Box.createVerticalStrut(10)); //Spacing
    dimensionsPanel.add(panelBox); //Adding all components to the JPanel
    System.out.println("end dimensionpanel");
    }//end DimensionsPanel()
    //------ActionListeners
    }//end class DimensionsPanel extends JPanel

  • Adding Components to a JPanel not working correctly

    I'm trying to build a JFrame that contains a parent JPanel that will hold a JPanel used to display a message view, a vertical strut and a JPanel that holds VCR-like buttons to cycle through the messages.
    My parent JPanel uses a BorderLayout and the Border is a TitledBorder which tells which product you are viewing (i.e., Message 1 of 5). I build the message JPanel, vertical strut and button JPanel and add them all in order to the parent JPanel which then gets added to the rootContentPane of the JFrame. All that appears is the parent JPanel's TitledBorder, the strut and the button JPanel. Using JSwat, I've been able to determine that the message JPanel has 0 for both its height and width after adding the message components to the JPanel.
    I create the message JPanel with a BorderLayout and an OvalBorder as copied from Manning Press's Swing book (which works fine in other JFrames that I have built), then add other components as necessary to the individual messages (mostly items around the edges with a central display for the actual message). What I can't figure out is why the height and width of the message JPanel isn't growing as I add components.
    I had previously used the same code to display a single message (minus the parent JPanel, strut and button JPanel) where I added the border panels (northPanel, eastPanel, southPanel and westPanel) created in createMsgPanel() directly to the contentPane and it worked perfectly, so I know that the code that adds the message works fine. Then, the requirements changed (go figure) and I had to display multiple messages from the same screen.
    Here's what I've got:
    public class Layout
                 extends JFrame
                 implements ActionListener
       private MissionData missionData;
       private JPanel messagePanel = null;
       private int index = 0;
       private int numMsgs = 0;
       private JPanel mainPanel = null;
       private JPanel buttonPanel = null;
       private TitledBorder titledBorder = null;
       Layout ()
       public Layout (MissionData msn)
          super ();
          missionData = msn;
          setSize (640, 640);
          setIconImage (new ImageIcon ("Icon.jpg").getImage());
          setTitle (((Message) (missionData.messages.elementAt(0))).name);
          numMsgs = missionData.messages.size();
          titledBorder = new TitledBorder (
                            new LineBorder (Color.BLACK),
                            "Message " + String.valueOf (index + 1) +
                            " of " + String.valueOf (numMsgs),
                            TitledBorder.LEFT,
                            TitledBorder.TOP);
          mainPanel = new JPanel ();
          mainPanel.setLayout (new BorderLayout());
          mainPanel.setBorder (new CompoundBorder (titledBorder,
                                                   new EmptyBorder (
                                                      new Insets (3, 3, 3, 3))));
          messagePanel = new JPanel();
          messagePanel.setLayout (new BorderLayout ());
          messagePanel.setBorder (new CompoundBorder (
                                     new EmptyBorder (50, 50, 50, 50),
                                     new OvalBorder (20, 20, Color.white)));
          messagePanel.setBackground (Color.black);
          createButtonPanel ();
          createMsgPanel ((Message) missionData.messages.elementAt (0));
          mainPanel.add (messagePanel);
          mainPanel.add (Box.createVerticalStrut (20));
          mainPanel.add (buttonPanel);
          Container mainContentPane = getContentPane();
          mainContentPane.add (mainPanel);
       private void createMsgPanel (Message msg)
          MessageType msgType = null;
          if (msg.getFunctionalAreaDesignator(0) == Message.GENERAL_INFO)
             if (msg.getMessageNumber(0) == 1)
                msgType = FREE_TEXT;
          else if (msg.getFunctionalAreaDesignator(0) == Message.SUPPORT)
             if (msg.getMessageNumber(0) == 33)
                msgType = CAS;
             else if (msg.getMessageNumber(0) == 34)
                msgType = OSR;
          // Setup NORTH Panel of Display
          JPanel northPanel = new JPanel (new GridLayout (2, 6));
          northPanel.setBackground (Color.black);
          northPanel.add (new JTIMLabel ("", false));
          northPanel.add (new JTIMLabel ("<html>RECV</html>", false));
          if (msgType == CAS)
             northPanel.add (new JTIMLabel ("<html>PCLR</html>", false));
             northPanel.add (new JTIMLabel ("<html>MSN</html>", false));
             northPanel.add (new JTIMLabel ("<html>SAVE</html>", false));
          else if (msgType == OSR)
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
          else if (msgType == FREE_TEXT)
             northPanel.add (new JTIMLabel ("<html>ERASE</html>", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("<html>BRDCST</html>", false));
          northPanel.add (new JTIMLabel ("<html>SEND</html>", false));
          northPanel.add (new JTIMLabel ("", false));
          northPanel.add (new JTIMLabel ("", false));
          if (msgType == CAS)
             northPanel.add (new JTIMLabel ("<html>CAS</html>", false));
          else if (msgType == OSR)
             northPanel.add (new JTIMLabel ("<html>OSR</html>", false));
          else if (msgType == FREE_TEXT)
             northPanel.add (new JTIMLabel ("<html>FTXT</html>", false));
          if (msgType == FREE_TEXT)
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
          else
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("<html>CAS</html>", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
             northPanel.add (new JTIMLabel ("", false));
          messagePanel.add (northPanel, BorderLayout.NORTH);
          // Setup EAST Box of Display
          Box eastBox = new Box (BoxLayout.Y_AXIS);
          if (msgType == CAS)
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("<html>F<br>T<br>X<br>T</html>", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("<html>O<br>S<br>R</html>", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("<html>D<br>P<br>I<br>P</html>", false));
             eastBox.add (Box.createGlue());
          else if (msgType == FREE_TEXT)
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("", false));
             eastBox.add (Box.createGlue());
             eastBox.add (new JTIMLabel ("", false));
             eastBox.add (Box.createGlue());
          eastBox.add (new JTIMLabel ("<html>W<br>L<br>C<br>O</html>", false));
          eastBox.add (Box.createGlue());
          eastBox.add (new JTIMLabel ("<html>C<br>N<br>T<br>C<br>O</html>",
                                        false));
          eastBox.add (Box.createGlue());
          messagePanel.add (eastBox, BorderLayout.EAST);
          // Setup SOUTH Panel of Display
          JPanel southPanel = new JPanel (new GridLayout (2, 5));
          southPanel.setBackground (Color.black);
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("<html>ON</html>", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("", false));
          if (msgType == CAS)
             southPanel.add (new JTIMLabel ("<html>USE</html>", false));
             southPanel.add (new JTIMLabel ("<html>RCALL</html>", false));
          else if ((msgType == OSR) || (msgType == FREE_TEXT))
             southPanel.add (new JTIMLabel ("", false));
             southPanel.add (new JTIMLabel ("", false));
          southPanel.add (new JTIMLabel ("<html>MENU</html>", false));
          southPanel.add (new JTIMLabel ("<html>VMF</html>", false));
          if (msgType == CAS)
             southPanel.add (new JTIMLabel ("<html>NETS</html>", false));
          else if ((msgType == OSR) || (msgType == FREE_TEXT))
             southPanel.add (new JTIMLabel ("<html>CAS</html>", false));
          southPanel.add (new JTIMLabel ("", false));
          messagePanel.add (southPanel, BorderLayout.SOUTH);
          // Setup WEST Box of Display
          JTIMLabel incrLabel = null;
          JTIMLabel decrLabel = null;
          Box westBox = new Box (BoxLayout.Y_AXIS);
          if (msgType == FREE_TEXT)
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("", false));
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("", false));
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("", false));
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("<html>N<br>E<br>X<br>T</html>", false));
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("<html>P<br>R<br>E<br>V</html>", false));
          else
             westBox.add (Box.createGlue());
             westBox.add (new JTIMLabel ("<html>U<br>F<br>C</html>", false));
             westBox.add (Box.createGlue());
             if (msgType == CAS)
                westBox.add (new JTIMLabel ("<html>/\\</html>", false));
                westBox.add (Box.createGlue());
                westBox.add (new JTIMLabel ("<html>\\/</html>", false));
                westBox.add (Box.createGlue());
                incrLabel = new JTIMLabel ("<html>I<br>N<br>C<br>R</html>", false);
                westBox.add (incrLabel);
                westBox.add (Box.createGlue());
                decrLabel = new JTIMLabel ("<html>D<br>E<br>C<br>R</html>", false);
                westBox.add (decrLabel);
                westBox.add (Box.createGlue());
          messagePanel.add (westBox, BorderLayout.WEST);
          // Create CENTER Box to display message bodies
          GriddedPanel centerBox = new GriddedPanel ();
          centerBox.setBackground (Color.black);
          messagePanel.add (centerBox, BorderLayout.CENTER);
          if (msgType == CAS)
             new CASDisplay (msg, centerBox, incrLabel, decrLabel);
          else if (msgType == OSR)
             new OSRDisplay (msg, centerBox);
          else if (msgType == FREE_TEXT)
             new FreeTextDisplay (msg, centerBox);
       private void createButtonPanel ()
          // build the button panel
          buttonPanel = new JPanel ();
          buttonPanel.setLayout (new BoxLayout (buttonPanel, BoxLayout.X_AXIS));
          buttonPanel.setBorder (new LineBorder (Color.BLACK));
          // Create and add the buttons
          buttonPanel.add (createButton ("FIRST_BUTTON"));
          buttonPanel.add (createButton ("PREV_BUTTON"));
          buttonPanel.add (createButton ("NEXT_BUTTON"));
          buttonPanel.add (createButton ("LAST_BUTTON"));
       private JButton createButton (String buttonName)
          JButton button = new JButton ();
          button.addActionListener (this);
          button.setActionCommand (buttonName);
          Image image = null;
          String tooltip = "Press to go to the ";
          if (buttonName.equals ("FIRST_BUTTON"))
             image = new ImageIcon ("firstArrowIcon.gif").getImage();
             tooltip += "First";
          else if (buttonName.equals ("PREV_BUTTON"))
             image = new ImageIcon ("previousArrowIcon.gif").getImage();
             tooltip += "Previous";
          else if (buttonName.equals ("NEXT_BUTTON"))
             image = new ImageIcon ("nextArrowIcon.gif").getImage();
             tooltip += "Next";
          else if (buttonName.equals ("LAST_BUTTON"))
             image = new ImageIcon ("lastArrowIcon.gif").getImage();
             tooltip += "Last";
          tooltip += " message in the lst";
          button.setToolTipText (tooltip);
          button.setIcon (new ImageIcon (image.getScaledInstance (36, 36, Image.SCALE_FAST)));
          return button;
       public void actionPerformed (ActionEvent e)
          if (e.getActionCommand ().equals ("FIRST_BUTTON"))
             index = 0;
          else if (e.getActionCommand ().equals ("PREV_BUTTON"))
             if (index > 0)
                index--;
          else if (e.getActionCommand ().equals ("NEXT_BUTTON"))
             if (index < numMsgs - 1)
                index++;
          else if (e.getActionCommand ().equals ("LAST_BUTTON"))
             index = numMsgs - 1;
          titledBorder.setTitle ("Message " + String.valueOf (index + 1) +
                                 " of " + String.valueOf (numMsgs));
          createMsgPanel ((Message) missionData.messages.elementAt (index));
       private static class MessageType
                            extends EnumeratedType
                            implements Serializable
          final static long serialVersionUID = 1;
          protected MessageType (int value, String desc)
             super (value, desc);
       private static MessageType FREE_TEXT =
          new MessageType (0, "Free Text");
       private static MessageType CAS =
          new MessageType (1, "Call Accounting System");
       private static MessageType OSR =
          new MessageType (2, "Occupational Survey Report");
    }

    That's all well and good, but I've had more times that not where
    people want the entire program, not bits and pieces.Then you missed the whole point of that link.
    We don't want to see bits and pieces of code. We want to see an executable program, but we want an executable program the demonstrates the incorrect behaviour without all the unnecessary code. 90% of the code you posted was not related to your problem. That is we what you do to some basic debugging and remove the parts of code that are not related to the problem so we can concentrate on the code that is related to the problem.

Maybe you are looking for

  • Unable to select individual frames from entire mov file in iMovie

    I am trying to edit one long clip in iMovie from an iPhoto .mov file downloaded from a FlipCam. When I select the project from the library in iMovie, I cannot isolate frames to trim. The entire clip is repeatedly highlighted no matter what I do. I us

  • Event Receier to Save Document Library History in Custom List

    Hi All,         I have the document library which holds an excel document .And my client team will  update the excel document, such as making "check-in,check-out,editing the excel-sheet etc..) .      And my client wants to store the below info of thi

  • BW Problem Extracting Custom Hierarchy

    Hello Experts, I have built a completely new hierarchy of new custom master data in R3. I then have used BW07 to create a datasource to extract the hierarchy data with no problems. I have then created a new infoobject in BW and I have successfully lo

  • Cannot launch After Effects CS6 or CC HELP!!!

    When i try to launch CS6 I get this message: You can't use this version of the application "Adobe After Effects CS6" with this verson of OS X. You have "Adobe After Effects CS6" 11.0 When i try to launch CC this message: You can't use this version of

  • Drivers do not get installed

    I am using the hugely popular method of creating OS > Architecture > Make > Model hierarchy in Out-of-box drivers then within task sequence setting DriverGroup001 to path above (Windows 7 x64\%Make%\%Model%) and setting Inject Drivers to Nothing. htt