Results 1 to 4 of 4
  1. #1
    ann123 is offline Member
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    0

    Default Scrollbar on graphics output window

    Hi All,
    I need to display some lines on graphics window. The length of the lines can reach upto any extend. Now I can see only upto the screen size of my computer. So i need a scrollbar on that window to scroll the outputwindow. can anyone please help me for that.
    Many thanks in advance :)

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

    Default

    What GUI library are you using here, AWT or Swing? What are you drawing your graphics in, a JComponent or JPanel? Have you tried simply placing a graphics JPanel into a JScrollPane? If so, has it not worked?

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Java Code:
    class Pseudo extends JPanel {
        protected void paintComponent(Graphics g) {
            // drawing code...
        }
    
        public Dimension getPreferredSize() {
            // The parent scrollPane will ask for this
            // and use it to set its scrollbars to
            // make this component fully visible.
            return new Dimension(desired width and height);
        }
    }
    
    Pseudo drawingPanel = new Pseudo();
    JScrollPane scrollPane = new JScrollPane(pseudo);
    JFrame f = new JFrame();
    ...
    f.add(scrollPane);
    f.setSize(any size you like); // scrollPane does the rest

  4. #4
    ann123 is offline Member
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    0

Similar Threads

  1. how can i move one frame window to another window
    By santhosh_el in forum AWT / Swing
    Replies: 8
    Last Post: 06-10-2009, 03:36 PM
  2. scrollbar issue
    By kumar_gemi in forum New To Java
    Replies: 9
    Last Post: 05-06-2009, 06:57 AM
  3. scrollbar issue
    By kumar_gemi in forum NetBeans
    Replies: 1
    Last Post: 05-03-2009, 10:23 PM
  4. how to add scrollbar in netbeans
    By kumar_gemi in forum NetBeans
    Replies: 1
    Last Post: 03-12-2009, 06:50 PM
  5. Using java.awt.Scrollbar
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-03-2008, 09:19 AM

Posting Permissions

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