How can I add JScrollpane to one of the panels of a JFrame????

I want to generate a screen with one JFrame and two JPanels.one panel to the left of the Frame and another to the right.
I want to add a Jscrollpane to left panel,to which i am adding images so that they can be scrolled.How can I achieve this ???????????
please reply me.............
this is Basic Frame class.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.media.j3d.*;
import javax.vecmath.*;
public class BasicFrame
private JFrame frame = null;
private JPanel CanvasPanel = new JPanel();
private JPanel libraryPanel = null;
public static void main(String args[])
new BasicFrame();
public BasicFrame()
frame = new JFrame( "Java3d Demo of VRML Loading ");
frame.setSize( 800, 600 );
frame.setLayout(new BorderLayout());
     frame.add(CanvasPanel,BorderLayout.EAST);
frame.add(new LibraryPanel(),BorderLayout.WEST);
     frame.setMenuBar(createMenuBar());
frame.setVisible( true );
     // kill the window on close
     frame.addWindowListener(new WindowAdapter()
     public void windowClosing(WindowEvent winEvent)
     System.exit(0);
public MenuBar createMenuBar()
MenuBar menubar = new MenuBar();
     Menu menu;
Menu subMenu;
MenuItem menuItem;
menu = new Menu("File");
menuItem = new MenuItem("New");
menu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("Load");
menu.add(menuItem);
//menuItem.addActionListener(this);
subMenu = new Menu("Save");
menu.add(subMenu);
menuItem = new MenuItem("VRML97");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("X3D");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
subMenu = new Menu("Print");
menu.add(subMenu);
menuItem = new MenuItem("VRML97");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("X3D");
subMenu.add(menuItem);
//menuItem.addActionListener(this);
menuItem = new MenuItem("Quit");
menu.add(menuItem);
//menuItem.addActionListener(this);
menubar.add(menu);
menu = new Menu("View");
menuItem = new MenuItem("Reset");
menu.add(menuItem);
menuItem.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
menubar.add(menu);
return menubar;
this is Library panel class.To this,I want to add Jscrollpane to scroll the images displayed in this panel.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class LibraryPanel extends JPanel
private ArrayList<String> imageList = new ArrayList<String>();
private ImageIcon imageIcon;
private JLabel imageLabel[] = new JLabel[100];
private String path = "small images";
private JList list;
LibraryPanel()
setSize(400, 600);
setBorder(BorderFactory.createLineBorder(Color.black));
setLayout(new FlowLayout());
JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
indexFiles();
for(int imageNo=0;imageNo<imageList.size();imageNo++)
try
imageIcon = new ImageIcon(path + "/" + imageList.get(imageNo));
imageLabel[imageNo] = new JLabel(imageIcon);
//scrollPane.getViewport().
          add(imageLabel[imageNo]);
catch (IllegalArgumentException illegalArgEx)
illegalArgEx.printStackTrace();
     add(comboBox(),FlowLayout.CENTER);
add(vbar,FlowLayout.CENTER);
public JComboBox comboBox()
String[] comboTypes = { "Sachin", "YuvRaj", "Ganguly", "Dravid", "Sehwag", "Dhoni" };
     // Create the combo box, and set 2nd item as Default
     JComboBox comboTypesList = new JComboBox(comboTypes);
     comboTypesList.setSelectedIndex(0);
     return comboTypesList;
public void indexFiles()
File dir = new File(path);
String[] children = dir.list();
if (children == null)
System.err.println("Error: The directory doesn't exists!");
System.exit(1);
else
imageList.ensureCapacity(children.length);
for (int i = 0; i < children.length; i++)
if(children.endsWith(".jpg"))
imageList.add(children[i]);
please reply me

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.media.j3d.*;
import javax.vecmath.*;
public class BasicFrame
    private JFrame frame = null;
    private JPanel CanvasPanel = new JPanel();
    private JPanel libraryPanel = null;
    public static void main(String args[])
        new BasicFrame(); 
    public BasicFrame()
        frame = new JFrame( "Java3d Demo of VRML Loading ");
        frame.setSize( 800, 600 );
        frame.setLayout(new BorderLayout());
     frame.add(CanvasPanel,BorderLayout.EAST);
        frame.add(new LibraryPanel(),BorderLayout.WEST);
     frame.setMenuBar(createMenuBar());
        frame.setVisible( true );
     // kill the window on close
     frame.addWindowListener(new WindowAdapter()
         public void windowClosing(WindowEvent winEvent)
             System.exit(0);
    public MenuBar createMenuBar()
        MenuBar menubar = new MenuBar();
     Menu menu;
        Menu subMenu;
        MenuItem menuItem;
        menu = new Menu("File");
        menuItem = new MenuItem("New");
        menu.add(menuItem);
        //menuItem.addActionListener(this);
        menuItem = new MenuItem("Load");
        menu.add(menuItem);
        //menuItem.addActionListener(this);
        subMenu = new Menu("Save");
        menu.add(subMenu);
        menuItem = new MenuItem("VRML97");
        subMenu.add(menuItem);
        //menuItem.addActionListener(this);
        menuItem = new MenuItem("X3D");
        subMenu.add(menuItem);
        //menuItem.addActionListener(this);
        subMenu = new Menu("Print");
        menu.add(subMenu);
        menuItem = new MenuItem("VRML97");
        subMenu.add(menuItem);
        //menuItem.addActionListener(this);
        menuItem = new MenuItem("X3D");
        subMenu.add(menuItem);
        //menuItem.addActionListener(this);
        menuItem = new MenuItem("Quit");
        menu.add(menuItem);
        //menuItem.addActionListener(this);
        menubar.add(menu);
        menu = new Menu("View");
        menuItem = new MenuItem("Reset");
        menu.add(menuItem);
        menuItem.addActionListener(new ActionListener()
            public void actionPerformed(ActionEvent e)
        menubar.add(menu);
        return menubar;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
public class LibraryPanel extends JPanel
    private ArrayList<String> imageList = new ArrayList<String>();
    private ImageIcon imageIcon;
    private JLabel imageLabel[] = new JLabel[100];
    private String path = "small images";
    private JList list;
    LibraryPanel()
        setSize(400, 600);
        setBorder(BorderFactory.createLineBorder(Color.black));
        setLayout(new FlowLayout());
        JScrollBar vbar = new JScrollBar(JScrollBar.VERTICAL, 30, 40, 0, 300);
        indexFiles();
        for(int imageNo=0;imageNo<imageList.size();imageNo++)
            try
                imageIcon = new ImageIcon(path + "/" + imageList.get(imageNo));
                imageLabel[imageNo] = new JLabel(imageIcon);
                //scrollPane.getViewport().
          add(imageLabel[imageNo]);
            catch (IllegalArgumentException illegalArgEx)
                illegalArgEx.printStackTrace();
     add(comboBox(),FlowLayout.CENTER);
        add(vbar,FlowLayout.CENTER);
    public JComboBox comboBox()
        String[] comboTypes = { "Sachin", "YuvRaj", "Ganguly", "Dravid", "Sehwag", "Dhoni" };
     // Create the combo box, and set 2nd item as Default
     JComboBox comboTypesList = new JComboBox(comboTypes);
     comboTypesList.setSelectedIndex(0);    
     return comboTypesList;
    public void indexFiles()
        File dir = new File(path);
        String[] children = dir.list();
        if (children == null)
            System.err.println("Error: The directory doesn't exists!");
            System.exit(1);
        else
            imageList.ensureCapacity(children.length);
            for (int i = 0; i < children.length; i++)
                if(children.endsWith(".jpg"))
imageList.add(children[i]);

Similar Messages

  • How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    Hi Nancy,
    This screenshot was only for imagination. A part of the code (not all) is below.  In the code there are some background images but they are not seem in live mode.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="css/my_site.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css"/>
    <link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
    <style>
    #CollapsiblePanel1 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-color: #003366;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel1 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel1 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/international.jpg);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel2 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelContent {
        background-color: blue;
    #CollapsiblePanel3 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel3 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel3 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel4 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel5 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    </style>

  • How can I add new games without overwriting the old ones?

    I have just purchased two new games in the itunes store and although they are showing in the library (under applications) my previously purchased games are not. In Summary under games it will not let me choose selected games only 'all games' and when I press sync warns that the existing games will be replaced. How can I add these games without deleting the older ones? Also if I did want to remove a game from my ipod how do I do it?

    hardlyquinn wrote:
    Part of the problem is that I can never sync the whole thing as I dont keep all my music in my library (it seems silly to have my enture cd collection on the computer).
    Clearly it ISN'T silly as it avoid issues like you are having right now. If you need more space, get an external hard drive. To me it is much sillier to only have your stuff on the iPod and no where else as the iPod, as a small portable player, is much more likely to be dropped, lost, damaged, stolen, forgotten somewhere, etc.
    While I am not familiar with the use of games on the iPod (I have never bought any) you can switch the iPod to manually manage and then you can add content to your iPod without losing what is already there. Perhaps it works for games as well.
    But long term, I strongly suggest you keep all your stuff in your library so if you need to (you have to perform a restore on the iPod, you lose it and buy a new one, etc.) you can very easily sync it all back to the iPod when needed.
    Good luck,
    Patrick

  • How can i add an administrator access so the admin can edit his webpage on the web browser?

    How can i add an administrator access so the admin can edit his webpage on the web browser?

    A content management system or CMS is software usually on the server that allows client's to log-in and edit content from any web browser with an internet connection.  These web pages are typically built with server-side programming (PHP) and databases (MySql). 
    CMSs come big and small.  The right one for your project depends on
         a) your programming skills,
         b) project requirements,
         c) budget.
    COMMERCIAL CMSs:
    Cushy CMS (watch the video to see how it works)
    No PHP or databases required.  Editing is performed on their web site.
    http://www.cushycms.com
    Perch ($59 license per site)
    PHP & MySql required
    http://grabaperch.com/
    WebAssist Power CMS Builder - Extension for DW
    PHP & MySql required
    http://www.webassist.com/dreamweaver-extensions/powercms-builder/
    Adobe Business Catalyst (full subscription includes CMS & web hosting)
    http://www.businesscatalyst.com/
    OPEN SOURCE CMSs:
    Get Simple CMS
    PHP & XML required.
    http://get-simple.info/
    e107 CMS
    PHP & MySql required
    http://e107.org/
    WordPress
    PHP & MySql required
    http://wordpress.org
    Joomla!
    PHP & MySql required
    http://joomla.com
    Drupal
    PHP & MySql required
    http://drupal.com
    Concrete 5
    PHP & MySql required
    http://www.concrete5.org/
    Nancy O.

  • How can i add a navigation rule at the runtime of JSF?

    Hello,
    how can i add a navigation rule at the runtime of JSF. Maybe i should use the method "addNavigationRule()" in class "FacesConfig", but i do not know, how can i obtain the instance of class "FacesConfig". Can anybody help me?
    Thank you very much!!!

    Just curious: Why whould you want to add navigation Rules at run time. I believe the navigation rules should be set to begin with - "by s/w Architect Design".
    Else you can always use Redirect / Forward.

  • How can I add a black border at the bottom of a photo?

    How can I add a black border at the bottom of a photo?

    Just curious: Why whould you want to add navigation Rules at run time. I believe the navigation rules should be set to begin with - "by s/w Architect Design".
    Else you can always use Redirect / Forward.

  • How can I add a line but keep the number I have from tmobile

    How can I add a line but keep the number I have from Tmobile

    Hi, Janice!
    I'm just guessing, but I imagine you'd get your question answered faster in the AE forum.

  • How can I add keywords for SEO into the code?

    How can I add keywords (for SEO) into the code of a Muse designed site?

    You might also be interested in the upcoming MuseJam on Thursday Muse Jam: Search Engine Optimization | Facebook
    Muse Jam: Search Engine Optimization
    Online May 22, 2013
    Join Principal Product Manager Dani Beaumont of the Adobe Muse team as she explores ways within the Muse application to build search engine optimized sites by way of metadata, keywords, H1 definitions, and sitemap generation. After the presentation we'll open the floor to any questions you might with the application.

  • Cs6 , how can i add a anchor point in the curve in the channel Red or Green?

    Hi
    how can i add an anchor point in the curve in the Channel R / G and B?
    in cs5 , with ctrl + click i was able to click on the image and add an anchor point in the curve channel RGB
    and with shift +ctrl + click i was able to click on the image and add an anchor poing in the channel Red , 1 in the channel Green  and 1 in the channel blue
    i know cs6 doesn't have any more ctrl+mouse click , there is the targeted adjustamanent tool
    i can do it with ctrl+m and call the curve
    but i can't do it with curve adjustament tool
    is there a way to add a anchor point in each channel red , green and blue (like the prev photoshop)?
    thanks

    thanks that's correct! thanks
    but it's not 100% correct
    to add a multiple points in rgb shift+click doesn't work!
    from adobe
    Keyboard shortcuts: Curves
    You can use these keyboard shortcuts for Curves:
    To set a point on the curve for the selected color in each color component channel (but not in the composite channel), Shift+Ctrl-click (Windows) or Shift+Command-click (Mac OS) in the image.
    To select multiple points, Shift-click points on the curve. Selected points are filled with black.
    To deselect all points on the curve, click in the grid, or press Ctrl‑D (Windows) or Command-D (Mac OS).
    To select the next higher point on the curve, press the plus key; to select the next lowest, press the minus key.
    To move selected points on the curve, press the arrow keys.
    (Curves dialog box) To set a point on the curve for the current channel, Ctrl-click (Windows) or Command-click (Mac OS) in the image. 
    If you’re instead using the Curves adjustment, simply click in the image with the On-image adjustment tool .

  • How can i add a new function to the Basic IVI class vi's?

    I need to use the IVI vi's to control some instruments, let's say a DC Power Supply.
    Since there's a DC Power supplyclass, i can used those VI's but waht if one of the VI's does not contains all the functions that i need?. How can i add more functions to the IVI classes?. What do i need to do to add a new function to the iviFGen class?

    If you would like to try developing your own instrument driver (or modify the existing one), we have documentation, model instrument drivers, and driver templates to help at :
    http://www.ni.com/devzone/idnet/development.htm
    We also have a syndicate of third party vendors that specialize in National Instruments' products and services. Some of the vendors specialize in driver development. I would suggest contacting one of the Alliance members at:
    http://www.ni.com/alliance

  • How can I add my own files to the TV Shows Library instead of the Movie Library?

    I have my own TV Shows in m4v format.  I can drag and drop the TV Shows into the iTunes Movie Library.  How can I add my files to the TV Shows Library?  Can I group them by show in the TV Shows Library?

    Select the files in iTunes.
    Right click - get info.
    Select the Options tab and set Media kind to TV Show.
    Better yet, use something like MetaZ to tag the files before adding them to iTunes.
    -> http://www.macupdate.com/app/mac/36029/metaz

  • How can i add a gmail icon to the firefox toolbar?

    how can i add the "red envelope" gmail icon to my firefox 7.0.1 toolbar?

    Save that page as a bookmark to the Bookmarks Toolbar. <br />
    http://support.mozilla.com/en-US/kb/Bookmarks+Toolbar

  • .How can I add data from one list to other in Jsp Page

    Hi..I have three multiple selection ListBox..I want to add the selected item from 2 list boxes to 3rd list box how can i do that..do i need to write javascript? If possible then suggest me some link where i can get help?
    Thanks
    Regards
    Chintan

    Yep, Javascript.
    Unless you want to post the data to the server and then rewrite the page (ie. jsp/servlets) then you are going to need to use a client side script to modify the page.
    Javascript. You need to get the onClick() event of one list box and get the item that was clicked. then you can rewrite the 3rd list box.
    If possible, try doing a search on google. Or do you want someone to hold your hand.

  • How can I add more than one submit button in a jsp without use of javascrip

    I want to add more than one submit button in a jsp without use of javascript

    you can do add multiple submit button with this way
    <input type="submit" value="Previous" />
    <input type="submit" value="Next" />
    <input type="submit" value="Finish" />

  • How can I add more than one song to fit the length of the slideshow

    I would like to add more than one song to my slideshow. I do not want to repeat the same song more than once. Is there a way to add more than one song to a slideshow?

    Great - unfortunately it is not intutative - but simple - once you know the secret - and at least in iphoto '08 it acts like you can select multiple songs using the command key but it only plays the first one
    LN

