Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-26-2009, 11:04 PM
Member
 
Join Date: Jun 2009
Posts: 2
Rep Power: 0
ann123 is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 06-27-2009, 04:38 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,447
Rep Power: 8
Fubarable is on a distinguished road
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?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-27-2009, 07:36 AM
hardwired's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 1,577
Rep Power: 4
hardwired is on a distinguished road
Default
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
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-27-2009, 09:47 PM
Member
 
Join Date: Jun 2009
Posts: 2
Rep Power: 0
ann123 is on a distinguished road
Default
It worked out.
Thank you so much for your help.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i move one frame window to another window santhosh_el AWT / Swing 8 06-10-2009 04:36 PM
scrollbar issue kumar_gemi New To Java 9 05-06-2009 07:57 AM
scrollbar issue kumar_gemi NetBeans 1 05-03-2009 11:23 PM
how to add scrollbar in netbeans kumar_gemi NetBeans 2 03-13-2009 11:57 AM
Using java.awt.Scrollbar Java Tip Java Tips 0 01-03-2008 10:19 AM


All times are GMT +2. The time now is 01:25 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org