Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-13-2009, 10:18 AM
Member
 
Join Date: Dec 2008
Posts: 98
Rep Power: 0
itaipee is on a distinguished road
Default Can I add scrollPane to panel with not access to the frame
I have JPanel - but don't have access to the "father" - I mean waht the jPanel is added to ( JFrame or something else)

I want to add JSrollPanel but all the example I see are something like that

Code:
JScrollPane scrollPane = new JScrollPane(myJPanel);
myJFramel.add( scrollPane, BorderLayout.CENTER );
Is there a way to add a scroll to a component itself ithout its paranet?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-13-2009, 10:23 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Did you try to do that? And if so, what happen?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-13-2009, 10:47 AM
Member
 
Join Date: Dec 2008
Posts: 98
Rep Power: 0
itaipee is on a distinguished road
Default
The problem is that I cannot use myFrame - only the Panel
the code is and example of how to use JScrollPane. when I try

Code:
JScrollPane scrollPaneOut = new JScrollPane();
myPanel.add(scrollPaneOut,null);
or

Quote:
JScrollPane scrollPaneOut = new JScrollPane(myPanel);
myPanel.add(scrollPaneOut,null);
I imply don't have the scroll bars so its not working
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-13-2009, 10:54 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Actually what you have to do is, first add components to the JPanel if any. Then add that panel into the JScrollPane. Finally add that panel to the frame.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-13-2009, 11:08 AM
Member
 
Join Date: Dec 2008
Posts: 98
Rep Power: 0
itaipee is on a distinguished road
Default
ok . I have many components in the panel - and I need scroll for the panel so I can move between these buttons and textfield when I'm not using full screen -
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-13-2009, 11:10 AM
Darryl.Burke's Avatar
Senior Member
 
Join Date: Sep 2008
Location: Madgaon, Goa, India
Posts: 745
Rep Power: 2
Darryl.Burke is on a distinguished road
Default
How to Use Scroll Panes (The Java™ Tutorials > Creating a GUI with JFC/Swing > Using Swing Components)

db
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 01-13-2009, 11:18 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Try this simple code segment.

Code:
    public static void main(String[] args) {
        JFrame frame = new JFrame();

        JPanel panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

        for(int i = 0; i < 10; i++) {
            panel.add(new JButton("JButton"));
        }

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(new JScrollPane(panel));
        frame.setSize(200,200);
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
    }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 01-13-2009, 11:18 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Darryl, I've learn something on my last code because of you.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 01-13-2009, 11:30 AM
Member
 
Join Date: Dec 2008
Posts: 98
Rep Power: 0
itaipee is on a distinguished road
Default
Again - the problem - I dont have access to the JFrame- only to the panel.
I look several times on the scrollpane toturial in "sun" .

I control only the frame - other part of the program, which I cannot change or modify , add the panel to the frame. It is not that simple.

Code:
public static void main(String[] args) {
        JFrame frame = new JFrame();
//  I cant access JFrame. 

//from here my program starts
        JPanel panel = new JPanel(); // 

        panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));

        for(int i = 0; i < 10; i++) {
            panel.add(new JButton("JButton"));
        }

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(new JScrollPane(panel));
        frame.setSize(200,200);
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
    }
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
Method access or field access carderne New To Java 2 12-06-2008 07:20 PM
ScrollPane Issues.. hanifa AWT / Swing 4 09-11-2008 09:18 AM
scrollpane Newb AWT / Swing 0 06-09-2008 01:14 AM
Tree with Listener not working when added to ScrollPane praveen.kb AWT / Swing 2 01-09-2008 08:06 AM
How to place panel into frame vivek_9912 AWT / Swing 2 11-20-2007 12:21 AM


All times are GMT +2. The time now is 09:04 PM.



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