How to add Panel in JScrollPane? URGENT!

I need to add a Panel in JScrollPane
I have try to add JPanel into JScrollPane, but apparently, the JPanel did not show up at all in the JScrollPane (all i see is the border of JScrollPane)
Then I switch my JPanel to Panel (awt) and it does appear on the JScrollPane, but scrollbars are not visible even i have set the size of the panel is larger than the JScrollPane. (and i also set the VERTICAL_SCROLLBARS_ALWAYS) I can scroll with my mousewhieel, but the panel can scroll out of place(ie outside of the Jscrollpane)
Can someone teach me how to add a Panel or JPanel to a JScrollPane Please~ Thanks!!!

here is an example that illustrate my problem:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.filechooser.*;
public class testing extends JFrame
     public testing()
          Container pane=getContentPane();
          pane.setLayout(null);
          setSize(600,600);
          JPanel backgroundpanel= new JPanel();
          backgroundpanel.setLayout(null);
          backgroundpanel.setSize(500,500);
          backgroundpanel.setLocation(0,0);
          Panel insidepanel = new Panel();
          insidepanel.setLayout(null);
          insidepanel.setSize(300,300);
          insidepanel.setLocation(0,0);
          JLabel something= new JLabel("something");
          JTextField someTF= new JTextField(10);
          something.setSize(100,20);
          something.setLocation (20,20);
          someTF.setSize(100,20);
          someTF.setLocation(50,60);
          insidepanel.add(something);
          insidepanel.add(someTF);
          JScrollPane scrollpane= new JScrollPane(insidepanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
          scrollpane.setSize(200,200);
          scrollpane.setLocation(10,10);
          backgroundpanel.add(scrollpane);
          pane.add(backgroundpanel);
          setVisible(true);
          setDefaultCloseOperation(EXIT_ON_CLOSE);
     public static void main(String args[]) throws FileNotFoundException, IOException
                    testing test=new testing();
apparently, the panel i add in teh scrollpane is on the top layer instead of inside the scroll... can anyone help?

Similar Messages

  • Cannot add Panels to JScrollPane

    I have the following class to add Panels on a frame, getting something like a business card on the screen. So if the frame is not large enough the panels get cutted:
    public AlternativeUI() {
              super("Test");
              Container cp = getContentPane();
              GridBagLayout gbl = new GridBagLayout();
              GridBagConstraints gbc;
              cp.setLayout(gbl);          
              for(int i=1; i < 10; ++i) {
                   MyPanel panel = new MyPanel("DATUM", "Name " + i, "Kurztext " + i);          
                   gbc = makegbc(0, i, 1, 1);
                   gbc.anchor = GridBagConstraints.NORTHWEST;     
                   gbc.fill = GridBagConstraints.HORIZONTAL;
                   gbc.weightx = 100;
                   gbl.setConstraints(panel, gbc);
                   cp.add(panel);          
              addWindowListener(new WindowClosingAdapter(true));
              setBackground(Color.lightGray);
         }Adding the layoutmanager GridBagLayout to a scrollpane does not work:
    JScrollPane jsp = new JScrollPane();
    jsp.setLayout(gbl);
    jsp.add(panel);
    cp.add(jsp);Is there a way to get it working?

    I am now using another JPanel to place the smaller Panels on it. Now it works as I expected:
    public AlternativeUI() {
              super("Test");
              Container cp = getContentPane();
              JPanel jp = new JPanel();
              GridBagLayout gbl = new GridBagLayout();
              GridBagConstraints gbc;
              jp.setLayout(gbl);          
              for(int i=1; i < 10; ++i) {
                   MyPanel panel = new MyPanel("DATUM", "Name " + i, "Kurztext " + i);          
                   jp.add(panel);          
              cp.add(new JScrollPane(jp));
              addWindowListener(new WindowClosingAdapter(true));
              setBackground(Color.lightGray);
         }

  • How to add attachments in pdf -URGENT

    Hi All,
    I need information about how to add attachments to pdf in webdynPro. I am unable to find related topics in Forums. Sample code,examples,or suggestions would be helpful.
    Thank you
    Regards
    Ravi

    Hello Ravi,
    Please take a look at: Add attachments to the Interactive form of a Web dynpro application
    Please take a look at my reply there on Mar. 29, 2007. I am not sure but i assume that you are using Web Dynpro for Java. Attachment capability is available with NW04s SP10 (both runtime and NWDS). Although, SP09 contains the required web dynpro runtime changes but the API has only been made part of SP10. Follow the note numbers provided therein.
    Best Regards,
    Krish

  • How to add panel to Dialog?

    hi all,
    I had tried to use setContentPane() methed to include a Panel ,but occured error.
    how should I do that it is work?
    thanks!

    For example :
    Frame frame = new Frame();
    Dialog d = new Dialog(frame);
    Panel p = new Panel();
    d.add(p);

  • How to add icon to JList(urgent)

    Hi guys,
    wanted to make a jlist which will have icon & string in it. How can I add the icon to it. also does icon file extension must be .gif ?
    Thanks & Kind Regards

    You are in luck. The API documentation for JList contains an example of precisely that. Take a deep breath, relax, and read it. (Icons must be GIF or JPEG.)

  • How to add a JScrollPane in a JPanel

    I have a JPanel (layout = null, size = 200*400).
    I would like to add a JScrollPane, that sizes 100*100 and that contains an other JPanel, at the location 0,200 in the first JPanel. I would like too that the JScrollBar is always visible.
    How is it possible ?

    The scrollbars will appear automatically when the preferred size of the panel is greater than the size of the scroll pane. So you probably need to add:
    panel.setPreferredSize(...);
    Of course if you use LayoutManagers, instead of a null layout, then this is done automatically for you.
    If you want the scroll bars to appear all the time then read the JScrollPane API.

  • How to add scroll bars to a panel

    Hi
    Can anyone plz tell me how to add a scroll bar to a panel created within a JFrame
    Regards
    ats

    import javax.swing.*;
    import java.awt.*;
    class Testing extends JFrame
      public Testing()
        setLocation(300,200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        JPanel jp = new JPanel();
        jp.add(new JLabel("Label on a panel"));
        jp.setPreferredSize(new Dimension(200,300));
        JScrollPane sp = new JScrollPane(jp);
        sp.setPreferredSize(new Dimension(200,200));
        getContentPane().add(sp);
        pack();
      public static void main(String args[]){new Testing().setVisible(true);}
    }

  • Urgent - How to add a new control instead of tabs in JTabbedPane

    Hi,
    Please give me an idea or a sample program for how to add a new control
    in JTabbedpane instead of tabs that means overlay any Java controls or pane
    in the tabpane empty place next to tabs

    "Urgent" is not relevant to the question. Your question is no more important than anybody elses.
    My answer in this posting show a limited solution:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=636289
    Otherwise I suggest you try using a layered pane approach:
    http://java.sun.com/docs/books/tutorial/uiswing/components/layeredpane.html

  • How to add a navigation Panel and Zoom Slider Bar using Java API

    Hello,
    I am using Mapviewer Java bean as I have to use Oracle Mapviewer in Java Stanalone application.Please can anyone tell me how to add a Navigation panel and Zoom Slider in Java API. I found the API s for same in Java Script but not in Java.Kindly help.
    I am using Oracle Mapviewer 11g.

    This is forum sponsored by Adobe make of Acrobat and Reader. Since Chrome and FireFox web browser have chosen to use their own viewer you might get more help in their forums or customer support.

  • Hi All how to add new payscale  for an employee in sap hr-abap,its urgent

    Hi All ,
    how to add new payscale for an employee  in sap hr-abap,its urgent.
    Message was edited by:
            bharat kumar
    Message was edited by:
            bharat kumar

    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 display an Image which is on Panel behind JScrollPane - Please Help

    Hiii All,
    How to display an Image which is on Panel behind JScrollPane. I have set the setOpaque() method of JScrollPane to false still when i run the program the JScrollPane is set as Opaque.. Can some one please help me in this...
    Thanks,
    Piush

    you need to set both
    scrollPane.setOpaque(false);
    scrollPane.getViewport().setOpaque(false);

  • How to add a border for Panel (jdk 1.1) ?

    how to add a border for Panel (jdk 1.1) ?

    Border's are a Swing feature, you will have to draw one by yourself (extend Panel and override paint()).

  • How to add Favorites in EP ? Pl... provide steps in details....urgent

    Hi All
         How to add Favorites in EP ? What and settings i need to do ?
        Can any one help me on this and this is urgent for me ?
        In general what is content we will keep in this Favorites ?
    Thanks and Regards
    Rakesh

    Hi,
    You can "add Favorites in EP" by clicking on the image available next to forward link in the title bar of the portal
    Various options like
    Open in New window
    Refresh
    Personalise
    Details
    Add to Browser Favorites
    Add to Portal Favorites
    When you click on "Add to Portal Favorites" then the particular iview is added in the portal favorites iview section. which is displayed below the detailed navigation.
    Example if you add the iview present in the Content administration --> K M Content
    you can add the KM content iview in the favorites.
    Now if you are present in the System Administration --> Portal Display --> Theme Editor then you can navigate to KM iview directly without going through Content administration --> KM Content.
    This reduces the number of navigation paths.
    Hope this helps you.
    Thanks and Regards,
    Gauri Gosavi.

  • REG: How to add elements onto htmlb table cell.. URGENT PLZ HELP

    Hi all,
    I have created a htmlb table. And the jsp code is as follows
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="myBean" scope="application" class="com.linde.myaccounts.util.TableBean" />
    <hbj:content id="myContext">
      <hbj:page title="PageTitle">
       <hbj:form id="myFormId" >
       <hbj:tableView id="myTableView1"
                          model="myBean.model"
                          design="ALTERNATING"
                          headerVisible="false"
                          footerVisible="false"
                          fillUpEmptyRows="true"
                          visibleFirstRow="1"
                          visibleRowCount="5"
    </hbj:form>
      </hbj:page>
    </hbj:content>
                          width="500 px" >
    </hbj:tableView>
    I have used a table bean by which I am getting the column header names. I have 5 columns, I have to add input field in the first column, checkbox in the second column, leave the third column blank, checkbox in the fourth column and again a input field in the fifth column. I am not understanding on how to add this elements onto the table. Will I add it from the JSP using <hbj:tableViewColumns> tag or I have add them in the bean or in the dynpage. Kindly someone give me the code for this...
    This is very urgent..Kindly help...
    Thanks in advance,
    Priyanka

    Hi,
    Have you tried looking at the examples that come with the PDK for all of the HTMLB elements?  From memory, there should be a small table example or 2 that have different types of columns shown similar to what you want - they have the full source code with them for you to look at.
    If you are working in a portal, go to the Java Developer tab and I "think" there should be a tab linking to HTMLB documentation and examples - sorry I can't be more specific but I don't have access to a portal at the moment so am trying to remember.
    Gareth.

  • How to add silver front panel theme for labview 2010

    how to add silver front panel theme for labview 2010

    Mahisnair wrote:
    yes i had tried this way but the vi built with silver theme doesnt look good in 2010 :-(
    wish if there was a way to include silver theme in 2010
    The only way I see to make it like that would be to recreate the theme in LabVIEW 2010 with external bitmap objects. Unfortunately it won't be as functional as the silver controls in various terms such scaling (bitmaps scale very badly) or transparency and click through functionality (a bitmap assigned to a control part will always catch all clicks and never allow a click to pass through anywhere to a lower layered part).
    The silver controls are using special internal graphic objects that were added in LabVIEW 2011, so recreating silver controls with the same functionality in earlier LabVIEW versions is impossible.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

Maybe you are looking for

  • IPod not recognized by iTunes 11.1.4

    Running Mavericks on my MBP, 2011,  iTunes version 11.1.4, 2nd gen iPod Nano Since installing this update for iTunes I've already had to wipe and reauthorize my iPod once, which was mildly annoying. I connected it a second time, now a week later, and

  • Preflight error message . . .

    Hi - never needed to use this forum before, but I've found the Indesign lot incredibly helpful on various occasions in the past. I'm running CS4 on XP pro, the whole suite is installed in its own separate partition on a non system drive, and I also h

  • Customer external number problem

    i have given customer external number range for ex, cna10000 to cnz9999 as i want to know customer by c, and n for north region and a for the alphabet, but system is allowing me to input cnnnnn100, and other wise also, how can i restrict that the sys

  • Kiosk with Front Row???

    Is it possible to create a Kiosk app using Front Row? I want the ability to allow the user to start various websites (on localhost) from a Kiosk interface. Hopefully the user is then locked out of the main HD directories.... Any help/direction apprec

  • Warning: EJB  referenced an unknown security role?

    Hello, I get a weird error from WL 5.1 (SP6), using the default WLPropertyRealm. In the EJB I have the following check: if (ctx.isCallerInRole("ConspiratorRole")) System.out.println ("the user is in the ConspiratorRole role"); At run time, I get the