I want the divider is located at the right(under) component.
run this program you will see my effect, and fix this problem. thanks for reading
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
public class ChatFrame extends JFrame{
private JTree tree = null;
private ClientNode[] clientArray= new ClientNode[9999];
private JTextArea textChat=null;
private JTextField [] textBox = new JTextField[9999];
private Socket connection=null;
private BufferedReader in = null;
private PrintWriter out = null;
private int port;
private JTabbedPane communicationTab;
private JButton sendButton;
public ChatFrame(int port){
setSize(300,300);
this.port = port;
DefaultMutableTreeNode user = new DefaultMutableTreeNode("Another users");
DefaultMutableTreeNode Client1 = new DefaultMutableTreeNode("Client 1");
user.add(Client1);
tree = new JTree(user);
JScrollPane treeScrollPane = new JScrollPane(tree);
JPanel p = new JPanel();
p.add(treeScrollPane);
communicationTab = new JTabbedPane();
JSplitPane upperSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,communicationTab,p);
upperSplitPane.setContinuousLayout(true);
upperSplitPane.setOneTouchExpandable(true);
upperSplitPane.setLastDividerLocation(1);
textChat = new JTextArea();
textChat.setLineWrap(true);
textChat.setWrapStyleWord(true);
JScrollPane scroll = new JScrollPane(textChat);
JPanel q = new JPanel();
sendButton = new JButton("Send");
sendButton.setSize(2,2);
q.setLayout(new FlowLayout());
q.add(sendButton);
JPanel tc = new JPanel();
tc.setLayout(new BorderLayout());
tc.add(scroll, BorderLayout.CENTER);
tc.add(q,BorderLayout.EAST);
JSplitPane underSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,upperSplitPane,tc);
underSplitPane.setLastDividerLocation(1);
getContentPane().add(underSplitPane,"Center");
}
public void connectToServer(){
try{
connection = new Socket("serverName",getPort());
while(true){
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
out = new PrintWriter(connection.getOutputStream());
String s = in.readLine();
if(s!=null){
textChat.append(s);
}
}
}catch(Exception e){
}
}
public int getPort(){
return port;
}
public static void main(String[] args){
ChatFrame c = new ChatFrame(903);
c.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
c.show();
}
}