How to handle events in J Table (Enter event)

I created a J Table having multiple rows and columns. I want to have the event to happen on second column, on entering the code on first column, and then pressing ENTER.
Eg:
first column i enter code : say A010
In the code master, the description matching the above code is "HIGH TENSION CABLE".
When I enter "A010" in the first column and press "ENTER", i want the description to appear in the second column i.e. HIGH TENSION CABLE (by referring the code master, which I already created).
How this can be handled. Please help me with the code/suggestions. As this urgently required for me in a project, I request the FORUM to help at the earliest.
Thanking you in advance.
PS: I shall appreciate if the reply is also sent to my email id: "[email protected]".
N Murali

This code would do your work
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class TestTable
    private JTable table;
    private AbstractTableModel model;
    private DefaultTableModel defaultModel;
    private JScrollPane jsp;
    public TestTable()
        table = new JTable();
        defaultModel = new DefaultTableModel(10,5);
        setModel(defaultModel);
        jsp = new JScrollPane(table);
        hookSetTextOnEnter();
    protected void hookSetTextOnEnter()
        String actionName = "selectNextRowCell";
        final Action enterAction = table.getActionMap().get(actionName);
        Action myAction = new AbstractAction()
            public void actionPerformed(ActionEvent e)
                int row = table.getSelectedRow();
                int column = table.getSelectedColumn();
                System.out.println(" SELECTING NEXT ROW "+row+""+column);
                if(row != -1 && column == 2 )
                    Object value = table.getValueAt(row,column);
                    if(value != null && value.toString().equals("A010"))
                    table.setValueAt("HIGH TENSION CABEL",row,column+1);
                enterAction.actionPerformed(e);
        table.getActionMap().put(actionName,myAction);
    public void setModel(TableModel model)
        table.setModel(model);
    public JScrollPane getScrollPane()
        return jsp;
    public JTable getTable()
        return table;
    public static void main(String[] args)
        TestTable tt = new TestTable();
        JFrame frame = new JFrame("Test Table");
        frame.getContentPane().add(tt.getScrollPane());
        frame.pack();
        frame.setVisible(true);
}------- Unformatted Version------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class TestTable
private JTable table;
private AbstractTableModel model;
private DefaultTableModel defaultModel;
private JScrollPane jsp;
public TestTable()
table = new JTable();
defaultModel = new DefaultTableModel(10,5);
setModel(defaultModel);
jsp = new JScrollPane(table);
hookSetTextOnEnter();
protected void hookSetTextOnEnter()
String actionName = "selectNextRowCell";
final Action enterAction = table.getActionMap().get(actionName);
Action myAction = new AbstractAction()
public void actionPerformed(ActionEvent e)
int row = table.getSelectedRow();
int column = table.getSelectedColumn();
System.out.println(" SELECTING NEXT ROW "+row+""+column);
if(row != -1 && column == 2 )
Object value = table.getValueAt(row,column);
if(value != null && value.toString().equals("A010"))
table.setValueAt("HIGH TENSION CABEL",row,column+1);
enterAction.actionPerformed(e);
table.getActionMap().put(actionName,myAction);
public void setModel(TableModel model)
table.setModel(model);
public JScrollPane getScrollPane()
return jsp;
public JTable getTable()
return table;
public static void main(String[] args)
TestTable tt = new TestTable();
JFrame frame = new JFrame("Test Table");
frame.getContentPane().add(tt.getScrollPane());
frame.pack();
frame.setVisible(true);
Thanks,
Kalyan

