Problem of set focus on the cell during the validation.

I am having a table with 5 columns.
I can change the value of the 2nd cell in 2 ways.
one by 1. editing the 2nd cell
or by 2. clicking the button avilable in the 1st cell.(the button editor will set the value to the 2nd cell of selected row)
In both cases, i have to validate the value in the 2nd cell.
If the value is not meeting some criteria, i am pop uping a msg box, contain approprite message.
and the cursor should be focused on the 2nd cell until the value will be corrected.
i done for the case 1.
but for the case 2, i couldn't keep the cursor on the 2nd cell when the value got changed by the button editor of cell 1, and if the value is wrong
The 1st cell 2nd cell are having it own Renderer and Editor
even i tried a lot, but i not yet achieved it.
pls. guide me to get a perfect result.

Thnks for u'r reply.
the 1st part what i mentioned is done by the same way in those example by the sun site only.
But in the 2nd part, when i set the value to text field by the button editor,
the editor of the textField(2nd cell), is not got called.
If i made to call editor also, i am unable to keep the cursor on 2nd cell

Similar Messages

  • Problem to set focus to the particular cell in matrix

    Hi All
    I want to set the focus on the particular set on the matrix. i used following code
       oMatrix.Columns.Item("MinSal").Cells.Item(iRow).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
    but it execute two times and doesnt work Properly.
    Thanks
    Rupinder

    Hi
    If (pVal.ColUID = "MinSal") And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_LOST_FOCUS) Then
                                                                                If MinSalaryRange(pVal.Row) = False Then
                                        BubbleEvent = False
                                                                                    End If
    and MINSalaryRange is a function
    Private Function MinSalaryRange(ByVal iRow As Integer) As Boolean
            Dim oMatrix As SAPbouiCOM.Matrix = oForm.Items.Item("SalGrade").Specific
            Dim MinSal, MinSal1, MaxSal As Integer
            Try
                If iRow > 1 Then
                    For i As Integer = 1 To iRow - 1
                        If oMatrix.Columns.Item("Date").Cells.Item(iRow).Specific.String = oMatrix.Columns.Item("Date").Cells.Item(i).Specific.String Then
                            MinSal = oMatrix.Columns.Item("MinSal").Cells.Item(iRow).Specific.String
                            MinSal1 = oMatrix.Columns.Item("MinSal").Cells.Item(i).Specific.String
                            MaxSal = oMatrix.Columns.Item("MaxSal").Cells.Item(i).Specific.String
                            If (MinSal >= MinSal1) And (MinSal <= MaxSal) Then
                                SBO_Application.MessageBox("Min Salary ")
                                'oMatrix.Columns.Item("MinSal").Cells.Item(iRow).Click(SAPbouiCOM.BoCellClickType.ct_Regular)
                              '  oMatrix.Columns.Item("MinSal").Cells.Item(iRow).Click()
                                MinSalaryRange = False
                            End If
                        End If
                    Next
                Else
                    MinSalaryRange = True
                End If
            Catch ex As Exception
                SBO_Application.MessageBox(ex.Message)
                MinSalaryRange = False
            End Try
        End Function
    Thanks

  • How to set focus to a cell

    Hi everybody,
    How can i set focus to a cell?
    In the Purchase Matrix:
    oMatrix.Columns.Item("1").Cells.Item(pVal.Row).Click()
    But This set focus to column 3  (Item description. Not 1). Why?
    Thanks
    Carles
    Edited by: Carles Costa on Mar 4, 2011 10:57 AM

    hi Carles Costa,
    i think your issue is type of Purchase document. if it is Item type then matrix (38) and column(1) is itemcode,
    if service type then matrix(39) and column 1 is Description.
    this code oMatrix.Columns.Item("1").Cells.Item(pVal.Row).Click() or oMatrix.Columns.Item("1").Cells.Item(pVal.Row).Click(BoCellClickType.ct_Regular) is correct.
    hope this help you.
    thanks
    H2

  • How to set focus on the title of JTabbedPane

    I have created a JTabbedPane and added three JPanels to it. They are titled, say "Panel 1", "Panel 2" and "Panel 3". And each of them contains buttons and text areas. Since this app is for physically disabled users, it must provide navigation through these three tabs with keyboard operations only (i.e. without mouse clicks).
    When the title "Panel 1" gets focused, users can go to "Panel 2" by the right arrow key. When Panel 2 is brought up, however, the title "Panel 2" does not get focused. Instead the first button inside panel 2 is focused. In order for users to navigate to 'Panel 3" by the arrow key, the title "Panel 2" has to be focused. How do I set focus on the tab title?
    I have tried 'requestFocus()' on Panel 2, but it does not work. Please help me with this issue. Thanks in advance.

    I'd be quite interested to know if this can be doen as well so I thought I'd post this message to move it to the top of the board.
    Thanks.

  • How to set focus on the last row of JTextPane

    how to set focus on the last row of JTextPane?
    import javax.swing.*;
    import javax.swing.text.html.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MyGUITest extends JPanel implements ActionListener
    {   public static void main(String[] args)
        {   SwingUtilities.invokeLater(new Runnable()
             {   public void run()
              {    JFrame f = new JFrame("My GUI");
                  MyGUITest GUI = new MyGUITest();
                  GUI.setOpaque(true);
                  f.setContentPane(GUI);
                  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  f.pack();
                  f.setLocationRelativeTo(null);
                  f.setVisible(true);
        JTextPane txtP;
        JButton add;
        HTMLEditorKit hek;
        HTMLDocument hd;
        String txt;
        MyGUITest()
        {     this.setLayout(new BorderLayout());
         this.setPreferredSize(new Dimension(400,200));
         txtP = new JTextPane();
         txtP.setEditable(false);
         txtP.setContentType("text/html");
         txtP.setText("");
         hek = new HTMLEditorKit();
         txtP.setEditorKit(hek);
         hd = new HTMLDocument();
         txtP.setDocument(hd);
         JScrollPane sTxtA = new JScrollPane(txtP);
         add = new JButton("add");
         add.addActionListener(this);
         sTxtA.setBorder(BorderFactory.createTitledBorder(""));
         this.add(sTxtA, BorderLayout.CENTER);
         add(add, BorderLayout.SOUTH);
         new Thread(new Runnable()
         {   public void run()
             {   while(true)
              {   try
                  {     Thread.sleep(100);
                  }catch(InterruptedException ex)
                  {     ex.printStackTrace();
                  appendText("This is <b>HTML</b> text");
                  //add.doClick();
         }).start();
        public void actionPerformed(ActionEvent e)
        {     txt = "<b>asd</b>";
         try
         {   hek.insertHTML(hd, hd.getLength(), txt, 0, 0, null);
         }catch(Exception ex){   ex.printStackTrace();   }
        public void appendText(String txt)
        {     try
         {   hek.insertHTML(hd, hd.getLength(), txt, 0, 0, null);
         }catch(Exception ex){   ex.printStackTrace();   }
    }thanks~

    anIdiot wrote:
    im not sure what is the caret location...So don't youthink you should have looked for it in the API?
    anyway, i want the scroll bar to scrolled down automatically when the output is displayed.
    normally, the scroll bar is scrolled down automatically when a new text is inserted, but it doesnt work on this timeGo through camockr's http://tips4java.wordpress.com/2008/10/22/text-area-scrolling/
    db

  • How do I set focus to the Browser so I can CmdKey-A and select all?

    I've searched the shortcut list for about 10 minutes and cannot find a shortcut to shift focus to the browser (by default the right-side) preferably the lower film-strip/list pane where pressing Cmd-A selects all the photos.
    Note, that if you select an album and hit Cmd-A it doesn't select all the photos in the album - if that worked I wouldn't need to set focus to the film-strip/list pane.
    There's only 1 keyboard shortcut in the "Aperture 3 Keyboard Shortcuts" guide with the word "Focus", and it's not the one I need.

    Put it this way.
    1. Select an Album
    2. Now, you want to select all photos in that album, hit Cmd-A
    You can't do (2) until I manually click in the film-strip pane.
    I want to hit 1 key, to put me in a position to select all photos immediately.
    This would also allow me to navigate using the arrow keys.
    I'm not sure I really understand how anyone would not need this.
    You click an album, you want to navigate through them (without using the mouse) ... doesn't everyone need to do this somehow?
    ** I just realized while experimenting that hitting the arrow-key actually gives focus to the film-strip in a way that allows me to hit Cmd-A.
    So it looks like the answer is to
    1. Select the Album
    2. Hit any arrow key (sometimes it already has focus, depending on what you were doing in this album last time, by the look of it)
    3. Cmd-A now works.

  • Problem in setting focus in JTable

    Hi,
    In my application I am using JTable with a customized table model. The table has two columns. First column has jcombobox as its editor and the second column has the customized editor developed by me. This particular table appears in a wizard. When this wizard page (which contains the above JTable) is shown I set the keyboard focus on the JTable using JTable's requestFocus() method (I even tried with grabFocus()method but got the same result). But the focus does not appear on the JTable. Even none of the cells get the focus. Also no matter how many time I press tab key the focus does not shift to the next component in the page which happens to be a JButton. I have set the next focussable element for the JTable as that JButton. When I manually put the focus on one of the cells by clicking on it and then if I press either arrow key or tab key the focus is lost and it does not go either on the next cell or the JButton.
    If anybody can shed some light on what exactly needs to be done to give proper keyboard navigation for JTable please let me know.
    Regards
    Atul

    Hi Atul,
    I suspect your problem is with your cell renderer. The DefaultTableCellRenderer class has code in the getTableCellRendererComponent method that provides the visual indication as to which cell has the focus. You will want to do something similar in your JPanel-subclassed renderer - perhaps change the border or the background color to indicate whether a cell is selected or not.
    Note also that there is a difference between a cell that has "isSelected" set to true, which indicates that the cell is part of the current selection, and a cell that has "hasFocus" set to true, which indicates that the cell is the last one to be clicked on. Actually, it seems to be a bit more complicated than that, but that's at least part of what "hasFocus" indicates. A cell can be selected and not have the focus, and a cell can have the focus but not be selected. You may want to setup your renderer to clearly indicate which of these states are set and then run your app and play with the table selection to get a feel for how it works.
    Hope that helps.
    - Tyler

  • Problem in Setting Focus, on a dynamically generated field

    Hi all,
    I am having a jsp page, in which I have dynamically generated n number of input text fields, and with the function onchange="chk();", and i am passing the current text field value, and 2 more parameters min and max.
    In function chk(), i am validating the input value by condition it should be within min and max..
    my problem is i want to[b] get back the focus to the input text box, where the input is entered and not satisfied my condtion
    function chk(a,b,c)  / /a is my i/p, b and c are min and max values
    if( (parseInt(a)>=parseInt(b)) && (parseInt(a)<=parseInt(c)) )
    document.form1.submit;
    return true
    else
    alert("Invalid Output");
    var element=event.srcElement.name;
    alert(element); // I am able to get the name of input text box
    alert(event.srcElement.tagName);  // this gives INPUT
    if(event.srcElement.tagName=='INPUT')
    alert("yes"); // i can get this alert
    event.srcElement.focus();  // the focus can't be set back to that input field or element
    return false
    }

    try this and say me if it works fine!!!
    <html>
    <head>
    <script>
    function fileds() {
         var myParent = document.getElementById('myDiv');
         var text = document.createElement('input');
         text.setAttribute('id', 'myText');
         myParent.appendChild(text);
         document.all.myText.focus();
    </script>
    </head>
    <body>
    <input type="button" onClick="javascript:fileds()" value="Create And Give Focus">
    <br>
    <div id="myDiv"></div>
    </body>
    </html>
    bye

  • Set Focus to a cell in ALV on action performed outside ALV

    Hi All,
    In my application i have created a dynamic ALV using technical structures.
    I have few fixed columns and few scrollable columns.
    The scrollable columns represents dates. The caption of the ALV headers are set later with the dates.
    I have a date navigator control. On choosing a date, the headers of date columns changes.
    Table layout is fixed with 4 displayed scrollable columns displayed each time.
    Issue:
    When i use horizontal scroll on ALV and then navigate on a date, then the ALV headers are updated. But the scroll position is not changed. I would want to focus on the first date column.
    I tried 2 options to set focus. But both dont seem to work.
    Could you provide me some suggestions?
    Option 1:
      CALL METHOD lo_view->if_wd_view_controller~request_focus
        EXPORTING
          context_element = lo_el_time_ps            " i get the element reference for the right index )
          attribute       = lv_attribute_name            "first date column name (technical name)
    Option 2:
    lo_interfacecontroller = wd_this->wd_cpifc_alv_usage1( ).
    lo_interfacecontroller->set_focus(
                                      index = lv_index                       " i get the element reference for the right index )
                                     column = lv_attribute_name ).   "first date column name (technical name)
    Regards,
    Rekha

    hi Carles Costa,
    i think your issue is type of Purchase document. if it is Item type then matrix (38) and column(1) is itemcode,
    if service type then matrix(39) and column 1 is Description.
    this code oMatrix.Columns.Item("1").Cells.Item(pVal.Row).Click() or oMatrix.Columns.Item("1").Cells.Item(pVal.Row).Click(BoCellClickType.ct_Regular) is correct.
    hope this help you.
    thanks
    H2

  • Problem using Setting Focus

    Hello there, can you help me on how to use the set Focus.
    For instance I have a 3 JTextField, when I run it, the focus is on the first textField, what I want is that, when I pressed the enter key on the keyBoard, the focus will be on the 2nd textField, and when I pressed again the enter key, the focus will be on the 3rd textField and so on.
    can you give me a sample code on this one, thanks.

    the last post in this thread might give you some ideas
    http://forum.java.sun.com/thread.jspa?threadID=713697&tstart=0
    note: will only work if the textfields follow each other in the focus traversal policy

  • How to set Focus on a Cell in a Table

    I have a column for which i set the table editor in the following way :
    DateTextField contractStarts = new DateTextField();
    itemTable.getColumnModel().getColumn(9).setCellEditor(new DefaultCellEditor(contractStarts);
    When the focus is brought to a cell in 9th column thru tab key I want the cursor displayed and invariably invoking the cell editor without clicking the cell.
    If i don't click on the cell the cell editor (contractStarts) implementation does not seem to work or otherwise does very well. Since normally a user would manoeuvre using tab key.
    Can this be done. I am searching for possible clues to this.
    Regards
    Shomal

    OK well I tried your example again and it does work in my Chrome and Firefox browser. IE10 still won't let me type into the fields.
    I borrowed some of your code and changed your input to fit with mine.
        if (typeof oItem.getCells()[1].$().find('input').selectionStart === "number") {
    oItem.getCells()[1].$().find('input').selectionStart =
         oItem.getCells()[1].$().find('input').selectionEnd =
      oItem.getCells()[1].$().find('input').value.length;
        } else if (typeof oItem.getCells()[1].$().find('input').createTextRange !== "undefined") {
    oItem.getCells()[1].$().find('input').focus();
    var range = oItem.getCells()[1].$().find('input').createTextRange();
    range.collapse(false);
    range.select();
    In debugger when I evaluate:
    oItem.getCells()[1].$().find('input').selectionStart
    it is undefined.

  • How to set focus in the parent window after a JOptionPane pop up ?

    I am not able to set the focus back to a JTextField in the parent window after poping up a JOptionpane.showMessageDialog(). I tried requestfocus(),requestFocusInWindow etc......but not working. The code is given below.
    if ((encryptor.encrypt(password)).equals(configuredPasswd)) {
                        validPassword = true;
                   } else {
                        JOptionPane.showMessageDialog(saveUI,"The password entered is not correct.");
                        saveUI.getPasswdField().setText("");
    saveUI.getPasswdField().requestFocus();
    Sometimes the focus is coming to the JTextField.Sometimes it appears for a moment and then dissappears.Please give a solution

    see if this makes a difference
    if((encryptor.encrypt(password)).equals(configuredPasswd))
      validPassword = true;
    else
      JOptionPane.showMessageDialog(saveUI,"The password entered is not correct.");
      ActionListener al = new ActionListener(){
        public void actionPerformed(ActionEvent ae){
          saveUI.getPasswdField().setText("");
          saveUI.getPasswdField().requestFocusInWindow();}};
      javax.swing.Timer timer = new javax.swing.Timer(100,al);
      timer.setRepeats(false);
      timer.start();
    }

  • Problem in set selectedTextcolor in uitableview cell in iPhone SDK 3.1.2

    Hello,
    I set selected text color in uitableview cell using cell.selectedTextColor = [UIColor whiteColor]; for iPhone SDK 2.2.1.
    Now i use iPhone SDK 3.1.2, So for that i make change as per documentation for that i use textLabel properties. But selectedTextColor is not exit.
    So Now for SDK 3.1.2 how to set selectedTextColor?..
    Thank you.

    The textLabel property is an instance of UILabel, so it has its own textColor, textAlignment, and font properties. E.g.:
    cell.textLabel.text = @"foo";
    cell.textLabel.textColor = [UIColor whiteColor];
    cell.textLabel.textAlignment = UITextAlignmentLeft;
    Hope that helps!
    - Ray

  • Plz help  for set focus in the table column

    hi
    I have aproblem like i want that when i click on submit button aftr filling tables column value if there is any error the error massage displaying after that click on masaage ok button get focus of my cursor on the same column where i was not fill any value .
    i am giving a piece of code also with this also
    thanks in advance
    else if(!checkResources())//check if all resource brackets are set
    JOptionPane.showMessageDialog(this, "Resource Brackets are not correct or complete." , "Error", JOptionPane.OK_OPTION);
                   //resourceTable.requestFocus(true);
              return;
    private boolean checkResources()
    try
                   float number = -999999999.0F;
              float[] lowerRange = new float[ resourceModel.getRowCount()];
              float[] upperRange = new float[ resourceModel.getRowCount()];
              allResource.setVisible(false);
              overlapRes.setVisible(false);
              for( int i =0; i< resourceModel.getRowCount(); i++)
                   if(((Boolean)resourceModel.getValueAt(i,4)).booleanValue())
                        lowerRange[i] = -999999999.0F;
                   else
                        lowerRange[i] = ((Float)resourceModel.getValueAt(i,2)).floatValue();
                   if(((Boolean)resourceModel.getValueAt(i,5)).booleanValue())
                        upperRange[i] = 999999999.0F;
                   else
                        upperRange[i] = ((Float)resourceModel.getValueAt(i,3)).floatValue();
              for(int i =0; i<lowerRange.length-1 ; i++)
              {     int temp =i;
                   for(int j= i+1; j<lowerRange.length; j++)
                   {     if(lowerRange[temp] > lowerRange[j])
                             temp = j;
                        else if(lowerRange[temp] == lowerRange[j])
                             if(upperRange[temp] > upperRange[j])
                                  temp = j;
                   if(temp != i)
                   {     float swapt = lowerRange[i];
                        lowerRange[i] =lowerRange[temp];
                        lowerRange[temp] = swapt;
                        swapt = upperRange;
                        upperRange[i] =upperRange[temp];
                        upperRange[temp] = swapt;
              for(int i=0; i<lowerRange.length; i++)
              {     if(lowerRange[i] != number )
                   {     if(lowerRange[i] < number)
                             overlapRes.setVisible(true);
                        else
                             allResource.setVisible(true);
                        return false;
                   number = upperRange[i];
    if(number != 999999999.0F)
              {     allResource.setVisible(true);
                   return false;
              return true;
    catch(Exception e)
    CAT.error("Error in checking wheather resource Bracket is complete or not",e);
    return false;
    this code belongs to action perform method....
    the function for chek rong value is ritten insisde checkresources() function
    plz help

    plz help ASAP

  • Set focus on particular cell in a JTable when using TableModel.

    I want to implement validation in my table cells. I the value does not satisfy certain condition then the focus should remain on the same cell and the user should be asked to enter valid value.
    I am using TableModel and i have tried implementing validation in the setValueAt() method some thing like this.
    setValueAt method of my table model.
    public void setValueAt(Object value, int row, int col){
    if(datalist.size()>row){
    OutboundFieldMappingObj obj=(OutboundFieldMappingObj)datalist.get(row);
    String str=null;
    switch (col){
    case 0:
    str=Validator.getValidNumber((String)value,1,999999999L);
    obj.setFiledName(str);
    break;
    case 1:
    str=Validator.getValidString((String)value,128,false);
    obj.setFiledClass(str);
    break;
    case 2:
    obj.setSource((String)value);
    break;
    fireTableCellUpdated(row, col);
    But this doesn't solve the issue. In this case after entering the value when i click on some other cell then it shows me a message stating that the value is invalid but it doesn't takes the focus back to same cell. The focus is shifted to the cell where i have clicked.
    Please help me out in resolving the issue.
    I have added the code of my validator class at the bottom if any one needs to have a look at it.
    Thanks
    Validator class
    public class Validator {
    public Validator() {
    public static String getValidString(String val, int max, boolean upper) {
    if (val == null || val.equals("")) {
    showErrorMsg("The cell can not be left blank");
    return " ";
    if (val.length() > max) {
    val = val.substring(0, max);
    showErrorMsg("String value to long. Truncated to " + max +" characters.");
    if (upper) {
    val = val.toUpperCase();
    return val;
    public static String getValidNullableString(String val, int max, boolean upper) {
    if (val == null) {
    return null;
    if (val.length() > max) {
    val = val.substring(0, max);
    showErrorMsg("String value to long. Truncated to " + max +" characters.");
    if (upper) {
    val = val.toUpperCase();
    return val;
    public static String getValidNumber(String number, int min, long max) {
    try {
    long num = Long.parseLong(number);
    if (num < min) {
    showErrorMsg("Number less than mininum value of " + min + ".");
    return "" + min;
    if (num > max) {
    showErrorMsg("Number greater than maximum value of " + max +".");
    return "" + max;
    return number;
    } catch (Exception x) {
    showErrorMsg("Invalid Entry. Number Expected.");
    return "0";
    // return "";
    public static boolean getValidNumber(String number) {
    try {
    Integer.parseInt(number);
    return true;
    } catch (Exception x) {
    showErrorMsg("Invalid Entry. Number Expected.");
    return false;
    // return "";
    public static void showErrorMsg(String message) {
    JOptionPane.showMessageDialog(new java.awt.Frame(), message,
    "Invalid Value!",
    JOptionPane.ERROR_MESSAGE);
    public static boolean validString(String str) {
    if (str != null && str.length() > 0) {
    return true;
    return false;
    }

    You need to create a custom editor. Something like this:
    http://forums.sun.com/thread.jspa?forumID=57&threadID=642364
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

Maybe you are looking for

  • How to create clipping paths shape like a slice of a circle?

    I want to make a DVD label by dividing the circle into 8 equal slices (like cutting a pie 4 times). In each slice I will put an actor's photo in it. I think I need to create 8 layers to house the 8 slices of photo, each layer gets a clipping path tha

  • Report Output Changed when Executed in Background

    Hi Guys, I have generated a report,which when executed online displays four records. But when i am executing the same report in background by generating a spool,my output is changed,such as third record is missing and i am getting only three records.

  • UNIX scripting with id and password in clear text

    Hi I have a shell script to connect and do several PLSQL. how can the script doing it without the ID password in cleartext? i.e. #!/bin/sh conn id/password ....

  • Roxio Media manager

    Installed the latest version (5.0) of BB Desktop. It then downloaded and installed Roxio Media Manager, which always opens up trying to configure itself, and gives the error "Unrecognized character in the My Pictures path". Did a search of the regist

  • OS Yosemite Slowed My MAC DOWN!

    I am new to Mac and a brand new user with Apple products.  Since I upgraded to this OS Yosemite, it slowed my computer even slower than my previous windows pc.  As a new user, I am very disappointed and of course I can't return my Mac now since its o