Results 1 to 5 of 5

Thread: JScroll

  1. #1
    DaoK
    Guest

    JScroll

    How can I add a Jscroll in a jTextArea if my layout is NULL?

    Thx you

  2. #2
    DaoK
    Guest
    I just want to add a scroll bar to a jTextArea. Any suggestion if my layout is null?

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    This is how it is normally done....
    Code:
    import javax.swing.*; 
      import java.awt.*; 
      import java.awt.event.*;
    
      class Example{ 
       public static void main(String[] args){
     
      JScrollPane jsp = new JScrollPane(new JTextArea());
      JFrame jf = new JFrame(); 
      jf.addWindowListener(new WindowAdapter(){
         public void WindowClosing(WindowEvent we){
           System.exit(0);
         }
     });
    
     
      Container c = jf.getContentPane(); 
      c.add(jsp); 
    
      jf.setSize(200,150); 
      jf.setVisible(true); 
    
     }
    }
    But in order to position a component without the help of a layout manager you would have to use absoulte positioning. Normally you would want to use the setBounds() method which takes either a rectangle or x,y,width and height. I guess this could be good if you want the scroll bar wider then it normally is. You could also use setLocation() which takes a Point or x,y coordinates.

  4. #4
    DaoK
    Guest
    thx you, !!! I mixed up the jscroll pane and the jtextarea

    that what I had:
    JTextArea text1 = new JTextArea(new JScrollPane);
    and like you have gaven to me :
    JScrollPane jsp = new JScrollPane(new JTextArea());


    You see my error now

    Thx you Dilenger4

  5. #5
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Your welcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width