Similar Messages

  • How to handle scroll bar in table control in bdc

    hi friends,
       how to handle scroll bar coding in table control in bdc
    Thanks & Regards,
    Srinadh D

    hi,
    check the sites :
    table control scrolling:
    Scrolling in table control
    Re: scrolling in table control
    Table control - Vertical scrolling problem
    table control scrolling problem

  • How to handle main vi short cut menu event in subvi

    I am making a thin GUI with a subVI to handle all the events including top VI UI events. I can get most of the events working but not with the short cut menu events. What I did was to pass the top VI control reference to a subVI and then registered for dynamic event. The event refnum is then passed on to another subVI next to it with the actual event structure where the top VI control's short cut event was handled. (using two separate subVIs definitely helped clean up the code, and I don't suspect it is the problem as other events worked fine in this structure)
    After not able to get it to work, I also tried to register the dynamic event inside the event structure of the 2nd subVI mentioned above, which still not working. Your help is greatly appreciated.

    I do have another problem related to handling top VI events in a subVI:  as my top VI controls were set as "Latch When Released", they cannot be located inside the event structure anymore, the result is that even though I can have their events correctly handled, those controls will stay pressed and not returning to the latch state as previously when I had the event structure located in the top VI itself.
    As I have to many controls, I dont want to change their mechanical action state and just wish to have an easier solution. Thanks.

  • How to handle 3 different fact tables and measures within a DAX query?

    I am writing a DAX query in DAX studio in Excel against a tabular model that has 4 different Fact tables, but they share the same dimensions. (There's some long story I can't get into here, but unfortunately this is the structure) I want to
    include measures from the 4 fact tables, summarize by the dimensions in a single query output that can be used for a pivot table.  So far I have something like this:
     EVALUATE
    FILTER
        SUMMARIZE
            FactTable1,
            DimensionTable1[Value],        DimensionTable2[Value],
            DimensionTable3[Value],
            Dimensiontable4[Value],
            'dimDateTime'[Month PST],
            DimDateTIme[FiscalYear PST],
            "Measure Score",
            FactTable1[Measure 1],
            "Measure Score 2",
            FactTable1[Measure 2],
        ,Company[CompanyName]="Company ABC" 
    What I want to do is summarize the 3 fact tables by the same dimensions, but I am not sure how to do that within a DAX query.  I am getting an error if I try to include another table statement in the original SUMMARIZE function, even though the FACTS
    do share the same dimension.  Is there an easy way to do this?

    You can use ADDCOLUMNS to add the data from other tables, but you need to use within the SUMMARIZE the fact table that determines the cardinality of the output. If you are not sure (e.g. you project cost and revenues from two fact tables by month and there
    could me months with cost and no revenues, but also months with revenues and no costs), then you should use CROSSJOIN and then FILTER.
    You query might be written as (please note CALCULATETABLE instead of FILTER to improve performance):
    EVALUATE
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE (
                FactTable1,
                DimensionTable1[Value],
                DimensionTable2[Value],
                DimensionTable3[Value],
                Dimensiontable4[Value],
                'dimDateTime'[Month PST],
                DimDateTIme[FiscalYear PST]
            "Measure Score", FactTable1[Measure 1],
            "Measure Score 2", FactTable1[Measure 2]
        Company[CompanyName] = "Company ABC"
    Marco Russo http://www.sqlbi.com http://www.powerpivotworkshop.com http://sqlblog.com/blogs/marco_russo

  • How to handle field symbols internal table values?

    HI all,
              I declared field string as below.The below code is working fine.
    Data : ITAB TYPE STANDARD TABLE OF YAPOPLN, (Custom table).
              wa_itab like line of ITAB.
    field-symbol : <fs> type ITAB.
    ASSIGN PARAM TO <FS>
    LOOP AT <FS> INTO WA_ITAB.
    WRITE:/ 'ABC'.
    ENDLOOP.
    But my requirement is that I dont want all the fields of the table YAPOPLN.My output contains only 2 fields of the table YAPOPLN,which contains total 4 fields.According to my requirement only 2 fields will be getting into one parameter PARAM(this is function module parameter,which is from ALV classes) from the user entered output,which contains only 2 fields.So the above code is not working properly because wa_itab contains 4 fields and giving short dump.
    If I am declaring the internal table with the required fields(only 2 fields) and referring that internal table to field symbol <FS>
    Data : BEGIN OF ITAB1 OCCURS 0,
             FIELD1 LIKE YAPOPLN-FIELD1,
             FIELD2 LIKE YAPOPLN-FIELD2,
             END OF ITAB1.
    field-symbol : <fs> LIKE ITAB1 OR  <FS> TYPE ANY.
    DATA :WA_ITAB1 LIKE LINE OF ITAB1.
    ASSIGN PARAM TO <FS>
    LOOP AT <FS> INTO WA_ITAB.
    WRITE:/ 'ABC'.
    ENDLOOP.
    But when I am compiling this code i am getting the below error.I am gettting the same below error when even <FS> is also declared as <FS> TYPE ANY.
    .'FS' is not an internal table or defined in TABLES.
    Can anyone help me in this regard?
    Thanks,
    Balaji

    Hello,
    Try this way:
    If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
    itab = <itab>.
    Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
    Now, you can create <wa> as follow:
    FIELD-SYMBOLS <wa>.
    DATA wa TYPE REF TO DATA.
    CREATE DATA wa TYPE LINE OF <itab>.
    ASSIGN wa->* to <wa>.
    This way your work area is read.
    Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
    Finally you can use that value to load static internal table.
    You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
    Hope this helps!
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 20, 2009 10:06 AM

  • How to handle (drag and drop) and Action Event in a JList?

    I am having many JList,
    On click of an element in JList I am loading a image in JSP.
    But If I try to drag and drop one image from one bucket to another bucket Iam not getting any problem,
    But I when I drag all the images from the target List to some other List and make the target List empty.
    Now If I try to move the image from source list to the target list Iam getting this error,
    Exception in thread "AWT-EventQueue-6" java.lang.NullPointerException
         at pdfViewer.NewFileSegregater$24.valueChanged(NewFileSegregater.java:1944)
         at javax.swing.JList.fireSelectionValueChanged(Unknown Source)
         at javax.swing.JList$ListSelectionHandler.valueChanged(Unknown Source)
         at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
         at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
         at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
         at javax.swing.DefaultListSelectionModel.insertIndexInterval(Unknown Source)
         at javax.swing.plaf.basic.BasicListUI$Handler.intervalAdded(Unknown Source)
         at javax.swing.AbstractListModel.fireIntervalAdded(Unknown Source)
         at javax.swing.DefaultListModel.addElement(Unknown Source)
         at pdfViewer.NewFileSegregater.actionPerformed(NewFileSegregater.java:2918)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener$Actions.actionPerformed(Unknown Source)
         at javax.swing.SwingUtilities.notifyAction(Unknown Source)
         at javax.swing.JComponent.processKeyBinding(Unknown Source)
         at javax.swing.KeyboardManager.fireBinding(Unknown Source)
         at javax.swing.KeyboardManager.fireKeyboardAction(Unknown Source)
         at javax.swing.JComponent.processKeyBindingsForAllComponents(Unknown Source)
         at javax.swing.JComponent.processKeyBindings(Unknown Source)
         at javax.swing.JComponent.processKeyEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
         at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
         at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
         at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
         at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Please help me how to solve this problem..

    Er, sure. In the class pdfViewer.NewFileSegregater on line
    1944 (!), in the valueChanged() method, something is pointing to
    null.
    That method is being called from
    pdfViewer.NewFileSegregater.actionPerformed() on line
    2918 (!!).
    Of course, none of us know what's going on in those code
    segements but you. And for the record, that's not how to spell
    Segregator.

  • How to handle Datatype mismatch in table and EO

    Hi
    I have one table which store employee details, where empId of employee is of data type varchar2. I have its equivalent EO and VO with empId as Number type. when i create a row with empId as 100 its seen as -530000000000 something of this form.
    How to resolve this issue without disturbing database.

    Hello Suresh,
    Change the attribute in the entity object to VARCHAR2.
    Regards.

  • How to handle Many-to-Many tables

    I have table_1 with a primary key, x
    I have table_2 with primary key y
    Table_3 represents the many-to-many relationship between table_1 and table_2, and has a primary key x,y.
    Okay - so I know how to set up master detail forms for table_1 and for table_2, but what type of form do I use for table_3? I want to use the primary key of table_1 as an item (:pagenum_x, I guess) and then select from a drop-down list for key y.
    I am am newbie, so if this is somewhere in the documentation (I can't find it after a few days trying), just tell me to keep looking. :)
    Norm

    Vojin,
    Thanks for the reply. It helps to have some corroboration when these types of issues come up.
    I can create regions or pages that handle the associations, but it seems as though I am fighting or fooling the product (APEX) to do so. Maybe adding the rowid with a sequence / trigger will simplify the design.
    Thanks,
    Norm

  • How to handle pagenation for tree table

    Hi,
    I implemented af:treeTable but, that table is displaying 20K rows(childerns). When i ckick on the views->Expand All, taking 30min to load the treeTable.
    Is there any wan to handle this problem or is there any way to pagenate the treeTable?
    Regards,
    Raghu.

    Hi,
    I have used the following KMs in my transformation with the following options:
    IKM SQL Incremental Update
    INSERT    <Default>:true
    UPDATE    <Default>:true
    COMMIT    <Default>:true
    SYNC_JRN_DELETE    <Default>:true
    FLOW_CONTROL    <Default>:true
    RECYCLE_ERRORS    <Default>:false
    STATIC_CONTROL    <Default>:false
    TRUNCATE    <Default>:false
    DELETE_ALL    <Default>:false
    CREATE_TARG_TABLE    <Default>:false
    DELETE_TEMPORARY_OBJECTS     <Default>:true
    LKM SQL to SQL
    DELETE_TEMPORARY_OBJECTS    <Default>:true
    CKM Oracle
    DROP_ERROR_TABLE    <Default>:false
    DROP_CHECK_TABLE    <Default>:false
    CREATE_ERROR_INDEX    <Default>:true
    COMPATIBLE    <Default>:9
    VALIDATE    <Default>:false
    ENABLE_EDITION_SUPPORT    <Default>:false
    UPGRADE_ERROR_TABLE    true

  • How to handle the MISSING STATISTICS:Table or Index has no optimizer stats

    Dear All,
    For some of our recently created Ztables, we have been receiving an error message of MISSING STATISTICS in the system saying that Table or Index has no optimizer statistics. To solve the problem, when I go for creating an index with the key fields of the table, I receive a message that these fields are already there in the index 0 (primary index).
    Pls advice how to solve this issue.
    Regards,
    Alok.

    Hi friend,
    Please delete all primary and secondary indexes and redo creation of index. Now u will surely be able to create it.

  • How to handle hot spot in table

    I have a screen with ALV grid where the first column is hot spot and when you press it, it will go to another screen and display details of selected row with some additional functionality as below.
    Now I want to skip this screen and proceed to next step .
    To do this I have recorded the flow and then I have created script to identify which row is selected with the following script which is working fine.
    In the recorded script(below) I had selected the second row of the grid, so that displayed screen show second row details and when I changed the value to 3, event of the 3rd row triggered and works fine.
    Since i have the selected row value,Can I make this value (marked in above screen) dynamic? So that every time I trigger the hot spot it will capture corresponding row and display the screen.
    Message was edited by: Shaik Shadulla

    Hi Shaik Shadulla,
    I am also having the same requirement .Have you fixed this issue?
    Could you please let me know how you have fixed?
    Thank you,
    Arunkumaran

  • How to handle Adobe Form - Dynamic Tables.

    Experts:
    I am new to Web DynPro for ABAP and Adobe Interactive forms.
    I have created a Adobe form with dynamic table. When I submit the form, WD4A is able to read only the first row of the table. Other rows are getting lost.
    I thought just binding with the context will trasfer data from Adobe to WD4A. But it is not happending.
    Do I need to write any code in WD4A and any script in Adobe Designer?
    Can any one send me a sample code (ABAP and JavaScript). Even link to that will be very useful.
    Thanks,
    Vijai

    Thomas:
    My context is as follows.
    <CHANGING>
      <REQUISITION_ITEMS>
        <ELEMENT..1>
        <ELEMENT..2>
        <ELEMENT..3>
    The cardinality of <CHANGING> node is 1..1 and the cardinality of  <Requisition_items> is 1..n.
    Thanks
    Vijai

  • How to handle plsql Object and Table type inside BPEL

    Hi All,
    I have a procedure with 5 IN and 4 OUT parameters. Out of 4, One is Object type and remaining 3 are Table type. Now in my bpel, i am calling this proc from DB Adapter. The DB Adapter wizard created XSD with proper structure. But when i am testing this i am not getting these out parameters values in the payload of Invoke DBAdapter activity. I am neither getting errors nor output.
    What could be the issue.?
    Thanks in advance,
    Sudheer

    Arik,
    JDev is not creating any wrapper packages as such. It simply created a XSD with same as my procedure name.
    My XSD looks like this...
    <element name="OutputParameters">
    <complexType>
    <sequence>
    <element name="P_OBJ_H_INFO_O" type="db:APPS.H_OBJ_TYPE" db:index="6" db:type="Struct" minOccurs="0" nillable="true"/>
    <element name="P_TAB_L_INFO_O" type="db:APPS.L_TAB_TYPE" db:index="7" db:type="Array" minOccurs="0" nillable="true"/>
    <element name="P_TAB_M_INFO_O" type="db:APPS.M_TAB_TYPE" db:index="8" db:type="Array" minOccurs="0" nillable="true"/>
    <element name="P_TAB_A_INFO_O" type="db:APPS.A_TAB_TYPE" db:index="9" db:type="Array" minOccurs="0" nillable="true"/>
    </sequence>
    </complexType>
    </element>
    And again the 3 table types internally referring object types.
    Thanks for reply. Awaiting response...
    Sudheer

  • How to handle Event in JACOB API

    Hi,
    I am read the outlook mail using JACOB[Java Com Bridge] API successfully, now i want to handle events for outlook mail using JACOB. and also i can able to catch the new mail event. but i am unable to catch any deleted mail and move mail from one folder to another folder. This is extremely important for my project. so any one please tell me how to handle and catch the Outlook deleted event and move event using JACOB.
    Thanks in Advance,
    With Regards,
    Ganesh

    Windows can be closed in a number of ways and the simplest way to trap them would be to handle Window Closing in code behind.
    This is also the easiest way to show dialogs if that's how you wanted the warning message to appear.
    This:
    chxAllowToClose.IsChecked
    Looks like a checkbox to me, seeing as you have IsChecked.
    That presumably means you already have that bound to a viewmodel and visible to the user.
    You can therefore just test that value from the view.
    If you prefer to hide that instead then there are several options.
    You could have a dependency property and a binding in code behind which binds to the viewmodel. Test that in your event.
    Or
    You could save the value when it changes to application.current.resources.  Since dependency properties and bindings are a bit wordy this is easier.
    Or
    You could have just a variable in the view code behind and use messenger to tell that when the value changes from the viewmodel:
    http://social.technet.microsoft.com/wiki/contents/articles/26070.communicating-between-classes.aspx
    Please don't forget to upvote posts which you like and mark those which answer your question.
    My latest Technet article - Dynamic XAML

  • How to handle transaction exception

    Hi,
    I am using jdev 11g.
    I need to catch the exception in my transaction like (table not found, column must not be null, column not found, ...)
    hereunder is my code.
      public void saveOsaUser(OsaUser osaUser) throws Exception {
        EntityManager em = getEntityManager();
        try {
          utx.begin();
          em.joinTransaction();
          em.persist(osaUser);
          utx.commit();
        } catch (Exception ex) {
          try {
            utx.rollback();
            throw new Exception(ex.getLocalizedMessage());
          } catch (SQLException sqle) {
            throw new Exception(sqle.getLocalizedMessage());
          } catch (IllegalArgumentException iae) {
            throw new Exception(iae.getLocalizedMessage());
          } catch (EJBException ejbe) {
            throw new Exception(ejbe.getLocalizedMessage());
          } catch (RuntimeException re) {
            throw new Exception(re.getLocalizedMessage());
          } catch (Exception e) {
            throw new Exception(e.getLocalizedMessage());
        } finally {
          em.close();
      }Whatever the error type, i always get the message : Transaction does not exist.
    Kindly advice how can handle these SQL error (table not found, column must not be null, column not found, ...)
    Regards
    Emile BITAR

    Repost

Maybe you are looking for

  • Linux Cluster File System partitions for 10g RAC

    Hi Friends, I planned to install 2 Node Oracle 10g RAC on RHEL and I planned to use Linux File system itself for OCR,Voting Disk and datafiles (no OCFS2/RAW/ASM) I am having SAN storage. I would like to know how do i create shared/cluster partitions

  • Illustrator CS5.5 Transforms in Actions not working properly?

    I'm doing a simple transform action. I want to move an object to a value on the Y axis. First of all, after recording the action, and setting the Y value to 64 px, the action is recorded as 64 pt, not px. This happens regardless of my 'Units' setting

  • What will I do with the SQL Server (2012/2014) (Standard/Enterprise) Licenses?

    What will I do with the SQL Server (2012/2014) (Standard/Enterprise) Licenses? Are these the same as software product keys, or just some pieces of paper the company needs to have on hand? In which case, when we install SQL Server 2014, (and when look

  • Where do I get the Request-Object

    Dear Friends, I want to upload a file via HTTP multipart-formdata request (POST). For that reason I use the FileUpload-API: http://jakarta.apache.org/commons/fileupload/using.html Everything is described perfectly and I am very happy that there is su

  • Creative Suite 6 (CS6) Master Collection Student Edition

              Hi;      I'm a student in Turkey. I want to buy Creative Suite 6 Master Collection Student Edition. Because it's too cheap than normal CS6.      I have a credit card in Turkey and in USA. I want to but CS6 Master Collection Student Edition