doing this works :
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
textArea = new JTextArea();
scrollPane = new JScrollPane(textArea);
contentPane.add(scrollPane,BorderLayout.CENTER);
setContentPane(contentPane);
however this doesnt :
contentPane = new JPanel();
textArea = new JTextArea();
scrollPane = new JScrollPane(textArea);
contentPane.add(scrollPane,BorderLayout.CENTER);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
i guess thats got something to do with setBorder()
and setLayout()
creating something like a new instance of JTextArea perhaps , something that nullifies the effect of contentPane.add(scrollPane,BorderLayout.CENTER);
line , but i was hoping for a concrete answer as to why one code works and the other doesnt.
thanks in advance for your time :)