I am trying to display a JtextPane embedded into a JScrollPane in a JFrame. But I can only see the JScrollPane (not the JTextPane) in the JFrame. Here is my code:
public class JTextPaneTest extends JFrame {
public static void main(String args[]) {
try {
JTextPaneTest frame = new JTextPaneTest();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public JTextPaneTest() {
super();
getContentPane().setBackground(new Color(241, 243, 248));
//setBounds(100, 100, 500, 375);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(null);
//this.setPreferredSize(new Dimension(1020,730));
this.setSize(536, 300);
this.setLocationRelativeTo(null);
final JTextPane textPane_1 = new JTextPane();
textPane_1.setText("New JTextPane");
final JScrollPane statisticsScrollPane = new JScrollPane(textPane_1);
statisticsScrollPane.setBorder(new TitledBorder(new EtchedBorder(), "Statistics", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, new Color(0, 128, 255)));
statisticsScrollPane.setLayout(null);
statisticsScrollPane.setBounds(6, 14, 486, 140);
getContentPane().add(statisticsScrollPane);
}
}
Just wondering, what am I doing wrong? Please help.