import javax.swing.*;
import java.awt.*;

public class ChatDisplay extends JPanel{
    private JPanel interfacePanel;
    private JPanel userPanel;
    private JLabel userLabel;
    private JComboBox userComboBox;
    private JLabel messageLabel;
    private JButton sendButton;
    private JTextField messageText;     
    private JTabbedPane textTabbedPane;
    private JScrollPane publicScrollPane;
    private JTextPane publicTextPane;
    private JScrollPane privateScrollPane;
    private JTextPane privateTextPane;
   
    public ChatDisplay(){     
      interfacePanel=new JPanel();
      interfacePanel.setLayout(new BorderLayout(10??10));   
    //?????????
          //??????????????
        JMenu[] menus={ new JMenu("File")??new JMenu("Action")};
        JMenuItem[] items={new JMenuItem("Save")??new JMenuItem("Exit")};
        menus[0].add(items[0]);
      menus[0].add(items[1]);
          //?????????????????????????
        JMenuBar mb = new JMenuBar();
      mb.add(menus[0]);
      mb.add(menus[1]);
        //???ò??????λ???????????
      interfacePanel.add(mb??BorderLayout.NORTH);   
       
    //???????????????   
         //????????к???е?????? ?? ??????塢???ò????       
        publicTextPane=new JTextPane();
        publicScrollPane=new JScrollPane(publicTextPane);   
        publicTextPane.setEditable(false);

        privateTextPane=new JTextPane();
        privateScrollPane=new JScrollPane(privateTextPane);       
        privateTextPane.setEditable(false);
          //???????????
        textTabbedPane=new JTabbedPane();
        textTabbedPane.addTab("public"??publicScrollPane);
        textTabbedPane.addTab("private"??privateScrollPane);
        textTabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
        interfacePanel.add(textTabbedPane??BorderLayout.CENTER);
           
   //??????????????
             //???????????????????
        userPanel =new JPanel();                 
        userLabel=new JLabel("    Send to :");
        userComboBox=new JComboBox();
        String users[]={"Public"??"ClientB"??"CientA"};
        userComboBox.addItem(users[0]);
        userComboBox.addItem(users[1]);
        userComboBox.addItem(users[2]);
        messageLabel=new JLabel("Message:");
        messageText=new JTextField(22);
        sendButton=new JButton("Send");   
    //??????uesePanel?????в???       
        //userPanel ???????????е???????????з?????????壬userPanel2.??userPanel
        userPanel.setLayout(new GridLayout(2??1));
        JPanel userPanel2 =new JPanel();       
        JPanel userPanel3 =new JPanel();
        userPanel.add(userPanel2 );
        userPanel.add(userPanel3);

        //????е???? userPanel2 ????????λ??????????????????????
        userPanel2.add(userLabel);
        userPanel2.add(userComboBox);
        GridBagLayout gridbag=new GridBagLayout();       
        userPanel2.setLayout(gridbag);
        //?????е?????????????в????????????????????C
        GridBagConstraints c=new GridBagConstraints();
        //?????????????????????  
        c.weightx=1;
        c.weighty=1;
        //?????????????λ???????????????????????????
        c.fill=GridBagConstraints.HORIZONTAL;
        //?????????????????????????? ?? ?? ??
        c.insets=new Insets(0??10??0??5);
        //????????????????????
        gridbag.setConstraints(userComboBox??c);

        //????е???? userPanel3????????????????????????????????????????????                             
        userPanel3.setLayout(new FlowLayout());
        userPanel3.add(messageLabel);
        userPanel3.add(messageText);
        userPanel3.add(sendButton);          
        //??????????·??????????嵽?????????
        interfacePanel.add(BorderLayout.SOUTH??userPanel);  
        JFrame frame=new JFrame();    
        frame.add(interfacePanel);
        frame.setVisible(true);
        frame.setSize(410??400);
    }
    public static void main(String[] args) {
          new ChatDisplay();
    }
 };

????????Ч?????£?

????????????£??????????????????????????????????????????????????????????ü??????????????棬????????????????????????????????????????????????????檔