How to add a scroll pane for a panel.

Hi
i have a panel with some images drawn . i want a scroll pane added to this panel.
I tried adding it but failed.
Any suggestions please (
here is my code.
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
class frame extends JFrame
     public frame()
          JScrollPane pane=new JScrollPane();
          setContentPane(new  DrawClass());
          setSize(500,300);
          setBounds(200,300, 100, 500);
          setVisible(true);
public class DrawClass extends JPanel implements ActionListener {
     public DrawClass(){
           public void paintComponent(Graphics g){
                      super.paintComponent(g);
                String [] Filenames={"im3","im4","im5","im6"};
               int imgX = 0;
               int imgY = 10;
               Toolkit toolkit = Toolkit.getDefaultToolkit();
               Integer[] intArray = new Integer[Filenames.length];
               for (int i = 0; i < Filenames.length; i++)
                    intArray[i] = new Integer(i);
                   if (Filenames[i] != "" )
                        //XMLFileParser r=new XMLFileParser();
                         Image img =toolkit.getImage( "/home/swathi/Desktop/Images/"+ Filenames[i]+ ".jpg" );
                       g.drawImage (img, imgX, imgY, this);                                       
                       imgY=imgY+100;                  
                   else
                        System.out.println("NO file Found");
           public static void main(String[] args){
           frame f =new frame();
          public void actionPerformed(ActionEvent e) {
               // TODO Auto-generated method stub
     

can you please help me in this code .....
DrawClass.
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
class frame extends JFrame
     public frame()
          setContentPane(new  DrawClass());
          setSize(500,300);
          setBounds(200,300, 100, 500);
          setVisible(true);
public class DrawClass extends JPanel implements ActionListener {
     public DrawClass(){
           public void paintComponent(Graphics g){
                      super.paintComponent(g);
                String [] Filenames={"im3","im4","im5","im6"};
               int imgX = 0;
               int imgY = 10;
               Toolkit toolkit = Toolkit.getDefaultToolkit();
               Integer[] intArray = new Integer[Filenames.length];
               for (int i = 0; i < Filenames.length; i++)
                    intArray[i] = new Integer(i);
                   if (Filenames[i] != "" )
                        //XMLFileParser r=new XMLFileParser();
                         Image img =toolkit.getImage( "/home/swathi/Desktop/Images/"+ Filenames[i]+ ".jpg" );
                       g.drawImage (img, imgX, imgY, this);                                       
                       imgY=imgY+100;                  
                   else
                        System.out.println("NO file Found");
           public static void main(String[] args){
           frame f =new frame();
          public void actionPerformed(ActionEvent e) {
               // TODO Auto-generated method stub
     ListClass
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.dnd.*;
import javax.swing.*;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.ImageObserver;
import java.awt.Toolkit;
import javax.swing.*;
import org.w3c.dom.Node;
     public class ListClass extends JPanel{
          ListClass(){
               DrawClass d=new DrawClass();
          My question is how i can call a method of DrawClass which contains the drawn images ; in the List Class.
its very urgent please.....

Similar Messages

  • IS IT POSSIBLE TO ADD A SCROLL PANE TO A PANEL??

    Hi, Im trying to add a scroll pane to a panel but when I compile the code and try to open the form - a 'Illegal Argument Exception' is produced. Can anyone tell me whether it is possible to add a scroll pane the actual panel itself and also the code to do this.     
    Many Thanks, Karl.
    I have added some sample code I have created -
    public RequestForm(RequestList inC)throws SQLException{
              inRequestList = inC;
              displayForm();
              displayFields();
              displayButtons();
              getContentPane().add(panel);
              setVisible(true);
         public void displayForm() throws SQLException{
              setTitle("Request Form");
              setSize(600,740);
              // Center the frame
              Dimension dim = getToolkit().getScreenSize();
              setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
              getContentPane().setLayout(new BorderLayout());
              Border etched = BorderFactory.createEtchedBorder();
              panel = new JPanel();
              panel.setLayout( null );
              //panel.setBackground(new Color(1,90,50));
              Border paneltitled = BorderFactory.createTitledBorder(etched,"");
              panel.setBorder(paneltitled);
              scrollPane1 = new JScrollPane(panel);
              scrollPane1.setBounds(0, 0, 600, 740);
              panel.add(scrollPane1);
    }

    Hi all,
    I am still having trouble here. would it be posible to add a scrollpanel to this form? Can anyone provide me with a working piece of code so I see how it actually works.
    Any help would be greatly appreciated.
    Many Thanks, Karl.
    Code as Follows:
    /* ADMIN HELP Manual*/
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.util.*;
    public class AdminHelp extends JFrame implements ActionListener{
         private JButton exit;
         private JLabel heading1, help;
         private JPanel panel;
         Font f = new Font("Times New Roman", Font.BOLD, 30);
         private JScrollPane scroll;
         public AdminHelp(){
              setTitle("ADMIN Help Manual");
              setSize(400,325);
              // Center the frame
              Dimension dim = getToolkit().getScreenSize();
              setLocation(dim.width/2-getWidth()/2, dim.height/2-getHeight()/2);
              panel = new JPanel();
              panel.setLayout(null);
              exit = new JButton("Close");
              exit.setBounds(280,260,100,20);
              exit.addActionListener(this);
              panel.add(exit);
              exit.setToolTipText("Click here to close and return to the main menu");
              getContentPane().add(panel);
              show();
              public void actionPerformed(ActionEvent event){
              Object source = event.getSource();
                   if (source == exit){
                        dispose();
              public static void main(String[] args){
                   AdminHelp frame = new AdminHelp();
                   frame.addWindowListener(new WindowAdapter(){
                   public void windowClosing(WindowEvent e){
                   System.exit(0);

  • How to add a scroll bar within a view window ?I want to display x and y axis outside the scoll window and keep those axis static and move the graph within scroll area

    how to add a scroll bar within a view window ?I want to display x and y axis outside the scoll window and keep those axis static and move the graph within scroll area
    ananya

    Hey Ananya,
    I believe what you want to do is possible, but it will not be
    easy.  If you want to add a scroll bar that will scroll the graph
    back and forth but keep the axis set, you would want to add a
    horizontal or vertical scrollbar.  Then you would create an event
    handler for the scroll event.  You would have to manually plot
    different data within this scroll event.  Unfortunately, there is
    not really a built in way to do this with the Measurement Studio plot
    control.
    Thanks,
    Pat P.
    Software Engineer
    National Instruments

  • How to add the scroll bar in the vertical photo gallery?

    like this, how to add the scroll bar? http://www.flashvault.net/tutorial.asp?ID=288 Thanks,

    I want to know how to add a vertical scroll bar in the photo gallery which I copied from the tutorial. And add the event to catch MouseEvent.CLICK for each photo. Please advise. Thanks,

  • How to add a new tab for the project?

    Dear All Experts,
        Could you tell me how to add a new tab for the project?
        Pls refer to the screenshot as below:
    Thanks!
    Xinling Zhang

    Hi,
        The new tab in cj20n , and the new tab can only be displayed in the highed level.Pls refer to below
        And in cj02, there is no this tab also in the wbs detailed screen,
    Thanks!
    Xinling

  • How to add a scrolling text in portrait with iMovie

    how to add a scrolling text in portrait with iMovie

    This is how i was able to do it. Edit html source.
    <div align="center"><marquee id='scroll_news4' bgcolor=#ff9966 "><font color="#000000" size="+1" ><strong>Outlook is down! IT is working on it! </strong></font></marquee></div>
    <input type='Button' value='Stop' id ='b1' onClick='button_click()';>
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    function button_click()
    if(document.getElementById('b1').value=="Start"){
    document.getElementById('b1').value="Stop";
    document.getElementById('scroll_news4').start();
    }else{
    document.getElementById('b1').value="Start";
    document.getElementById('scroll_news4').stop();
    // End -->
    </script>

  • How to add a search help for a field in Screen Personas?

       I just started learning to use a Screen Personas, and I want to know how to add a search help for a field.
       I found a property in the help document named "IsLookupSupported". Is it the key?  But I saw it was gray in the field I created, and its value is "false". I could not change it.

    Hi, Tamas,
    I found the reason. The function Z_WEBRFC_READ_DATA_SH had a string concatenation error.
    CONCATENATE '{"results":[{"key": "shlpname", "value": "' l_shlp '"},"key": "fieldname", "value": "' l_field '"}]}' INTO htmldoc-line.
    The correct code is like:
    CONCATENATE '{"results":[{"key": "shlpname", "value": "' l_shlp '"},{"key": "fieldname", "value": "' l_field '"}]}' INTO htmldoc-line.
    Another question is, I can't get any words in Chinese from WebRFC. It returns error when I try it. How can I configure it?
    Xin

  • Hi All ,How to add a new  field for MEDRUCK if we havea ZMEDRUCK

    Hi All ,
            How to add a new  field for MEDRUCK if we have a ZMEDRUCK
    Req: If I want to add a new field for the following text editor line :
    IN MAIN WINDOW > TEXT EDITOR> SERCH FOR TOTAL_AMOUNT-->
    In that we will have
    &ekko-waers&    &komkfkwrt&
    (currency)       (numerics)
    Pls send the Code to make these changes .Pls its urgent
    Thanks&Regards.
    Bharat.

    Hi
    If that field which you wants to add is available in one of the structures like EKKO,EKPO then you can add that field just beside the other fields
    If that field is not there in the any of the structures then you can define a variable using define command
    /: DEFINE  &VAR&
    / &VAR&  = <some value>
    or you can write subroutines to fetch the data from outside tables and can use those fields data in the script
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • How to add a document type for the residence status GB in infotype 48

    Hi Team,
    How to add a document type for the residence status GB in infotype 48.
    Please answer this  at the earliest.PFA screnshot.
    Thanks
    chris

    I believe there is a PDF doc which comes with the component (it should be at your harddrive when you install it), which describes everything you will need.
    In a nutshell, there are two types of relationship: sibling - sibling, parent - child (there are some more nuances, but it follows the same logic).
    A relationship is created between two existing items (not sure, if you can also create a relationship for a new checked in item, but it would be just a usability). You select the type of relationship and the item - I believe depending on the relationship you may start from either item. The dialog to start is INFO (display metadata) or UPDATE (update metadata).
    When a relationship is created you may watch it also from either end (again INFO is the starting point).
    It is quite self-explanatory, so if you have the component installed you may just play around with it for a while and that is it.

  • How to add a related content for a particular document in UCM

    Hi All
    How to add a related content for a particular document in UCM. On which table it stores all the related document details. Can anyone suggest me a document which helps me to know how to add related contents for a document
    With thanks and regards
    Anoop

    I believe there is a PDF doc which comes with the component (it should be at your harddrive when you install it), which describes everything you will need.
    In a nutshell, there are two types of relationship: sibling - sibling, parent - child (there are some more nuances, but it follows the same logic).
    A relationship is created between two existing items (not sure, if you can also create a relationship for a new checked in item, but it would be just a usability). You select the type of relationship and the item - I believe depending on the relationship you may start from either item. The dialog to start is INFO (display metadata) or UPDATE (update metadata).
    When a relationship is created you may watch it also from either end (again INFO is the starting point).
    It is quite self-explanatory, so if you have the component installed you may just play around with it for a while and that is it.

  • Does anybody know how to get a scroll bar for a long list of podcasts when selcting some for sync? Thanks

    Does anybody know how to get a scroll bar for a long list of podcasts when selcting some for sync? Thanks

    Hi lbadek
    I can help with this please send us an email using the contact the mods link in my proifle and we will investigated from there.
    Thanks
    Stuart
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • How to Add the title name for Graph in Excel

    Dear Friends
                      I am using LabVIEW 8.0.I need how to add the title name for chart in Excel.
    Jayavel
    Solved!
    Go to Solution.

    Do you have the Report Generation Toolkit? If so, the Excel Easy Graph VI has an input for that.
    If you don't have the toolkit then you will need to use ActiveX. Please do a search on how to use ActiveX (there are examples that ship with LabVIEW) to control Excel. There are also lots of example in the Excel thread. NOTE: DO NOT POST QUESTIONS IN THAT THREAD. 
    Ultimately you will need to look up the information in MSDN. 

  • How to add hotmail to mail for Yosemite

    how to add hotmail to mail for Yosemite

    Mail/Preferences/Accounts - click the + sign and add the account.
    Hotmail Settings      See post by Csound1

  • Custom display template - how to add anothe display template for refimement item?

    Custom display template - how to add anothe display template for refimement item?
    I add a new filter_default_custom.html file and want to create new refinement item display template to point to it
    keren tsur

    Not 100% if I understood the question, but if you uploaded your template to the Master Gallery and the corresponding .js file has been created, you can open the refinement config panel and specify the result type you want to map to your custom template.
    http://www.eliostruyf.com/part-1-create-first-search-refiner-control-template/
    Kind Regards
    Bjoern
    http://www.sharepointviking.com
    Twitter: Follow @bjoern_rapp

  • How to add another Chapter Page for more then 6 chapters & add right arrow?

    Hello,
    I created a project via the Magic iDVD option and it worked great and added multiple chapter pages for more then 6 chapters. Now, I manually added a submeno off of main and added 6 chapters but I need multiple pages since I have 40 chapters... I can't figure out how to add another chapter page and create a RIGHT ARROW navigation button for the next pages...
    I also looked at the map view and see that on the working pages there is page connected to page... I also cannot find a way to add a page connected vi map view...
    I have searched the forum but none of the answers were clear on how to do this... any help would be appreciated...
    Thanks! T.

    Adding the submenu is easy...making the button for it a "right arrow" is not.
    You can keep adding submenus to other submemus by navigating to the appropriate menu and then choose the "add submenu" command from the iDVD project menu. This can be done in either normal or map view.
    However, this creates a "folder" button, (or other things in some themes) not a right arrow. I agree it should be a choice! My 2nd best solution is to chage the folder button to a "text only button" and label it "More Chapters > >"
    Another solution (3rd best??) is to use command-shift-4 when you are one one of your other menus that DOES have a right arrow, and take a mini picture of the arrow. Then choose one of the oval menu buttons on the button pane, and drag this tiny picture onto the button. Re-size it to make it close to the same size as your other buttons. It will have a funny edge on it from the button style, but it will look like a right arrow.
    John B

Maybe you are looking for

  • Open Orders are negitive in ODS and Info cube

    Hi, Our ODS is getting data from sales order Item data and from ODS data is going to Info cube. The problem is that: for few sales orders some open orders are deleting in R/3 but same records are reversing the old records due to this in the ODS and i

  • Error accessing  identity management in EP

    Hi, I'v updated EP patches upto 11. After updating the patches I'm not able to access "User Administration". When clicked on "user administration" tab following error message is displayed. "A required service for the identity management user interfac

  • Using a Monitor TV as a second monitor

    I just got an iMac and everything is working just fine except that I want to use my TV Monitor (it's a LG) as a second monitor and for some reason it just doesn't seem to work. I tried going to System Preferences and clicking the "detect display" but

  • Audio tracks don't show up properly on sequence when enlarging timeline

    On the timeline, audio tracks don't show up properly, by either appearing out of sync or by repeating itself when I enlarge it to work on it. Other sequences in the project work fine, and I've tried coping a pasting this sequence or parts of it to a

  • File not getting posted at target directory

    Hi all, I am crearting a simple bypass scenario in which no mapping is involved. I simply have to pick up a file with particular naming convention from the FTP location and write it to other location at the target side with some different naming conv