Results 1 to 3 of 3

Thread: JScrollPane

  1. #1
    mitra is offline Member
    Join Date
    Jun 2011
    Posts
    59
    Rep Power
    0

    Default JScrollPane

    Hi everybody.....

    I want to draw something over the JPanel. Suppose the jpanel have the size 500,500 width and height respectively and added to a jscrollpane.
    now if I add 40 buttons to the jpanel, then the scrollbar appears.
    But now my problem is, if I draw something over the jpanel, that would be capture more space or size than jpanel(suppose 700,700), then scrollbar not appearing, and the drawing shows only the portion, that cover within jpanel's size, and rest part of the drawing hides.

    So what should I do?

    Please help
    Thanks....

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,233
    Rep Power
    7

    Default Re: JScrollPane

    Scrollbars are based on the preferred size of the panel added to the scrollpane.

    If you are doing custom painting of the panel, then you need to override the getPreferredSize() method of the panel to return the preferred size of the custom painting.

  3. #3
    mitra is offline Member
    Join Date
    Jun 2011
    Posts
    59
    Rep Power
    0

    Default Re: JScrollPane

    Thank for your information.
    but how can I override the getPreferredSize() method?
    can u give me sample code plz?

Similar Threads

  1. JScrollPane Help
    By Huskies in forum AWT / Swing
    Replies: 2
    Last Post: 08-06-2011, 06:06 PM
  2. need jscrollpane
    By aambhi in forum Advanced Java
    Replies: 1
    Last Post: 04-29-2011, 09:38 AM
  3. Need Help With JScrollPane Please
    By MemorableSmile in forum New To Java
    Replies: 4
    Last Post: 01-31-2011, 02:39 AM
  4. JScrollPane
    By UJJAL DHAR in forum New To Java
    Replies: 12
    Last Post: 08-17-2010, 06:47 PM
  5. jscrollpane
    By kaemonsaionji in forum New To Java
    Replies: 3
    Last Post: 02-25-2009, 08:39 AM

Tags for this Thread

Posting Permissions

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