ScrollPane Doesn't Show

Discussion in 'Mac Programming' started by Alvinkiang, Apr 24, 2006.

  1. Alvinkiang macrumors newbie

    Apr 24, 2006
    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);

    I ADDED in the Scrollpane:

    text=new JTextArea("",10,5);
    // text.setLineWrap(true);
    // JScrollPane p= new JScrollPane(text);
    // p.setPreferredSize(new Dimension(450, 110));
    // panel.add(p, BorderLayout.SOUTH);

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

    Jun 17, 2003
    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:

    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.

Share This Page