Chat Program

Hello all,

I would like to make a chat program that use GridBagLayout and GUI swing.

As the problem is Gridbaglayout, I don't know how can I set variable.

I want 4 components as below

JTextArea

JList

JTextField

JButton

--

+ 55555555555555555555555 + 999999999999 +

+ 55555555555555555555555 + 999999999999 +

+ 55555555555555555555555 + 999999999999 +

+ 55555555555555555555555 + 999999999999 +

+ 55555555555555555555555 + 999999999999 +

+ 5555 JTextArea 5555555555 + 999 JList999999 +

+ 55555555555555555555555 + 999999999999 +

+ 55555555555555555555555 + 999999999999 +

+ 55555555555555555555555 + 999999999999 +

+ 55555555555555555555555 + 999999999999 +

+ 55555555555555555555555 + 999999999999 +

--

+55555555555555555555555 + 999999999999 +

+55555 JTextField5555555555 + 99999J Button9 +

+55555555555555555555555 + 999999999999 +

--

I can't do this layout, Plaese give me a parameter value or some code will appreciate.

Thank you

Please

[1131 byte] By [al0701] at [2007-9-27 14:25:56]
# 1

actually i dont have a compiler to compile but i think this is what you are looking for.

import javax.swing.*;

import java.awt.*;

import javax.swing.event.*;

import java.awt.event.*;

public class chat extends JFrame {

public JTextField field;

public JTextArea area;

public JList list;

public JButton button;

public JPanel p1,p2;

public chat()

{

super("my chat");

Container cont = getContentPane();

cont.setLayout(new BorderLayout(5,5));

area = new JTextArea(50,50);

list = new JList(50,false);

field = new JTextField(50);

button = new JButton("SEND");

p1 = new JPanel();

p1.setLayout(new BorderLayout(2,2));

p1.add(button,BorderLayout.SOUTH);

cont.add(area,BorderLayout.WEST);

cont.add(list,BorderLayout.EAST);

cont.add(field,BorderLayout.SOUTH);

cont.add(p1,BorderLayout.EAST);

cont.setBounds(200,200,400,490);

cont.setVisible(true);

}

public static void main (String args[])

{

chat ch = new chat();

}

}

araingr8 at 2007-7-5 22:16:46 > top of Java-index,Archived Forums,Swing...
# 2
and i think there is not so big need to use the gridbag layout in this case
araingr8 at 2007-7-5 22:16:46 > top of Java-index,Archived Forums,Swing...
# 3
Thank you so muchemm but If I want this frame can maximize then the component maximize too.BorderLayout can do this.....
al0701 at 2007-7-5 22:16:46 > top of Java-index,Archived Forums,Swing...
# 4
didnt understand what you want to say.........
araingr8 at 2007-7-5 22:16:46 > top of Java-index,Archived Forums,Swing...
# 5
Sorry,JFrame has function for resize a frame.Then I resize a frame, the location of component in the frame should be move automatically.I would like to ask that BorderLayout can do this....
al0701 at 2007-7-5 22:16:46 > top of Java-index,Archived Forums,Swing...
# 6
hi,to resize the textarea of the frame when the frame is resized. you should use JTextpane insted of JTextarea. this is what i used in my chat program. its not as easy as JTextArea but it will help a lot as it is a full fledged text editor.
araingr8 at 2007-7-5 22:16:46 > top of Java-index,Archived Forums,Swing...