Why the JScrollPane not scroll?

I create a dialog,then I put a JScrollPane on the dialog,after this I put a JPanel on the JScrollPane,
finally I put many checkbox on the JPanel.Due to having many checkboxes, I hope that JScrollPane can scroll,but it cannot scroll .how can I sove this problem?
the following is my code:
this.setSize(new Dimension(543, 523));
this.getContentPane().setLayout(null);
jButton3.setText("ok");
jButton3.setBounds(new Rectangle(235, 455, 95, 30));
jButton4.setText("cancel");
jButton4.setBounds(new Rectangle(395, 455, 100, 30));
// jScrollPane1.setBounds(new Rectangle(0, 20, 515, 1195));
// jScrollPane1.setAutoscrolls(true);
jPanel1.setBackground(Color.cyan);
jPanel1.setLayout(null);
jPanel1.setAutoscrolls(true);
jPanel1.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
jCheckBox1.setText("attrib_manager");
jCheckBox1.setBounds(new Rectangle(10, 10, 110, 25));
������������
jCheckBox66.setBounds(new Rectangle(205, 1120, 97, 26));
jCheckBox66.setEnabled(false);
������������
jPanel1.add(jCheckBox66, null);
jPanel1.add(jCheckBox1, null);
JScrollPane jScrollPane1 = new JScrollPane(jPanel1);
jScrollPane1.setBounds(new Rectangle(0, 20, 515, 425));
jScrollPane1.setAutoscrolls(true);
jScrollPane1.getViewport().add(jPanel1, null);
this.getContentPane().add(jScrollPane1, null);
this.getContentPane().add(jButton4, null);
this.getContentPane().add(jButton3, null);

You have to set size of your panel.
override method getPrefferedSize() of panel. This methd should return correct size of content.
best regadrs
Stas

