Scrollbar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reon
    New Member
    • Feb 2007
    • 80

    Scrollbar

    Hi friends

    How can i add a vertical and horizontal scroll bar inside a Textarea..
    While i created a textarea i cant read the topics down the screen ...
    i add a scrollbar but it seperates from textarea , i want to attach that scrollbar with my textarea how is it possible...

    Code:
    JTextArea area = new JTextArea(40,40);
    JScrollBar scr = new JScrollBar();
    i call this textarea and scrollbar inside a panel...but it seperates ...
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by reon
    Hi friends

    How can i add a vertical and horizontal scroll bar inside a Textarea..
    While i created a textarea i cant read the topics down the screen ...
    i add a scrollbar but it seperates from textarea , i want to attach that scrollbar with my textarea how is it possible...

    Code:
    JTextArea area = new JTextArea(40,40);
    JScrollBar scr = new JScrollBar();
    i call this textarea and scrollbar inside a panel...but it seperates ...
    Let the TextArea determine for itself whether or not it needs scrollbars. There's
    a contructor that does the job:

    public TextArea(String text, int rows, int columns, int scrollbars)

    ... also have a look at the API docs for this class.

    kind regards,

    Jos

    ps. are you sure you don't want Swing's JTextArea instead?

    Comment

    • reon
      New Member
      • Feb 2007
      • 80

      #3
      I tried something with JScrollPane , trying,but didnt completed..
      i am using swing from javax and awt from java...

      public TextArea(String text, int rows, int columns, int scrollbars)
      would you please tell me wats the use of String text.bcoz i think textarea needed int columns and rows...wats the use of string there...

      Originally posted by JosAH
      Let the TextArea determine for itself whether or not it needs scrollbars. There's
      a contructor that does the job:

      public TextArea(String text, int rows, int columns, int scrollbars)

      ... also have a look at the API docs for this class.

      kind regards,

      Jos

      ps. are you sure you don't want Swing's JTextArea instead?

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by reon
        public TextArea(String text, int rows, int columns, int scrollbars)
        would you please tell me wats the use of String text.bcoz i think textarea needed int columns and rows...wats the use of string there...
        Did you read the API docs for this constructor? I bet you didn't.

        kind regards,

        Jos

        Comment

        • BSCode266
          New Member
          • Jan 2007
          • 38

          #5
          The way i have used it before isnt probably the best way but it works. You can add the textarea to the scrollbar. And then the scrollbar to the panel.

          i think its just one of the scrollbar.add() method.

          BSCode266

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by BSCode266
            The way i have used it before isnt probably the best way but it works. You can add the textarea to the scrollbar. And then the scrollbar to the panel.

            i think its just one of the scrollbar.add() method.

            BSCode266
            That's not necessary: the TextArea can take care of all that itself. See my
            previous replies.

            kind regards,

            Jos

            Comment

            Working...