• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What am I doing Wrong? Please Help

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
remove this line

statisticsScrollPane.setLayout(null);
 
sabbir kazi
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic