I'm writing a Java program and I use JSplitPane to split between two JTextPanes.
The bottom JtextPane is in JTabbedPane.
public class test extends JFrame{
private JTextPane commandTextPane = new JTextPane();
private JPanel tokenPanel;
private JTextPane tokenTextPane = new JTextPane();
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
test window = new test();
window.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public test (){
setBounds(100, 100, 900, 700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
commandTextPane.setBounds(0, 0, 200, 300);
commandTextPane.setPreferredSize(new Dimension(200, 300));
//create ressultTabPane
JTabbedPane resultTabPane = new JTabbedPane();
tokenTabPanel();
resultTabPane.addTab("Token", tokenPanel);
JScrollPane topScroll = new JScrollPane(commandTextPane,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
TextLineNumber topLine = new TextLineNumber(commandTextPane);
topScroll.setRowHeaderView(topLine);
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true,
topScroll, resultTabPane);
splitPane.setOneTouchExpandable(true);
getContentPane().add(splitPane);
setVisible(true);
}
public void tokenTabPanel() {
tokenPanel = new JPanel();
tokenTextPane.setBounds(0, 0, 200, 300);
tokenTextPane.setPreferredSize(new Dimension(200,300));
JScrollPane tokenScroll = new JScrollPane(tokenTextPane,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
TextLineNumber tokenLine = new TextLineNumber(tokenTextPane);
tokenScroll.setRowHeaderView(tokenLine);
tokenPanel.add(tokenScroll);
}
}
The problem is I can't set Bounds and PreferedSize of those JTextPanes. When I set them, the top JTextPane is not expect size and the bottom JTextPane is not in the top-left also its size.
image --> (http://upic.me/show/54858871)
Do you know how to fix them? Sorry for my English. Thanks in advance.