Go directly to the end of a scroll

Hello!
I have a JPanel with a table inside, and avery time I add rows to this table I want the scroll to go to the end... to show the last row, but I dont know how to do this, so any help would be great.
Here is my code:
    class paneltable extends JPanel
        public paneltable()
            super(new GridLayout(1,0));
            int row = data.getRowCount();
            table = new JTable(data);
            table.setPreferredScrollableViewportSize(new Dimension(1800, 500));
            table.setRowSelectionAllowed(true);
            table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            table.setRowSelectionInterval(row-1, row-1);
            TableColumn column = null;
            int col = table.getColumnCount();
            for (int i = 0; i < col; i++)
                column = table.getColumnModel().getColumn(i);
                column.setPreferredWidth(100);
            JScrollPane scroll = new JScrollPane(table);
            add(scroll, BorderLayout.CENTER);
            ListSelectionModel rowSM = table.getSelectionModel();
            rowSM.addListSelectionListener(new ListSelectionListener() {
                public void valueChanged(ListSelectionEvent e) {
                    if (e.getValueIsAdjusting()) return;
                    ListSelectionModel lsm =
                            (ListSelectionModel)e.getSource();
                    if (lsm.isSelectionEmpty()) {
                        //no rows are selected
                        selectedRow = -1;
                    } else {
                        selectedRow = lsm.getMinSelectionIndex();
                            // selectedRow is selected
    }thanks!

You could also use
table.scrollRectToVisible(table.getCellRect(row,column,true));This will (if the table is inside a JScrollPane (which yours is)) scroll to make the cell at the specified row/column visible.

Similar Messages

  • Delivery is to be done at the end user location not at the storage location

    Hai Gurus.
       I have a problem
    I am working for a construction industry.. I had a storage location at say" X":. And in case of emergency for the material to the end user at different locations, delivery is to be done at the end user location not at the storage location.. Where to give the end user location address .As delivery address in PO item details will be plant address. pl help
    regards
    chandrasekhar

    As i underdstand from your  description of issue .You dont want to recive the material in the storage location of your  main plant but you want to recive the goods directly to the end user from the vendor.This is typical scenario of Third party PO ..so kindly traise third part PO to vendor ..by changing the item category ...and so the delivery addfres popolutaed in ur PO will be directly from the ship to address from your sales order.rathewr than the storgae location you wd have specified in ur material master

  • Row getting added in the end of the scroll

    Hi -
    I am using a scroll area on a page on level 1. The issue iam encountering is that when ever i click the plus sign to add a second or third row (assume one record already exists in scroll 1) , the row gets added in the end of the scroll and also the fields are blank. However as delievered the new row should get added on the top of the scroll meaning 1 of 2 not 2 of 2, and also it should carry forward the values from the prior row. Please any suggestion or help is greatly appreciated.

    I figured it out. The reason it was happening was because, my scroll record had another key field after EFFDT and EFFSEQ, due to which the delivered copy forward logic for new rows in scroll did not work and the row was getting added in the end or after the first blank row always.

  • 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

  • JScrollPane Must Scroll to the END ........

    My problem is :
    I have a JTextArea , and the text inside doesn't fit
    in it. When this happens , the two ScrollBar should
    scroll to the END of the text....
    Like if a have a JTextArea with 10 rows with a JScrollPane, and my text is 20 rows long, then i
    need to see the end of the text(No manual Scrolling)
    Are there any method to control the Scrollbar position ?
    Help....!!!!!!!

    Hi,
    When you move the caret position of your JTextArea, then the scollbars follow. Try this (assuming your JTextArea is called textArea):
    textArea.setCaretPosition(textArea.getLineEndOffset(textArea.getLineCount()-1));This scrolls to the end of the JTextArea.
    Hope this helps,
    Kurt.

  • With a high volume of tabs, scrolling to the end of the tab list often resets to the first tab

    Firefox 34.0.5
    When using a large number of tabs, around 300 inactive and 30 active tabs, when the currently selected tab is a tab on the far left side of the tab bar, attempting to scroll to the end (far right) side of the tab bar will often cause scrolling to freeze momentarily, and then reset to far left, to the currently selected tab, and continues scrolling from the beginning of the tab bar, making it unnecessarily difficult to scroll to the end of a long tabs bar.
    This occurs when scrolling up/down with the scroll-wheel on a mouse, when scrolling up/down/left/right on a touchpad, and when scrolling using the left and right scroll buttons in the tab bar.

    hello kirbysama, can you try to replicate this behaviour when you launch firefox in safe mode once? if not, maybe an addon is interfering here...
    [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]

  • Unable to scroll down to the end of my playlist with i tunes

    I  must say that I could not be more disappointed  with the new i tunes 11. I have been using if for four months and have had nothing but problems which, as I am a professional DJ who uses it everyday, is really bad news. Unlike the old itunes creating playlist is a laborious process. I just bought a load of tunes from the Itunes store for a podcast I have to do but, to create a playlist and drag from another playlist (i.e.purchased) seems impossible. Once one clicks on view sidebar the plalylist disappears so you have to search for every single tune. Can anyone help ? Is there a solution ? I have read the tutorials and have used I tunes for over a decade.To add, now I can't scroll down to the end of my playlists even to click on create or get to any playlist past those beginning with the  letter  S. I hope someone from Apple sees this as the old I tunes was a far better product. Creating a seperate window for playlist and drag and drop is far easier.  If I could find another application other than I tunes I would drop this like hot bricks.Apple have taken a huge leap backwards in my opinion.

    Open the playlist.  Click View > Show View Options, and set "Sort By" to "Manual Order."
    Then you will be able to move songs up or down your playlist by drag-n-drop.

  • TS4357 The song I downloaded cuts off about 3 seconds before the ending, I have tried re-downloding per apple support directions with the same results. What further actions may I take to fix this issue?

    The song I downloaded (Slayer, Criminally Isane) cuts off about 3 seconds before the ending, I have tried re-downloding per apple support directions with the same results. What further actions may I take to fix this issue?

    I'd report the problem to the iTunes Store. 
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the item that is not playing properly. If you can't see "Report a Problem" next to the item, click the "Report a problem" button. Now click the "Report a Problem" link next to the item.

  • Jdev9i;JSP;Scroll a page at the end programatically?

    Hi,
    How can i scroll the the page to the end?
    More info: I have a JSP page that shows a database table. In
    some condition I'd like to show the last row in the visible area
    when page is loaded, so if the table is large i should scroll
    the page programatically at loading time. How could i do that?

    .focus() in javascript is a good candidate for this.

  • Is there a way to change the DIRECTED BY at the end of my iMovie?

    Hello:
    I just upgraded to iMovie '09 and really like it. I created a movie using the "Photo Album" option. Just wondering if there is a way I can change the ending transition to say something other than "Directed by" and my name?
    THANKS

    Yes. In the Project viewer click on the text in the bar above the clip. It will get the yellow frame around it. Then in the viewer window just click on Directed By field and type your new text. Click in your name and do the same.

  • [svn:fx-trunk] 5812: Fixed a bug where direct use of Animation failed because AnimationProperty was not setting up its internal keyframes with correct duration information , so the animation would skip immediately to the end.

    Revision: 5812
    Author: [email protected]
    Date: 2009-03-31 11:34:56 -0700 (Tue, 31 Mar 2009)
    Log Message:
    Fixed a bug where direct use of Animation failed because AnimationProperty was not setting up its internal keyframes with correct duration information, so the animation would skip immediately to the end.
    Bugs: SDK-20356
    QE Notes: spark/effects Mustella tests currently hosed, couldn't run test suite
    Doc Notes: None
    Reviewer: Jason
    Testing: checkintests, Mustella effects tests could not be run (post-rename issues)
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-20356
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/AnimationProperty.as
    flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/animation/Animation.as
    flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/supportClasses/AnimateColorIns tance.as
    flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/supportClasses/AnimateShaderTr ansitionInstance.as
    flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/supportClasses/FadeInstance.as
    flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/supportClasses/MoveInstance.as
    flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/supportClasses/ResizeInstance. as
    flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/supportClasses/Rotate3DInstanc e.as
    flex/sdk/trunk/frameworks/projects/flex4/src/spark/effects/supportClasses/RotateInstance. as

    Hi
    Can you please try setting up full persmission in the security properties for everyone on the wsconfig folder C:\ColdFusion10\config\wsconfig  and restart ColdFusion Server.
    Swaraj

  • Force to scroll to the ende of a IFrame

    Hello experts,
    could anyone please explain me if it is possible to enable a button after scrolling a IFrame until the end of the page?
    PsychoCode:
    Something like this:
    --> If IframeScrollToEnd then enable Button.
    Many thanks
    Marco

    in planning board
    go to the menu path
    Edit ->Show/hide -> Show milestone
    Hide whatever you do not want

  • [SOLVED] urxvt scroll's to the end

    ... without any output.
    I scroll to the top (with mouse wheel or keyboard bindings), but second after terminal scroll to the end without any output or input.
    Here's my .Xdefaults: https://www.refheap.com/20319 (removing "perl-ext-common" dont helps).
    Last edited by ShadowPrince (2013-10-31 16:13:22)

    karol wrote:What version of rxvt-unicode are you using?
    9.18-7

  • Scrolling an image at the end of a ticker

    hi,
    I am koushik from India. I am working in j2me(cldc-midp), for last six months.
    I have successfully scrolled a ticker and also worked with image.Now I want to scroll an image at the end of a ticker.So, at first I want to scroll an image independently, then I'll go for that. I want to do it not using Timer or I don't want it as a keyEvent,it should scroll like a ticker horizontally at the top of the emulator.Is it possible using Canvas,repaint()......
    if it possible , can anybody help me giving a sample code.

    Hi,
    Because it's an assignment that you've got to make we won't just post complete source code that can be pasted into your Canvas code. As a matter of fact, I don't have source code that accomplishes something similar, so I can't post any code.
    I will try to give some hints etc...
    Okay, you're not using the Ticker class. That's okay and the scenario is clear.
    You probably have got a Canvas screen in which you've made a sort of rectangle at the top of the screen. This rectangle (probably a filled rectangle) represents your titlebar. In this rectangle you will draw parts of a text during each run of the thread (timer).
    There are some interesting challenges: the process should be very smooth to let your ticker animate very realistic. The text will be drawn using a dynamic x coordinate. However, you will need to draw text first, then drawing a filled rectangle or something at the left or the text and at the right of the text to simulate that characters are visualised for only a certain part (like how the ticker does that).
    A fast thread (that sleeps for limited milliseconds) will obviously cause flickering on the screen that might be prevented with double buffering stuff. However this might be complicated on the mobile (the implementation should support double buffering to be able to use it), so then try to increase the delay between the (re)paint actions.
    The paint method should be clean and simple. Do not use any impressive calculations there. Try to find a balance in using class member variables and local calculations (in the paint method). Try to prevent the usage of local member variables in the paint method, to reduce processor load and heap usage.

  • I JUST INSTALLED MOUNTAIN LION, NOW THE SCROLL BALL ON MY MAGID MOUSE SCROLLS IN THE OPPOSITE DIRECTION THAN IT DID BEFORE. I NOW HAVE TO ROLL THE BALL UP TO SCROLL DOWN

    I JUST INSTALLED MOUNTAIN LION, NOW THE SCROLL BALL ON MY MAGIC MOUSE SCROLLS IN THE OPPOSITE DIRECTION THAN IT DID BEFORE. I NOW HAVE TO ROLL THE BALL UP TO SCROLL DOWN.

    If you go into System Preferences> Mouse. There is a box at the top of the screen that states Scroll direction: natural.
    Be sure to uncheck the box after installing MOUNTAIN LION, then the mouse ball will scroll in uthe normal fashion.
       Thanks for all the help...
    TRAIN MAN  

Maybe you are looking for

  • Sync of iCal to Calendar in iPhone off by 1 hour

    This problem has just come up in a 2 week old iPhone 3GS. When I enter new events in iCal and sync with iPhone, the times are one hour later in Calendar. Appears to match the advance in 1 hour of Daylight Savings Time from Nov. - March. So, entering

  • Video thumbnails scrambled, won't playback (v3.4.3)

    My video thumbnails in Aperture (version 3.4.3) are scrambled. Sometimes I can see part of a reference thumbnail frame (often in monochrome or with a single color overlay, like green), sometimes it's just all snow. 1) I just restored my mac mini from

  • Untrusted Forest

    Hi I have a forest (Internal) and I have another forest (External). SCCM 2012 R2 and SQL 2012 is installed in the "internal forest", I would like to add a new forest (external) to my SCCM setup which is "Untrusted". The two forests  are not trusted a

  • ITunes is only importing small parts of songs

    Hopefully this hasn't been posted, already, I checked and didn't see any topics specific to this. Alrighty, so I imported some WMA file songs that I had into iTunes.. however later on I noticed that iTunes had only imported the first 2 minutes or so

  • Time display incorrect using Output (generatePDFOutput) module

    I needed to manipulate the date & time to display the day, date time with am/pm and timezone. So using formcalc with renderPDFForm as the module i am using this formCalc code: $.rawValue = Concat(Num2Date(Date(), "EEEE MMM DD YYYY")," ", Num2Time(Tim