Capturing data from JTable and passing it to a class

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.table.AbstractTableModel;
import java.security.*;
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import javax.swing.SwingUtilities;
public class ProjectTable2 extends JFrame implements ActionListener
JButton Up;
// String lecturer_data[][];
public ProjectTable2()
super("Lecturer Table");
setSize(300, 200);
// addWindowListener(new BasicWindowMonitor());
//JButton Up = new JButton("Update");
//Up.addActionListener(this);
//getContentPane().add(Up, BorderLayout.SOUTH);
TableModel tm = new AbstractTableModel()
//JTable jt = new JTable(tm);
//JScrollPane jsp = new JScrollPane(jt);
//getContentPane().add(jsp, BorderLayout.CENTER);
Object[][] data = {
{"Sandip", "Vekaria", "ee99c9", "A"},
{"Manesh", "Mistry", "ee99b4", "A"},
{"Barry", "Kwok", "ee99b6", "A"},
{"Nikhil", "Nag", "ee99b3", "A"},
{"Kevin", "Jervis", "ee99b1", "A"}};
/* lecturer_data[][] = new String[data.length][4];
for(int row = 0; row < data.length; row++)
for(int col = 0; col <= 3; col++)
lecturer_data[row][col] = data[row][col];
String[] headers = {"First Name", "Second Name", "UserName", "Grades"};
public int getRowCount() { return data.length;  }
public int getColumnCount() {return headers.length; }
public String getColumnName(int c) {return headers[c]; }
public Object getValueAt(int r, int c) {return data[r][c]; }
public boolean isCellEditable(int r, int c)
if (c < 3)
return false;
else
return true;
/* Returns cell information of a record at location row,column
public synchronized Object getValueAt(int r, int c)
try
ProjectTable2 p = (ProjectTable2)data.elementAt(r;
switch (c)
case 0:
return (String)p.val1;
case 1:
return (String)p.val2;
case 2:
return new Integer(p.val3);
catch (Exception e)
return "";
public void setValueAt(Object value, int r, int c)
if (c >=3)
System.out.println("Setting value at " + r +", " + c + " to " + value);
else {data[r][c] = value;}
data[r][c] = value;
fireTableCellUpdated(r, c);
JTable jt = new JTable(tm);
JScrollPane jsp = new JScrollPane(jt);
getContentPane().add(jsp, BorderLayout.CENTER);
Up = new JButton("Update");
Up.addActionListener(this);
getContentPane().add(Up, BorderLayout.SOUTH);
public void actionPerformed(ActionEvent bc)
// fireTableCellUpdated(r, c);
if(bc.getSource()==Up)
Lecturer nameGrades = new Lecturer("Raul Mondragon", "ele_956", true);
// nameGrades.setTableDataUpdate(lecturer_data);
//no_of_rows = tm.
System.out.println("Update");
// nameGrades.printDetails3();
// nameGrades.printDetails4();
//JTable jt = new JTable(tm);
//JScrollPane jsp = new JScrollPane(jt);
// getContentPane().add(jsp, BorderLayout.CENTER);
public static void main(String args[])
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
ProjectTable2 pt = new ProjectTable2();
pt.setVisible(true);
Somebody please help!!

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.table.AbstractTableModel;
import java.security.*;
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import javax.swing.SwingUtilities;
public class ProjectTable2 extends JFrame implements ActionListener
JButton Up;
// String lecturer_data[][];
public ProjectTable2()
super("Lecturer Table");
setSize(300, 200);
// addWindowListener(new BasicWindowMonitor());
//JButton Up = new JButton("Update");
//Up.addActionListener(this);
//getContentPane().add(Up, BorderLayout.SOUTH);
TableModel tm = new AbstractTableModel()
//JTable jt = new JTable(tm);
//JScrollPane jsp = new JScrollPane(jt);
//getContentPane().add(jsp, BorderLayout.CENTER);
Object[][] data = {
{"Sandip", "Vekaria", "ee99c9", "A"},
{"Manesh", "Mistry", "ee99b4", "A"},
{"Barry", "Kwok", "ee99b6", "A"},
{"Nikhil", "Nag", "ee99b3", "A"},
{"Kevin", "Jervis", "ee99b1", "A"}};
/* lecturer_data[][] = new String[data.length][4];
for(int row = 0; row < data.length; row++)
for(int col = 0; col <= 3; col++)
lecturer_data[row][col] = data[row][col];
String[] headers = {"First Name", "Second Name", "UserName", "Grades"};
public int getRowCount() { return data.length;  }
public int getColumnCount() {return headers.length; }
public String getColumnName(int c) {return headers[c]; }
public Object getValueAt(int r, int c) {return data[r][c]; }
public boolean isCellEditable(int r, int c)
if (c < 3)
return false;
else
return true;
/* Returns cell information of a record at location row,column
public synchronized Object getValueAt(int r, int c)
try
ProjectTable2 p = (ProjectTable2)data.elementAt(r;
switch (c)
case 0:
return (String)p.val1;
case 1:
return (String)p.val2;
case 2:
return new Integer(p.val3);
catch (Exception e)
return "";
public void setValueAt(Object value, int r, int c)
if (c >=3)
System.out.println("Setting value at " + r +", " + c + " to " + value);
else {data[r][c] = value;}
data[r][c] = value;
fireTableCellUpdated(r, c);
JTable jt = new JTable(tm);
JScrollPane jsp = new JScrollPane(jt);
getContentPane().add(jsp, BorderLayout.CENTER);
Up = new JButton("Update");
Up.addActionListener(this);
getContentPane().add(Up, BorderLayout.SOUTH);
public void actionPerformed(ActionEvent bc)
// fireTableCellUpdated(r, c);
if(bc.getSource()==Up)
Lecturer nameGrades = new Lecturer("Raul Mondragon", "ele_956", true);
// nameGrades.setTableDataUpdate(lecturer_data);
//no_of_rows = tm.
System.out.println("Update");
// nameGrades.printDetails3();
// nameGrades.printDetails4();
//JTable jt = new JTable(tm);
//JScrollPane jsp = new JScrollPane(jt);
// getContentPane().add(jsp, BorderLayout.CENTER);
public static void main(String args[])
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
ProjectTable2 pt = new ProjectTable2();
pt.setVisible(true);
Somebody please help!!

Similar Messages

  • Pass current row data from table and pass it to a method in AM

    Hi All,
    I have a table with row selection enabled. Also for each row I have a select image which on selection should pass the data from one of the columns of the current row selected to a method in AM.
    Can anybody let me know on "How on selection of the image in any row, can I pass the column data to the method in AM?".
    Thanks,
    Vijay

    Hi,
    the most easiest and straight forward approach is
    - Ckick the "Binding" tab at the bottom of the Visual Editor
    - In the Bindings section click teh green plus icon and choose Generic Bindings | Attribute Value
    - point the iterator selection to the iterator used by the table
    - choose the column's attribute name from the list of attributes
    - Create a method on the ApplicatioNModule IMPL class (should take single argument)
    - expose it as a client interfaces so it shows in the Data Controls panel
    - In the "Binding" tab, create a method binding for this exposed method
    - point the method binding argument to #{bindings.column-attribute-name.inptValue}
    So whenever you need to pass the value on to the AM, you just call the method binding
    OperationBinding oper = (OperationBinding) bindings.get("name of method");
    oper.execute();
    Frank

  • Capturing data from ALV grid

    Dear experts.
    Can anyone help me to capture data from ALV grid to pass to a BAPI FM.
    My ALV grid has the check box as first column and I want to capture only the rows in the grid with these checkboxes checked. I would prefer to do it without OO.
    Regards
    Sathar

    Loop at the table used for ALV data where <checkbox-field> = 'X'.
    Best,
    Jim

  • Unable to capture data from drop down list in custom added field in migo tcode at item level

    Hi guys,
    need bit help in resolving query related to custom added field in Tcode migo.
    i have added a field in migo at item level ,in this i have used drop down list
    to get data but unable to capture data from drop down list.gown through
    many blogs in scn but unable to resolve.
    Please help me out in this.
    Thanks,
    Umakant.

    Hi,
    U can use following code to fill the list box
    write this code in PBO
    In layout editor please select listbox in dropdown attribute of input field and put some fctcode attribute
    TYPE-POOLS vrm.
      DATA values TYPE vrm_values WITH HEADER LINE.
      TABLES: <ur custom Database table>.
      clear values, values[].
      SELECT * FROM <ur custom Database table>.
        values-text = <TABLE FIELD TO DISPLAY IN DROPDOWN> .
        values-key = <TABLE KEY FIELD TO DISPLAY IN DROPDOWN>.
        APPEND values.
      ENDSELECT.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id              = '<SCREEN INPUT FIELD NAME>'
          values          = values[]
        EXCEPTIONS
          id_illegal_name = 1
          OTHERS          = 2.
    Also please define the following before accessing the listbox value
    data: <listbox input field name> type <table field name>,
            <inputfield name where text to display> type string  in top include
    In PAI, select the text from the table into <inputfield name where text to display>  depending on value selected which will be called when enter key is pressed or any vale is selected

  • Capturing data from usb webcam

    I'm interested in the acquisition of footage from a usb webcam into labVIEW. I have the professional development system and downloaded NI-IMAQ which I believe i'll need from reading online material.
    I don't really know where to start to link the camera with labview so any material would be a great help...
    Final question, is it a big undertaking acquiring data from a video camera in labVIEW? it's just i've limited time to work on a project and want to know if it's worthwhile undertaking or if it will be very time heavy. I've a few months labVIEW development experience if that would give an indication to anyone...
    Strokes 

    Hi,
    First your USB Cam needs to be DirectShow Compliant.
    Then you will need NI-IMAQdx from the Vision Acquisition Software 2009 (supports LV 8.2 and higher) or higher to acquire images from USB cameras. The NI IMAQ driver is to capture images from framegrabbers, and the NI SmartCamera, not for USB. There is also a own IMAQ USB Library for the Vision Acquisition 8.6 but since you need to buy the Acquisition Software I would recommend to use 2009 or higher where we added the DirectShow Support to IMAQdx.
    The Vision Acquisition Software is just for image acquisition and processing. If you want to do image processing you will need the Vision Development Module.
    And when doing a search at ni.com you should find some articles, examples and tutorials too.
    I can't estimate how much time you will need get that running, but you could just try to run one of the examples for IMAQdx in LabVIEW and then see how it works.
    Christian

  • How to pull data from EJB and present them using Swing ?

    Hi all,
    I've written stateful session bean which connect to Oracle database, and now I must write stand alone client application using Swing.
    The client app must present the data and then let users add,delete and edit data and it must be flexible enough to iterate through the records.
    The swing components can be JTextField,JTable etc.
    How to pull the data from EJB and present them to users with the most efficient network trip ?
    Thanks in advance
    Setya

    Thanks,
    Since the whole app originally was client-server app and I want to make it more scalable, so I decide to separate business logic in the EJB but I also want to keep the performance and the userfriendliness of the original user interface, and I want to continue using Swing as the original user interface does.
    I've read about using Rowset and I need some opinions about this from you guys who already have some experience with it.
    Any suggestions would be greatly appreciated.
    Thanks
    Setya

  • Capturing data from a website

    Hello,
    I would like to capture data from websites, or get a snapshot
    of a given URL. I was wondering how this would be posible using
    Java.
    Any help or comments will be greatly appreciated.
    Chanie

    Thanks, that worked beautifully.
    I was wondering if you could help me with one more point.
    There are some webpages that before getting to them you must
    give a username and password. I was wondering how I could get
    data from such a webpage if I know the username and password
    using Java.
    Thanks in advance.

  • Capturing data from a RS232 device

    how do I capture data from an RS232 device to my APEX application. Precisely, I am using a barcode scanner and I need to know how to get the barcode data into an item (say P12_barcode) in my application. I have tried the keyboard wedge and the problem is that I have to set the input focus each time I need to collect the barcode of an item, so I have to switch to RS232 mode but how do I get this barcode data now?
    Please HELP...

    Thanks a trillion for this reply! wether your reply was helpful is an understatement in this matter!
    That is the type of Barcode scanner I am using man... they call it USB Keyboard emulation. It scans into note pad, word processors and text items freely.
    In my design for a solution to this problem, I have on paper, your type of solution but I lack the ability to set the focus on the desired Text Field when my cash_sales page loads.
    Secondly you said "I did have to set it to include a "Enter" after each scan" that touched upon another bug in me: I had always wanted the form to submit after each scan so that my procedure can use it against the items database and display the item in my Current Transaction Report. How did you set it to include a "Enter" after each scan? Is it on the scanner or at the page item level?
    Precisely I am using Metrologic MS9520 barcode scanner a.k.a Honeywell MS9520 barcode scanner!
    If I can set a cursor in my Px_Barcode text item after loading my CASH_SALES page and automatically submit the page after a scan(without clicking any button) then my nightmare is over...and you become my Virgo 2009 Hero.
    Happy September :)

  • Capturing Data from forms before it is stored in the table

    Hi...I would like to capture data from a form before the data is stored in the database. that is, i would like to access whatever data is entered into a field right after the user pushes the Insert button. I would like to do some processing on the data and then store it in the table along with the data from the other fields. Is it possible to access it through a bind variable or something? Please tell me how to go about it. Thanks

    Hi,
    You can make of the session variables to access the values. Every field in the form has a corresponding session variable with the name "A_<VARIABLE_NAME>". For example for deptno the session variable will be "A_DEPTNO"
    Here is a sample.
    declare
    flightno number;
    ticketno varchar2(30);
    tdate date;
    persons number;
    blk varchar2(10) := 'DEFAULT';
    begin
    flightno := p_session.get_value_as_varchar2(
    p_block_name => blk,
    p_attribute_name => 'A_FLIGHT_NO');
    ticketno := p_session.get_value_as_varchar2(
    p_block_name => blk,
    p_attribute_name => 'A_TICKET_NO');
    tdate := p_session.get_value_as_date(
    p_block_name => blk,
    p_attribute_name => 'A_TRAVEL_DATE');
    persons := p_session.get_value_as_number(
    p_block_name => blk,
    p_attribute_name => 'A_NOF_PERSONS');
    p_session.set_value(
    p_block_name => blk,
    p_attribute_name => 'A_FLIGHTNO',
    p_value => to_char(NULL)
    p_session.set_value(
    p_block_name => blk,
    p_attribute_name => 'A_TICKETNO',
    p_value => to_char(NULL)
    p_session.set_value(
    p_block_name => blk,
    p_attribute_name => 'A_TRAVEL_DATE',
    p_value => to_char(NULL)
    end;
    In the above example the values of the variables are got into temporary variables and session variabels are set to null.
    Thanks,
    Sharmil

  • Using streams to capture data from physical standby database.

    Does anybody know if it is possible to use streams to capture data from physical standby database instead of PROD database? The standby database is in read only mode. We use Oracle 11gR2.
    Thanks in advance.

    physical are closed : how will it managed the queues and overspill queues when target is not present? Also the data dictionary must reflect the primary but If you run capture, then you introduce rules that are not on primary: How ?

  • Read data from Excel and write into oracle database

    Hi
    I want  to know how can i read data from excel and write into oracle database using java.Kindly help me out to find a solution.
    Thanks and Regards
    Neeta

    Hai,
    I am suggesting the solution.
    I will try out and let u know soon.
    Make a coma separated file from your excel file.
    Assuming that your requirement allows to make a csv file.
    This file may be passed as an file object to be read by java.Using JDBC you must be able to populate the data base.You can also use String Tokenizer if needed.
    You do not want to  go via sql Loader?
    For reading the excel file itself do you want java?

  • Process and Code for writing an RFC to retrieve data from IT0006 and IT0655

    Hi,
    Can some body tell me the process and code for creating an RFC to retrieve data from IT0006 and IT0655.
    Its very urgent........
    Waiting for an early reply.....
    Many thanks

    Hello Krishna,
          The process for creating an entry in infotype is as follows.
    1.First you get the personal number lock for upating.You can use function 
        module ' BAPI_EMPLOYEE_ENQUEUE ' or ENQUEUE_EMPREL.
    2.Pass the records to function module ' HR_INFOTYPE_OPERATION' with
       OPERATION - 'INS'.
    3.Unlock the Employee by using function moule 'BAPI_EMPLOYEET_DEQUEUE'.
    Regards,
    Manoj.

  • On my mac, photoshop cc "save as" removes capture date from exif data. How do I prevent this?

    On my mac, photoshop cc "save as" removes capture date from exif data. How do I prevent this?

    You had to reinstall CS6 after cancelling the CC as both were from the same Adobe ID. You can always use & keep both CC & CS6 together.
    Please refer to the blog:
    Can I install both CS6 and CC apps on my computer? « Caveat Lector
    Other references are :
    Creative Cloud Help | Install, update, or uninstall apps
    What is the difference CS6 & CC Versions?
    Regards
    Rajshree

  • How to insert data from JTable to mysql Table....

    hello everybody
    i need help about how to insert data from JTable to mysql table... i know about how to create Table model...facing problem about how to insert data from JTable to mysql table....any helping link or code ... ill be thankfulll....for giving me solution...

    table1.getValueAt(table1.getSelectedRow(),0)you are getting the value of a selected row... or if you want you can just use a loop..
    for(.....){
    table1.getValueAt(x,y);
    }I think you know INSERT STATEMENT.. here on it just string concat
    sample e.g. (This not insert)
    "delete from accrule " +
                    "where ruleid= " + tblRA.getValueAt(tblRA.getSelectedRow(),0)+
                    " and accountname='"+tblRA.getValueAt(tblRA.getSelectedRow(),1)+"'"

  • Virtual KF(as Date) in Cube and pass the variable value to this VKF runtime

    Hi ,
    User would enter 1 date using date variable untime.
    My cube also has 1 Completed Date (KF).
    And i wann do comparisan based on input variable and exisitng variable.
    Can i add 1 Virtual KF(as Date) in Cube and pass the variable value to this VKF runtime and do the calculation in cube ???
    I know the same thing i can do in formula , but i have some different req.which i am unable to explain u here .
    So please let me know can i use VKF if yes how ???
    Points would be thrown for all .
    Bapu

    it's the exact posting from your last post. Please don't duplicate the postings, so that we can help you in one thread and not so many different threads

Maybe you are looking for