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!!
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 );