Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Alvinkiang

macrumors newbie
Original poster
Apr 24, 2006
14
0
My Program read a XML file and Display the textArea according to the location it read.. which goes something like:


text=new JTextArea("",10,5);
text.setBounds(newPos[2*total1],newPos[2*total1+1],200,200);
panel.add(text);


I ADDED in the Scrollpane:

text=new JTextArea("",10,5);
text.setText("Item");
// text.setLineWrap(true);
text.setBounds(newPos[2*total1],newPos[2*total1+1],200,200);
// JScrollPane p= new JScrollPane(text);
text.setEditable(false);
// p.setPreferredSize(new Dimension(450, 110));
// panel.add(p, BorderLayout.SOUTH);
panel.add(text);


2 problem Faced... Firstly the lineWrap mess up all my location setting and Second is my Scrollpane code Wrong in any place?
 

mrichmon

macrumors 6502a
Jun 17, 2003
873
3
Alvinkiang said:
I ADDED in the Scrollpane:

text=new JTextArea("",10,5);
text.setText("Item");
// text.setLineWrap(true);
text.setBounds(newPos[2*total1],newPos[2*total1+1],200,200);
// JScrollPane p= new JScrollPane(text);
text.setEditable(false);
// p.setPreferredSize(new Dimension(450, 110));
// panel.add(p, BorderLayout.SOUTH);
panel.add(text);

2 problem Faced... Firstly the lineWrap mess up all my location setting and Second is my Scrollpane code Wrong in any place?

The code you show is adding the TextArea to the panel when you should be adding the scrollpane.

A couple of months back another poster had similar problems. I threw together a quick piece of example code and posted it in this thread: https://forums.macrumors.com/showthread.php?p=2156406#post2156406

My comments (and those by others) there about getting into good habits with regard to variable names and spacing out of code would also apply to you based on the code snippet you posted. If the code is readable and structured it is far easier to follow what is going on. It makes it easy for others to help you and suprisingly enough makes it easier for you to understand your own code.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.