Results 1 to 6 of 6
  1. #1
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Exclamation How to add JScrolPane to a JLayeredPane?

    Greetings,

    I have this JFrame that contains a JTabbedPane and instead the JTabbedPane is a JLayeredPane and another JScrollPane containing a JTable.

    I would like to add a JScrollPane to the JLayeredPane but my attempts seemed not to work. I have already tried added the JLayeredPane to a JPanel and initialized the size of the JPanel with setSize().

    But on the other hand, if the JFrame only contains the JScrollPane containing the JLayeredPane, it work.

    How could I solve this?
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    I think for us to best understand your problem and be able to help you, you need to create and post an SSCCE (please check out the link). Also, what are you having the greatest deal of trouble with? Adding to the JLayeredPane? Have you gone through the JLayeredPane tutorial?

    Luck

  3. #3
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Default

    you should better add JLayeredPane to JScrollPane instead... That would be more useful I guess

  4. #4
    gafa's Avatar
    gafa is offline Senior Member
    Join Date
    Jun 2010
    Posts
    107
    Rep Power
    0

    Default

    but to do thing you want you have to setBounds(x,y,w,h) for your JScrollPane because JLP is for absolute position only

  5. #5
    Prajin's Avatar
    Prajin is offline Senior Member
    Join Date
    Jun 2010
    Location
    Ktm, Nepal
    Posts
    120
    Rep Power
    0

    Default

    What I understand from OP 1st post is that, OP want to add scroll option to layeredPane. Probably because layeredPane contains many components and some can't be viewed even in JFrame maximized. If so, as already suggested, add layeredPane to scrollPane.

    -Regards.

  6. #6
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    I have solve this thread,
    I have the JLayeredPane object extended as a class.
    Then on the JTabbedPane, I added a new tab wherein the second parameter is

    Java Code:
    new JScrollPane(new Board()) //wherein: class Board extends JLayeredPane
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to 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
  •