Hi Geeks,
I have created JFrame and kept a JPanel in it. Now I have to split the JPanel to a scrollPane and a text Pane. My JPanel size is 1000(W),700(H). I wanted to devide it to scrollpane 700(W),700(H) and 300(W),700(H) textPane areas. But I am not able to do it. The main frame area is devided into two equal parts only. Can anybody help? Following are some code snippets
public JFrame getJFrame() {
if (jFrame == null) {
jFrame = new JFrame();
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setJMenuBar(getJJMenuBar());
jFrame.setSize(1000, 700);
jFrame.setContentPane(getJContentPane());
jFrame.setTitle("Application");
return jFrame;
}
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
GridLayout gridLayout = new GridLayout();
gridLayout.setRows(1);
jContentPane.setLayout(gridLayout);
jContentPane.setSize(1000, 700);
jContentPane.add(getScrollPane());
jContentPane.add(getTextPane());
}
return jContentPane;
}
private JTextArea getTxtArea() {
if (txtArea == null) {
txtArea = new JTextArea();
Font txtFont = new Font("serif",1,12);
txtArea.setFont(txtFont);
txtArea.setSize(700, 700);
}
return txtArea;
}
private JTextPane getTextPane() {
if (jTextPane == null) {
jTextPane = new JTextPane();
jTextPane.setSize(300, 700);
jTextPane.setBackground(Color.RED);
}
return jTextPane;
}
private JScrollPane getScrollPane(){
if(scrollPane == null){
scrollPane = new JScrollPane(getTxtArea());
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
scrollPane.setSize(700, 700);
}
return scrollPane;
}