Selecting a jlist item and placing it in view

i have 100 items in a jlist. then i scrolled to the bottom of the list.....so now the first item is not in view anymore.
i have a button on top that retrieves rows and rebuilds the jlist.
which it does.
however, if i am at the bottom of the list and hit the button i want the first item to be selected and viewed in the screen.
dbase_list.setSelectedIndex(0); ---> selects the first item
but its not in view till i scroll back up again.
how do i select and place the first item in the users view after i hit the button? is there a method that does it?
thanks

Add this code in ur constrcutor
list.setAutoscrolls(true);
list.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(KeyEvent e) {
list.ensureIndexIsVisible(list.getSelectedIndex());
});

Similar Messages

  • Help: Problem with scrolling my html items and placed objects they keep cutting through my top menu

    Basically whenever i place an html item in my Muse site or an object I encounter a problem when scrolling down past that object in the preview. I have a horizontal menu bar that sits on the top of my site and whenever I scroll down the html items and objects
    cut through my menu. Is there any way to rectify this? - i've tried pinning objects but can't figure it out. Any help would be greatly appreciated.
    Thanks,

    So you have a pinned Menu in the Master page but is being overlayed by the objects in page when you scroll down? If that is the case, select the Menu in the Master, right click on it and Move To Master Foreground.
    Thanks,
    Vinayak

  • Selection of JList item

    hi friends
    i am using JList component.i have added many item in Jlist.by keyboard up and down arrow key i can make them highlighted and then select. but i want few item of JList never highlighted and select when i press up and down arrow key . For example, If i do not want to select 2nd item in the list then by pressing down arrow key selection should be jumped from first to third item skipping second item.
    How to do that?

    I might be wrong but I think you need to code for it.
    I have created a code using key binding. To use if you need to skip an item you need to hold down the control key and use the up and down arrow to navigate and once you have selected an item release control key and press enter, vice-versa.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ListFocusDemo extends JFrame {
        public void createAndShowUI() {
            final JList myList = new JList(new String[] {"My data 1","My data 2",
            "My data 3","My data 4"});
            JScrollPane scrollPane = new JScrollPane(myList);
            InputMap map = myList.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
            map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "myAction");
            myList.getActionMap().put("myAction", new AbstractAction() {
                public void actionPerformed(ActionEvent evt) {
                    int lead = myList.getLeadSelectionIndex();
                    if(lead > -1 && !myList.isSelectedIndex(lead)) {
                        myList.getSelectionModel().addSelectionInterval(lead, lead);
                    } else if(lead > -1 && myList.isSelectedIndex(lead)) {
                        myList.getSelectionModel().removeSelectionInterval(lead, lead);
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            getContentPane().setLayout(new BorderLayout());
            getContentPane().add(scrollPane, BorderLayout.CENTER);
            pack();
            setLocationRelativeTo(null);
            setVisible(true);
        public static void main(String[] args) {
            Runnable run = new Runnable() {
                public void run() {
                    new ListFocusDemo().createAndShowUI();
            SwingUtilities.invokeLater(run);
    }

  • Permeantly select a JList Item.

    how would i permeantly select a item in a Jlist? ie. Even if the user clicks it it wont uncheck, it will always be selected.
    There will be other items in the Jlist which they may select and deselect but one which they cannot and stays selected.
    Thanks

    Hi,
    I would use the CellRenderer since selection if just the renderer drawing it. The example below should demonstrate what I mean.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class PermCellRenderer extends JLabel implements ListCellRenderer
      private int[] permIndices;
      public PermCellRenderer()
        this( null );
      public PermCellRenderer( int[] permIndices )
        setOpaque( true );
        this.permIndices = permIndices;
        System.out.println( this.permIndices[0] );
      private boolean isPermanent( int index )
        boolean outVal = false;
        if( permIndices != null )
          for( int i = 0; i < permIndices.length; ++i )
            if( permIndices[i] == index )
              outVal = true;
              break;
        return( outVal );
      public Component getListCellRendererComponent( JList list, Object value,
                                                     int index,
                                                     boolean isSelected,
                                                     boolean cellHasFocus )
        setText( value.toString() );
        if( isPermanent( index ) || isSelected )
          setBackground( list.getSelectionBackground() );
          setForeground( list.getSelectionForeground() );
        else
          setBackground( list.getBackground() );
          setForeground( list.getForeground() );
        return( this );
    public class PermListExample extends JFrame
      JList list;
      public PermListExample()
        super( "Permanent List Selection" );
        String[] data = { "First", "Second", "Permanent", "Fourth", "Fifth" };
        int[] perm = { 2 };
        list = new JList( data );
        list.setCellRenderer( new PermCellRenderer( perm ) );
        list.setVisibleRowCount( 10 );
        getContentPane().add( list );
        pack();
      public static void main(String[] args)
        new PermListExample().setVisible( true );
    }Enjoy,
    Manfred.

  • STARTED IT, BUT STILL NEED HELP -- INPUTTTING CHARACTERS FROM LOADED FILE INTO TABLE, SELECTING STRINGS FROM TABLE AND PLACING IN NEW TABLE, SAVING NEW TABLE TO SPREADSHEET FILE

    I AM TRYING TO IMPORT CHARACTERS FROM A TAB DELIMITED FILE INTO A TABLE ON LABVIEW.  ONCE THE DATA IS IN THE TABLE I WANT TO BE ABLE TO SELECT INDIVIDUAL STRINGS FROM THE TABLE AND PLACE IT IN A NEW TABLE.  WHEN I CLICK ON A STRING I WOULD LIKE THE SELECTED STRING TO SHOW IN A TEXT BOX LABELED 'SELECTED STEP'  AFTER ALL THE SELECTED STRINGS IS IN THE TABLE I WOULD LIKE TO SAVE THE NEW TABLE AS ANOTHER SPREADSHEET -- TAB DELIMITED -- FILE, MAKING IT ACCESSIBLE TO OPEN.  HERE IS WHAT I HAVE SO FAR.  I CAN INPUT DATA INTO THE TABLE, BUT I CAN ONLY TRANSFER ONE STRING INTO THE TABLE I WOULD LIKE TO BE TO INPUT MULTIPLE STRINGS.    ALSO WHENEVER I TRY SAVING THE FILE, IT ALWAYS SAVES A UNKNOWN FILE, HOW CAN I GET IT TO SAVE AS A SPREADSHEET FILE.  THANKING ALL OF YOU IN ADVANCE FOR YOUR HELP!!!!!!
    Attachments:
    Selector.zip ‏30 KB

    Pondered,
       The question you are asking is the same one that you asked in: http://forums.ni.com/ni/board/message?board.id=170&message.id=132508#M132508, to which I supplied a revised version of the original vi you used (which was modified from the original one I supplied to an earlier thread). A couple of questions: 1) What does my latest not do that is in your question, 2) Why are you starting yet another thread about the same problem?  We are here trying to help, it makes it a lot easier if you keep the same problem in the same thread, it reduces duplication of effort from those that might not have been following the previous thread(s).  Those of us that don't have our "names in blue" are just doing this "for fun" (the blue names are NI employees, who may still be doing it "for fun"), and it makes it more fun if it doesn't seem (correctly or not) that our attempts are ignored.  If an answer doesn't help, or seems incomplete, post a little more detail to the same thread so that the original respondent, or someone new, can provide more information, or understand your problem better.
    P.M.
    Message Edited by LV_Pro on 07-20-2005 01:20 PM
    Putnam
    Certified LabVIEW Developer
    Senior Test Engineer
    Currently using LV 6.1-LabVIEW 2012, RT8.5
    LabVIEW Champion

  • Button condition on page item and Validation error Conflict

    Hi,
    I have a select list page item and a button on page whose condition is based on the select list page item value(eg, If (:P2_item1='val1'){return true;}) with condition type=PL/SQL function returning boolean. This buttons submits the page.
    It' coming fine in normal case. However, if I select some value val2 from the list and then click the button, and if there are any validation errors (like mandatory check or email check fail etc), then the button disappears because it evaluates the button condition based on the changed value(val2), but the page has not yet been submitted because of validation errors.
    I think this can be solved if I create the button condition based upon database column value instead of page item as db col value won't change until the page is submitted.
    This look like very basic use-case and I would like to know if there is any better solution to this problem.
    Note: I am using Apex 4.2.1

    I don't want to show/hide the button on the change of the page item lov value, so i am not using Dynamic action.
    What i was is to make button visible based on a condition(which is based on page item), for which we have condition attribute of a button available.
    This is a very common thing where a user chooses the button condition as Value of item/column in expression 1 is null/expr2. But what if the user changes the page item value but it doesn't get submit due to validation error. In that case, the button condition fails.
    So, i guess i have to use column name in expression 1, can u tell how to do that?
    Expression 1 = IF (:P2_STATUS='val1') then return true;
    How to change the above to use db column 'status' instead? Any direct way(like #Status#) or I have to query db to get it using select.
    Any alternative approach?

  • Double click for JList items selection

    I would like to select JList items only by double clicking on them. I can write a mouse listener for detecting double clicks by my own (and handle it afterwards), by please tell me how to turn the default behavior off (selecting items by clicking one time).
    Thanks in advance
    Marek

    I would like to select JList items only by double clicking on them. Well the standard is to select or highlight on a mouseClick or by using the arrow keys on the keyboard.
    Then once you have a selected item you can perform and Action on the item by double clicking or by using the enter key. Remember you should always be able to use either the keyboard or the mouse to perform any given function.
    This posting shows my solution for the above scenario:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=626866

  • JList item selected is displayed twice. Please Assist

    Folks,
    I have this strange behaviour when I select an item from the JList.
    When I select the an item, it gets displayed twice.
    Can anyone tell me why this is being displayed twice?
    I am also checking the Java Sun Swing tutorials site..but no luck as yet.
    Attached is a short class.
    If you click on Black or Blue etc ,it gets displayed twice...
    public class JListDemo extends JFrame{
    private JList colorList;
    private Container c;
    private String colorNames[] = {"Black", "Blue","Red","Green","Yellow"};
    public JListDemo() {
    super("JList Demo");
    c = getContentPane();
    c.setLayout(new FlowLayout());
    /** Create a List */
    colorList = new JList(colorNames);
    colorList.setVisibleRowCount(3);
    colorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    c.add(new JScrollPane(colorList));
    //** Set up Event Handler.
    colorList.addListSelectionListener(
    new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e)
    System.out.println(colorList.getSelectedValue());
    setSize(1000,550);
    show();
    public static void main(String[] args) {
    JListDemo JListDemo1 = new JListDemo();
    }

    in your ListSelectionListener you must check if the event is one of multiple change events. In your case you get one event when the mouse first selects an item and possible more when you move the cursor over the other entries. If you are only interested in the final selection check if e.getValueIsAdjusting() is false.
    // not interested in events if they are not final
    if (e.getValueIsAdjusting())
        return;
    // do what ever you want
    System.out.println(colorList.getSelectedValue());
    ...Hope this helps!

  • Delete Selected JList Item on Pressing Delete Key

    Hi,
    I have to delete selected JList item ((in JFrame using java Swing) after pressing Delete key. Please provide me code for this.
    Thanks
    Nitin

    Again read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/list.html]How to Use Lists and [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]How to Use Key Bindings.
    Are you sensing a common theme here? Do some reading on your own. The tutorial has most of the information you need.

  • Item availability for selected items and directly create the delivery

    Hi All,
    For a very big sales order ..lets say having 700 line items ...is there any convenient way to create the delivery for selected items ..e.g. 30-40 line items rather going and selecting the line items then doing the item availability.
    do you have any LSMW format by which we can do the item availability for selected items and directly create the delivery.
    kindly Guide me..
    With Regards
    Azeez.Mohd

    Hi ,
    There is no stand way of doing it . You need to take help of abaper to do this :
    1. Create a t code where if you give sale order number , it displays a report with all the items with a check box near to it as we see in SE16 .
    2. This report could be best in ALV form where users can do "ctr+f" and search only the required materials then select those lines and press a button on the top of report .
    3. Once the button is pressed , program will run vL01n ( create delv in backgrnd) in a BDC form . At time of delev creating , the bdc program in backgrnd uses only those items which were selected by user and not the other items .
    4. Program will create a delv using a BDC in background and return the delv number for user to view tht.
    U can also try using FM : RV_DELIVERY_CREATE to create delv in backgrnd after user selection if BDC is getting tricky.
    Hopefully ,this shuld work and will be a easy process for the customers.
    Let us know the outcome .. .
    B O L ..
    Hope this Helps !!!

  • Select list with redirect and save the item to insert row

    On the Form, I want to select from the item (P105_ADMIN_DOMAIN_ID)
    and pop the result on the item (P105_ADMIN_NAME).
    P105_ADMIN_DOMAIN_ID define:
    Display as "select list with redirect"
    Alternate source used "Only when .."
    Source Type "Database Column"
    Source Value or express "ADMIN_DOMAIN_ID"
    P105_ADMIN_NAME define:
    Display as "Text Field"
    Altrenate source used "Only when .."
    Source Type "SQL Query"
    Source Value or express "select party
    from responsible_party
    where logonid
    = :P105_ADMIN_DOMAIN_ID"
    questions:
    1. item P105_ADMIN_DOMAIN_ID DROP DOWN LIST is limited to
    some threadhold, it did not list all the value from
    the LOV which is follow:
    select LOGONID d, LOGONID r
    from RESPONSIBLE_PARTY
    order by 1
    2. I want to insert a row after complete the form.
    But my item P105_ADMIN_NAME is defined
    Source Type "SQL Query" instead of the 'Database
    Column'
    How could I overcome these?
    Thanks so much for your help.

    1) what i meant was for you to test this ridiculously huge LOV outside of htmldb, but it occurred to me last night that you could, in fact, be hitting a limit of ours. after some poking around, i have confirmed that. select list items in htmldb are currently limited to 10,000 rows. this was initially done for performance reasons, but they're now opening up the restriction. if you really need to work with that many rows where the user is allowed to pick from a set of values, consider using a popup item type instead. it'd help your app performance as well (in my test cases, it stank to have to wait for my 10k select list rows to come down to my browser).
    2) sorry to not have been more clear about this, but when you set your item's "Source Type" back to "Database Column", you'd have to specify that column in the "Source or value expression" field. also, you can't put a sql query into that "Post Calculation Computation" field. as i said before, "you can take a look at the attribute-level help for that field to see implementation examples."
    3) stick with "Always..." for now if you're using our auto-dml process(es)
    regards,
    raj

  • I am using Windows XP and just installed Elements 12. When I try to select a different brush or shape the drop down list will not stay open long enough to select a different item. I have used Elements 9 for awhile and have not had this problem

    I am using Windows XP and just installed Elements 12. When I try to select a different brush or shape the drop down list will not stay open long enough to select a different item. I have used Elements 9 for awhile and have not had this problem

    grannybel
    It would appear that you are destined for the Adobe Photoshop Elements Forum since your question is related to Photoshop Elements and not Premiere Elements which is the focus program where you have posted.
    But, while the arrangements are being made, here are a few things for you to think about if you have not already
    1. Reset Tools - Select Brush Tool, then
    2. Delete Settings File
    Go to Full Editor/Edit Menu/Preferences/General and click on the option "Reset Preferences on Next Launch".
    We will be watching for your progress.
    Thank you.
    ATR

  • The following error occurs after Goodle News loads and I try to use the cursor to select a news item Script: chrome://vidbar/content/downloader.js:107

    Updated to the latest Version of Firefox and checked for updates on all apps but no change and the error occurs every time I select a news item or try to scan down or up the page.

    That issue is caused by the vidbar extension
    *https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • Sometimes I cannot view background items and the option to select it is blocked. Please help.

    The opening screenshot has four news stories, each having a background. I cannot see the background on this website and the option to view the background is blocked.

    The Print button in the "3-bar" Firefox menu button drop-down list opens the Print Preview window.
    You can click the Print button in the Print Preview window or use the Print item in the File menu (File > Print) or use the Ctrl+P shortcut to have access to the print selection item and other print setup options.
    * Tap the Alt key or press F10 to show the Menu bar.
    See also:
    *Universal Print: https://addons.mozilla.org/firefox/addon/universal-print/

  • Help with select list item and dynamics action

    G'Day Apex Gurus,
    I having problems trying to achieve to trigger the help window of a select item automatically. A help window is triggered when the select item label is clicked but my client would like to be triguered automatically as soon as the user click to see the options in the select list.
    I think that I should be able to do it with dynamic actions but I can not get it to work.
    I know when someone click on the label of the select list item trigger this JavaScript
    javascript:popupFieldHelp('277938589795252851','1545903379570909')
    So I want to trigger the javascript also when the user click of the select list item and pull down the options and for that I think that Dynamic actions is the way to go but I can't get it right.
    This is what I a doing:
    I created a Dynamic option as follow:
    Name : test
    Sequence: 30
    Even: Click
    Selection type: Item(s)
    Item(s): P1_RATING <- a selection list item
    Condtion: - No Condition -
    True Actions
    Sequence: 10
    Action : Execute JavaScript Code
    Fire when event result is :True
    Fire on page load: ticked
    Code: javascript:popupFieldHelp('277938589795252851','1545903379570909')
    I appreciate any one who can tell me what i am doing wrong here or provide a solution to my problem of achieving to trigger the help window of a select item automatically.
    Kind regards
    Carlos

    Hi Carlos,
    I set up a test case in exactly the same way and it worked fine for me. I created a page item called P1_DA_DEMO and added some static select list values then added some help text. The settings I used are below, I suggest you try again but also make sure you have no other Javascript errors on the page. Use a tool like firebug to check.
    Name : Dynamic Action Demo
    Sequence: 10
    Even: Click
    Selection type: Item(s)
    Item(s): P1_DA_DEMO <- a selection list item
    Condtion: - No Condition -
    True Actions
    Sequence: 10
    Action : Execute JavaScript Code
    Fire when event result is :True
    Fire on page load: Not Ticked
    Code: javascript:popupFieldHelp('277938589795252851','1545903379570909')
    Event Scope set a s Bind.
    Thanks
    Paul

Maybe you are looking for

  • ■Adobe Photoshop CS3 Windows版アップグレード専用パッケージ (新品同様)

    ■Adobe Photoshop CS3を使っています. PDFファイルをJPEG2000でフォーマット(.jpf)→■Adobe Photoshop CS3で開けないのですが...(エラー表示=ドキュメントの種類が適切ではありません) ご存知の方 ご指南よろしくお願いします.

  • Updating firmware on used X1900 xt

    I recently bought a used ATI Radeon X1900 XT to replace my "heat fried" OEM one. The card that I installed into my Mac Pro, running 10.6.8. shows a firmware of 113-A52027-140. I turns out the latest firmware should be 113-A52027-202. The card runs fi

  • Structure won't let me add characteristics

    Hi, I have 2 structures in a query but now when I try to add some particular restricted key figures it refuses to accept them? What could be the problem? Thanks

  • Popup window from webview

    When the user clicks on a link, the link won't open because the creator made it so that it opens in a new window. (popup window) set somes to "http://openwebim.org/webim" try loadPage from somes on error return end try that code is what i have. It lo

  • Qmaster seems to be corrupting my files

    I am running qadminastrator through qmaster with 5 nodes and one controller. I have run 5 tests today, that being submitting the same file to compressor via "this computer" and then my video cluster. My cluster creates ten segments and there are erro