# Java layout problem

**URL:** https://forum.kirupa.com/t/java-layout-problem/243869
**Category:** programming
**Created:** [November 12, 2007, 2:51am UTC](https://forum.kirupa.com/t/java-layout-problem/243869 "2007-11-12T02:51:21Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![FirePenguins](https://avatars.discourse-cdn.com/v4/letter/f/e95f7d/32.png) [@FirePenguins](https://forum.kirupa.com/u/FirePenguins)
#### Post date: [November 12, 2007, 2:51am UTC](https://forum.kirupa.com/t/java-layout-problem/243869/1 "2007-11-12T02:51:21Z")

</div>

Hi, this is my first post here. Been lurking around for awhile though 😉 making use of all the great posts, tutorials, guides, etc… Anyways I’ve got a problem with my layout for a java applet and maybe some one can help. Thanks!!

So basically what I want is for there to be a JTextField (chatInput) at the bottom of the screen, with a JTextArea (displayArea) just above that, and then a JPanel (gamePanel) at the top or middle of the screen. I can’t seem to get it to work right though ☹ right now the applet fails to init because of the layout and when i change it the layout isn’t right. If I cut gamePanel altogether it loads fine, but I kinda need gamePanel 😛

Any help is appreciated thanks!!

```auto
chatInput = new JTextField( 50 );
        chatInput.addActionListener(
            new ActionListener()
                {
                    public void actionPerformed( ActionEvent event )
                    {
                        sendMessage( event.getActionCommand() );
                        chatInput.setText( "" );
                    }
                }
            );

chatPanel = new JPanel();
        chatPanel.setLayout( new BorderLayout() );
        
        displayArea = new JTextArea( 4, 50 );
        displayArea.setEditable( false );
        
        chatPanel.add( new JScrollPane( displayArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, 
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER ), BorderLayout.NORTH );
        chatPanel.add( chatInput, BorderLayout.SOUTH );
        
        gamePanel = new JPanel();
        gamePanel.setLayout( new GridLayout( 12, 12, 0, 0 ) );
        
        bigPanel = new JPanel();
        bigPanel.setLayout( new BorderLayout() );
        bigPanel.add( gamePanel, BorderLayout.NORTH );
        bigPanel.add( chatPanel, BorderLayout.SOUTH );
        
        add( bigPanel, BorderLayout.CENTER );

```
