This week's book giveaway is in the Java in General forum.
We're giving away four copies of Java by Comparison (eBook) and have Simon Harrer, Jörg Lenhard, Linus Dietz on-line!
See this thread for details.
Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

loading text area into a panel  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pls,am having problems trying to put text area into JPanel.pls how can i do it.i did this and it didn't work.

JPanel p=new JPanel();
p.add(new JScrollPane(new JTextArea(50,50)));
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javax.swing.JFrame frame = new javax.swing.JFrame("TEST");
frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();

javax.swing.JPanel p = new javax.swing.JPanel();
javax.swing.JTextArea tArea = new javax.swing.JTextArea(50,50);
p.add(new javax.swing.JScrollPane(tArea));

tArea.setText("TEST");

frame.getContentPane().add(p);

frame.setBounds((screenSize.width-600)/2, (screenSize.height-400)/2, 600, 400);

frame.setVisible(true);
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!