Maybe you are looking for

  • Exchange 2013 DAG with single site and 2 multi-role servers with error "MapiExceptionIllegalCrossServerConnection"

    Hi, I've got a lab with a domain controller and an Hyper-v with on it two multi-role exchange 2013 CU7 servers on W2K12 R2 OS, configured in DAG semplified (but the problem is the same also if I use the classical DAG configuration), a witness server,

  • Clean (Custom) Installation of Windows 8.1

    Clean (Custom) Installation of Windows 8.1   I have HP Envy laptop which has Windows 8.1 pre-installed. Now I'm trying to clean install OS. But how to know the exact Windows 8.1 version. I'm trying to boot from pendrive & Its asking what version to i

  • Submit Button Hidden, Visible, Disappear

    I need to have a submit by email button that is hidden until a box is checked. Then once the user clicks the submit button then both fields disappear. My check box is named: StaffSubmission My submit by email button is named: StaffSubmit Thank you fo

  • Have such a long parameter value how do I pass it?

    hi I'm using 10g report. I have a MFC module that calls this oracle report using the link. I can create a URL and pass the parameters, it works fine, but some occasions, I have to pass down very long (more than 10,000 characters) parameter value to t

  • Mass Deletion of Sales order line items

    Dear Gurus.. There is a transaction VA02 for change and deletion of sales order line items. it takes time to delete line item of sales order one by one.. is there any abap program to do this process.. if so please let me know regards Saad Nisar