Results 1 to 6 of 6

Thread: What is the use of JScrollPane class?

  1. #1
    Join Date
    Dec 2009
    Posts
    38

    What is the use of JScrollPane class?

    Hi friends,

    I need your help to get solution over my query related to the java concept. I am quit confused about the 'JScrollPane class'' of java programming. I don't have any idea about the use of 'JScrollPane class'. I have searched lots of websites to get details over this, but didn't get enough details. If you have knowledge about 'JScrollPane class', then please let me know that. Your help would be greatly appreciated.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: What is the use of JScrollPane class?

    A JScrollPane class provides a scrollable view of a lightweight component. A JScrollPane manages a viewport, optional vertical and horizontal scroll bars, and optional row and column heading viewports. Note that JScrollPane does not support heavyweight components. The JViewport provides a window, or "viewport" onto a data source - for example, a text file. That data source is the "scrollable client" (aka data model) displayed by the JViewport view.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: What is the use of JScrollPane class?

    Hi friend,
    If you want to know about the use of JScrollPane class of java, then please refer following example:
    Code:
    import javax.swing.JScrollPane;
    import javax.swing.border.LineBorder;
    
    public class AddingToJScrollPaneDM {
    
      public static void main(String args[]) {
        JFrame frameK = new JFrame("Tabbed Pane Sample");
        frameK.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
        JLabel label2 = new JLabel("Label");
        label2.setPreferredSize(new Dimension(1200, 1000));
        JScrollPane jScrollPane2 = new JScrollPane(label2);
    
        JButton jButton1 = new JButton();
    
        jScrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane2.setViewportBorder(new LineBorder(Color.RED));
        jScrollPane2.getViewport().add(jButton1, null);
    
        frameK.add(jScrollPane, BorderLayout.CENTER);
        frameK.setSize(400, 150);
        frameK.setVisible(true);
      }
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: What is the use of JScrollPane class?

    Following are some oftenly used methods of JScrollPane class, which are very useful while accessing the properties of JScrollPane class:
    • setWheelScrollingEnabled(boolean handleWheelVal)
    • setViewportView(Component vw)
    • setViewportBorder(Border vwportBorder)
    • setViewport(JViewport vwport)
    • setVerticalScrollBar(JScrollBar verticalScrlBar)
    • setRowHeader(JViewport rwHeader)

  5. #5
    Join Date
    Oct 2005
    Posts
    2,393

    Re: What is the use of JScrollPane class?

    If you want to add component to the JScrollPane by using constructors of JScrollPane class, then please use following java code:
    Code:
    import javax.swing.JScrollPane;
    import javax.swing.JLabel;
    
    public class AddingToJScrollPN {
    
      public static void main(String argsm[]) {
        JFrame KX = new JFrame("Tabbed Pane Sample");
        KX.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
        JLabel label = new JLabel("Label");
        label.setPreferredSize(new Dimension(1000, 1000));
        JScrollPane jScrollPane = new JScrollPane(label);
    
        KX.add(jScrollPane, BorderLayout.CENTER);
        KX.setSize(300, 150);
        KX.setVisible(true);
      }
    }

  6. #6
    Join Date
    May 2008
    Posts
    2,389

    Re: What is the use of JScrollPane class?

    Hi,

    Below are four constructors of the JScrollPane class, which comprises same nae but with different parameter list to preserve uniqueness.
    1. JScrollPane(int vsbPlc, int hsbPlc)
    2. JScrollPane(Component vw, int vsbPlc, int hsbPlc)
    3. JScrollPane(Component vw)
    4. JScrollPane()

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. Replies: 5
    Last Post: 12-02-2010, 06:23 PM
  3. Difference among concrete class and abstract class
    By Roxy_jacob in forum Software Development
    Replies: 4
    Last Post: 07-12-2009, 01:22 PM
  4. Ultra solid drives:Imation M-Class and S-Class
    By Regina in forum Portable Devices
    Replies: 1
    Last Post: 03-04-2009, 10:34 AM
  5. Good news for CBSE CLASS X & CLASS IX - visit learnnext
    By surya_expert in forum Education Career and Job Discussions
    Replies: 0
    Last Post: 13-12-2008, 12:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,719,044.13289 seconds with 16 queries