Similar Messages

  • Need debugging help: Why is JScrollPane auto-scrolling?

    I'm trying to figure out why when I double-click on a cell within a JTable that's wrapped in a JScrollPane in order to open up another window, the JScrollPane automatically scrolls to the top.
    Even when I update the double click operation to simply call setSelected(false), the JScrollPane still automatically scrolls to the top.
    I added myself as a change listener to the scroll pane's row header view port, and captured the following stack trace.
    I'm having trouble debugging exactly what is causing the following chain of events to fire. If I try to put a debug breakpoint on a method like EventQueue.invokeLater() that's probably initiating the following chain of events, I can't even get back to my application window from my IDE without having to dismiss all of the breakpoints that are reached.
    If I try to follow through from the double-click to the actual JScrollPane auto-scroll, I get lost in a maze of Swing events that I can't navigate out of.
    Any suggestions on how to appropriately debug this would be greatly appreciated.
    Thanks,
    Mike
    rowHeaderViewPort stateChanged fired
    chgEvent == javax.swing.event.ChangeEvent[source=javax.swing.JViewport[,1,21,0x329,invalid,layout=javax.swing.ViewportLayout,alignmentX=null,alignmentY=null,border=,flags=8,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=0,height=0],isViewSizeSet=false,lastPaintPosition=,scrollUnderway=false]]
    chgEvent source == javax.swing.JViewport[,1,21,0x329,invalid,layout=javax.swing.ViewportLayout,alignmentX=null,alignmentY=null,border=,flags=8,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=0,height=0],isViewSizeSet=false,lastPaintPosition=,scrollUnderway=false]
    java.lang.Exception: stack trace
         at MyForm$2.stateChanged(MyForm.java:192)
         at javax.swing.JViewport.fireStateChanged(JViewport.java:1341)
         at javax.swing.JViewport.setViewPosition(JViewport.java:1096)
         at javax.swing.ViewportLayout.layoutContainer(ViewportLayout.java:179)
         at java.awt.Container.layout(Container.java:1020)
         at java.awt.Container.doLayout(Container.java:1010)
         at java.awt.Container.validateTree(Container.java:1092)
         at java.awt.Container.validateTree(Container.java:1099)
         at java.awt.Container.validateTree(Container.java:1099)
         at java.awt.Container.validateTree(Container.java:1099)
         at java.awt.Container.validateTree(Container.java:1099)
         at java.awt.Container.validateTree(Container.java:1099)
         at java.awt.Container.validateTree(Container.java:1099)
         at java.awt.Container.validateTree(Container.java:1099)
         at java.awt.Container.validate(Container.java:1067)
         at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:353)
         at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:116)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

    Thanks for your response. I examined the code and nowhere that I can see is it calling either of those two methods.
    At some point, it looks like something within my code or in the UI frameworks that I'm using is invalidating my JScrollPane. I'm having a very difficult time, though, tracking down exactly which component is causing that invalidation.
    Short of writing my own JScrollPane so that I can capture the stack trace of calls to invalidate(), does anyone have any suggestions for debugging this further? I tried to use a conditional breakpoint in Eclipse 2.1.3 (Component.invalidate() where the Component is an instance of JScrollPane), but my breakpoint is never being executed.
    Thanks,
    Mike

  • Why my panorama not scrolling when i move my cell phone as it was before, any special setting?? an answer please

    why my panorama not scrolling when i move my cell phone as it was before, any special setting?? i need an answer please

    Welcome to the Support Communities. This Apple doc may be of interest:
    Channel Member Code of Conduct
    Kings74 wrote:
    They told my friend that the phone was not available in Black, that was the 5, and that the 5s was only available in silver and gold..
    A minor point, but it may avoid a little confusion if, instead of saying "black" in reference to the iPhone 5s, say "space gray":
    "iPhone 5s — Available in silver, gold, and space gray" (Source)

  • JScrollPane not scrolling to the end of JTable

    Hello,
    I put a table in a scroll pane, and add the scroll pane to a panel. The problem is the scroll pane does not scroll to the end of the table, it always lets me view only the first 37 rows of the table, regardless of how many rows the table actually has. Basically, the scroll pane thinks the table has exactly the same height, no matter how many lines it has. Why is this happening?
    The code is something like
    model = new SearchResultTableModel(false, null, null);
    table = new ResultTable(model);
    scrollPane = new JScrollPane(table);
    mainBox.add(scrollPane);
    If this is important, the table is a bit more complicated, I subclass JTable, use a custom TableModel, several types of cell renderers / editors, so maybe this is why it behaves so strange. How could I tell the scroll pane the table is actually larger?
    Thank you very much, any ideas are highly appreciated,
    Regards from Romania,
    Adi

    Hi,
    fireTableDataChanged() is the easiest way to do it, but also that one, that forces JTable to rerender all visible cells, regardless the fact, that they are already displayed and would not need rerendering - if you add a row - for example row 7 - do fireTableRowsInserted(7,7); instead - so JTable will only render this single row if it is visible in the viewport. If you add a couple of rows, for example row 7 to 227, do fireTableRowsInserted(7,227); - always fire only the correct notifications accordingly to the changes you make, in order to keep the performance of JTable high.
    greetings Marsian

  • Why does Firefox not scroll the page when selecting & the cursor reaches the bottom of the screen

    When selecting text on a screen page, when the cursor reached the bottom edge of the screen Firefox (9.0.1) does not scroll. Other programs (including IE) do so, so it does not appear to be a local computer problem.
    I cannot see a setting on the options page that enables/disables this so what is the solution?

    Enable the Add-ons bar (Firefox > Options or View > Toolbars; Ctrl+/) or the Find bar (Ctrl+F) to make Firefox scroll the page while selecting text.

  • Why the file not picked by PI

    Hi mates:
           I tried to implement a XML-to-XML senario by XI, it is like picking the file from one folder to another .  and I have created and configurated everything for senario in ID and IR. and activated everything. but the file won't be picked up by XI, 
          I used two computers for the senario, one for Xi, one for the business system.
          Could you please tell me why the file can't be picked up by XI. do I have to installed any FTP server
    on the business system?
          Thank you very much!

    Hi Jingying,
                  There is some reasons are happended for the file is not picking.
    1) If use FTP , Check your FTP Connection working or not
    2)If not pick the file to XI , Check data from source end, if it wrong its shows the error in RWB->Communication Channel Monitoring--> File adapter..
    3)Check the sender Communication channel configured properly or not.
    Regards,
    Sateesh N.

  • Why the appletViewer not working

    i want to run my applet program through AppletViewer, but when I type
    AppletViewer tree.html, there is no error, but nothing promp up too,
    if I use the broswer IE to run the tree.html file, it is work
    any one know why I can not use the appletViewer to see the applet?

    hi, thanks your reply
    yes, I had give the resource code to the file
    <html>
    <applet code = tree.class height = 600 width = 600>
    </html>
    so, are there any other work I need to insert?hi,
    the code is okay but you might have to make it like this:
    /*<html>
    <applet code = "tree.class" height = 600 width = 600>
    </html>*/because it does not need to be complied.
    with this much and the command,
    appletviewer tree.java
    at the command line would work fine.
    hope you get through.
    P.S. if you are having problems, please try posting the error too.
    [email protected]

  • JScrollPane not scrolling, image only flickering

    Hi, guys:
    I have this problem that I used JAI to render an image on a JPanel and then put the JPanel into a JScrollPane. The strangest thing is that when I scroll, the scrollbar is moving but the image just flicker a little, for like 0.1 second it scrolls but quickly back to the original position. I feel that it has something to do with the paintComponent but I can't see what should be done. I will be very thankful if any of you can give me some suggestions!
    David

    Why my question is always ignored???
    I solved the problem by add the JComponent which renders the image to an additional JPanel, and then set the JPanel to opaque by setOpaque(true), and then add the JPanel to the viewport of the JScrollPane.

  • Why the getConnection not wait?

    if my connection pool is full, why the
    getConnection return a message"throws java.sql.SQLException:weblogic.common.ResourceException:
    No resources available" but not wait for retry serverl time.
    So what is the meaning of "Waiters"(in wls connection pool
    monitor)

    Hi.
    getConnection() will try/wait for a few seconds before throwing the ResourceException. The reason
    we do this is because you are using an execute thread to make this call (scarce resource). We
    don't want to use up execute threads waiting indefinitely for resources - these threads would be
    better used running other parts of your app..
    Regards,
    Michael
    eric nie wrote:
    if my connection pool is full, why the
    getConnection return a message"throws java.sql.SQLException:weblogic.common.ResourceException:
    No resources available" but not wait for retry serverl time.
    So what is the meaning of "Waiters"(in wls connection pool
    monitor)--
    Michael Young
    Developer Relations Engineer
    BEA Support

  • Why the different notes?

    I hope some one can help me with this? When I connect my keyboard and Yamaha DD-55c to my Mac I get a sound, which is the good thing. The bad thing is I get a number of notes on one key or drum pad. How can I fix this. Any help is welcome.

    Try making a blank project with no settings at all and just add a bass from whatever plugin. Make sure there are no plugins at all on the track (not just muted but removed). Then try again.
    I believe palying on the pianoroll with the mouse plays at 127 velocity but I ain´t sure. How about the output? Does it clip/go red? Then it will disort.

  • I am on v6.0.2 with a Vista O/S, why can I not scroll the Web page with my mouse ball?

    I am on the latest version of Firefox and I run Vista OS on my desktop. Why does the mouse ball function for scrolling not work with Firefox?

    Hello jaybearden,
    Thanks for the question. After reviewing your post, it sounds like you are not able to restore the iOS device since you get an error 9. I would recommend that you read this article, it may be able to help the issue.
    Resolve iOS update and restore errors - Apple Support
    Check your security software
    Related errors: 2, 4, 6, 9, 1000, 1611, 9006. Sometimes security software can prevent your device from communicating with either the Apple update server or with your device.
    Check your security software and settings to make sure that they aren't preventing a connection to the Apple servers.
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • Why can i not scroll through the InetRadio Favorites ? (per Remote up oder down)

    Hi,
    when i choose some Radiostationgrene like Top40 i can scroll through the Stations via Remote up and down. When i have 4, 5 or many other Favorite Stations (make them Favorite) i can´t scroll through these. I must go back in the menu and click the other favorite Station. .. thats not comfortable.

    Perfect:
    in iTunes/Preferences/Devices tab: check "prevent ...iPhones...from syncing automatically".
    Sync the iPhone.
    When ready, Restore the iPhone.
    When ready, rightclick the iPhone, from the popup menu choose "restore from backup", from the popup window choose the backup you made just before the restore.
    disconnect the iPhone.
    Check out the Music app.

  • Why is the  image not scrolling in applet ?

    Hello,
    I am using drawImage to draw the image on screen and everytime i am increasing the X values but still the image just remains there only. It doesn't scroll. How can i solve this?
    import java.applet.Applet;
    import java.awt.*;
    public class ImageScroller extends Applet implements Runnable{
         Image image;
         Thread t;
         int height,width;
         int x;
         public void init(){
              image = getImage(getCodeBase(),"3.jpg");
              x = 50;
              t = new Thread(this);
              t.start();
         public void run(){
              Graphics g = getGraphics();
              while(true){
                   try{
                        x+=50;
                        g.clearRect(0,0,800,600);
                        g.drawImage(image,x,x,this);
                        if(x>width)
                             x=0;
                        Thread.sleep(10);
                   catch(InterruptedException ex){}
    }

    I think what you want is something like this:
    import java.applet.Applet;
    import java.awt.*;
    public class ImageScroller extends Applet implements Runnable{
         Image image;
         Thread t;
         int height,width; // These arent used anywhere...
         int x;
         public void init(){
              image = getImage(getCodeBase(),"3.jpg");
              x = 50;
              t = new Thread(this);
              t.start();
         public void run(){
              while(true){
                   repaint();
                   try {
                        Thread.sleep(10);
                   catch(InterruptedException ex) {}     
         public void paint(Graphics g)
              x+=50;
              g.clearRect(0,0,800,600);
              g.drawImage(image,x,x,this);
              if(x>width)
                   x=0;
    }

  • Why the HTMLBooleanCheckbox not updated?

    Hi,
    I have a checkbox in a tabbed pane. The mapped property (of this Checkbox) was updated in the Bean class. But on the page, the checkbox itself did not change its checked status, and keep same.
    Some help!
    Why?
    Guangming

    Put <h:messages/> in your jsp.

  • Volume can not be found          WHY THE HECK NOT??

    Hi
    ok I have 26000 photos in iphoto so I have a litte bit of an idea how to do it...
    but why is it doing this now?
    -this is my workflow I insert my card in the reader
    -copy them to my external HD
    iphoto is only a reference library ( have copy unchecked )
    -I go into iphoto/file/import to library/external HD/pictures/then the file with my photos I want to reference
    -preparing to import
    -VOLUME CAN NOT BE FOUND. Insert the disk or connect to the server volume and wait for it to appear on the desktop, then try again.
    WHY WOULD IT DO THIS OUT OF THE BLUE??? HELP
    THANKS

    This sometimes occurs if you’re importing a file into iPhoto and there’s already a file there with the same name. Digital cameras can produce many, many files with the same name over their lifetime, so it’s not uncommon to have several files called IMG_00543.JPG, for instance. Now you want to import one also called this.
    What happens is that iPhoto compares the two files to check for duplicates. However, if iPhoto cannot find the file already in the database for comparison, then you get this message. It suggests that your database is damaged because iPhoto has lost track of this (or these) similarly named files.
    A simple test is to rename the file you are importing - just add a character - IMG_00543a.JPG for instance. If this then imports with no issue then you might consider rebuilding your library:
    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Rebuild iPhoto Library Database from automatic backup.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. This will create a new library based on data in the albumdata.xml file. Not everything will be brought over - no slideshows, books or calendars, for instance - but it should get all your albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one.
    Regards
    TD

Maybe you are looking for

  • How do I transfer all my itunes to a different computer

    I own a 3rd Generation Ipod touch and an Ipad 2. I also own a PC that has all of my Itunes music apps and things on it. But recieved a work Macbook that runs snow leapord. I want to sync both my devices to this Macbook but dont want to erase their co

  • HTML Snippet widget bug report.

    Dear Apple iWeb 08 Engineers. I didn't know where to send this bug report and so I have resorted to this forum. I hope it gets to you somehow. When creating a simple HTML Snippet in a page it seems that the piece of code that refers to the newly crea

  • Apple av adapter does not work after updating ios 5,01

    apple av adapter does not work after ios 5,01. no video on vga monitor. sound goes out on iphone 4 also.

  • Unsing RequestOneWayBean with Do Not Use SOAP Envelope

    HI All , I have a requriement where Ecc is calling PI with an Asyn Proxy and PI calls a Sync Webservice and gets the Response back and sends the response back to ECC in Async manner . (Async - Sync Bridge). I need to call aWeb Service which required

  • HP Mini 210-1076

    I have the Broadband 5G 59.95 plan and have had it for quite sometime now, I need to cut back and my contract isn't up til 12/2012. I tried to downgrade to a cheaper plan but when I tried the website said that I would have to upgrade to the IPAD. I d