How to enter the values in JTable in runtime

how to enter the values in JTable in runtime

Basically you need a vector of vectors or an array of arrays. Example (off the top of my head):
With Arrays
String[] cols = { "colone", "coltwo", "colthree", "colfour", "colfive" };
String[] numbers = { "one", "two", "three", "four", "five" };
String[] letters = { "A", "B", "C", "D", "E" };
String[][] data = { numbers, letters };
//make sure that the table has a scroll pane wrapped around it otherwise the header is not displayed
JScrollPane scroll = new JScrollPane(new JTable(data, cols));
With Vectors
Vector cols = new Vector();
cols.addElement("colone");
cols.addElement("coltwo");
cols.addElement("colthree");
cols.addElement("colfour");
cols.addElement("colfive");
Vector numbers = new Vector();
numbers.addElement("one");
numbers.addElement("two");
numbers.addElement("three");
numbers.addElement("four");
numbers.addElement("five");
Vector letters = new Vector();
numbers.addElement("A");
numbers.addElement("B");
numbers.addElement("C");
numbers.addElement("E");
numbers.addElement("F");
Vector data = new Vector();
data.addElement(numbers);
data.addElement(letters);
//make sure that the table has a scroll pane wrapped around it otherwise the header is not displayed
JScrollPane scroll = new JScrollPane(new JTable(data, cols));The array or vector can be easily populated at runtime.
Regards
Riz

Similar Messages

  • How to delete the values from TKOMV at runtime after creating PO

    Hi,
      How to delete the values from TKOMV at runtime after creating PO from IDOC. I am creating PO through IDOC, subsequently need to create Sales order and again need to create 2nd PO with reference of Purchase Requestion(created with sales order). At the time creation of 2nd PO the Header conditions are appearing twice and net price value is appearing wrong.
    Thanks in advance.

    Hi Padma
    Can you do this activity once the company code is in to production. I guess you can not do this activity, if the company code is already in to live. Setting or resetting of the recon accounts will hinder the previous actitivity. Infact resetting of the company code is also not a good option.
    Any how, thanks for the inputs. Please let me know whether i can do this activity only at the subledger level which will not impact other modules. The one solution i can figured out is , reverse all the transactions for the corresponding asset in the year of takeover and pass the entries again in the same year correctly which will have effect in Subledger and also in general ledger. But the business people will not allow this, since for a big client it will require lot of authorizations and approvals. Infact the vendor also, is cleared. So we have to reverse the cleared documents as well which is again a task and require approvals as well.
    Thanks and regards
    Seshu.

  • How i insert the values in JTable

    Hi,
    Iam new to the swings i have a problem placing the values in JTable while retriving the values from DataBase .Anybody please suggest me..
    i can retriving the values but how i place the vlaues..
    This is My code
    package com.teamone.healthcare;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import javax.swing.JButton;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.WindowConstants;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableModel;
    import com.mysql.jdbc.Connection;
    import com.mysql.jdbc.ResultSet;
    * This code was edited or generated using CloudGarden's Jigloo
    * SWT/Swing GUI Builder, which is free for non-commercial
    * use. If Jigloo is being used commercially (ie, by a corporation,
    * company or business for any purpose whatever) then you
    * should purchase a license for each developer using Jigloo.
    * Please visit www.cloudgarden.com for details.
    * Use of Jigloo implies acceptance of these licensing terms.
    * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
    * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
    * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
    public class ClientList extends javax.swing.JFrame {
         private static final long serialVersionUID = 1L;
         private JScrollPane list;
         private JButton view;
         private JButton close;
         private JTable jTable1;
         Connection con = null;
        Statement st = null;
        ResultSet rs = null;
         * Auto-generated main method to display this JFrame
         /*public static void main(String[] args) {
              ClientList inst = new ClientList();
              inst.setVisible(true);
         public ClientList() {
              super();
              initGUI();
              this.setVisible(true);
         private void initGUI() {
              try {
                        list.setBounds(161, 133, 371, 98);
                        list.getHorizontalScrollBar().setPreferredSize(new java.awt.Dimension(10, 59));
                   setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                   getContentPane().setLayout(null);
              try {
                    Class.forName("com.mysql.jdbc.Driver").newInstance();
                    con = (Connection) DriverManager.getConnection("jdbc:mysql:///healthcare","yenmad","yenmad");
                    st = con.createStatement();
                    rs = (ResultSet) st.executeQuery("SELECT User_id, Username, Citizen_ID, First_Name, Phone FROM register_users");
                    while(rs.next()) {
                      int Userid = rs.getInt(1);
                      String Username = rs.getString(2);
                      String ClientId = rs.getString(3);
                      String ClientName = rs.getString(4);
                      //String Last_Name = rs.getString(5);
                      String ContactNumber = rs.getString(5);
                      System.out.println(Userid + ", " + Username + ", " +ClientId  + "," + ClientName +","+ContactNumber);
                  } catch (Exception e) {
                       System.out.println("Exception: " + e.getMessage());
                        list = new JScrollPane();
                        getContentPane().add(list);
                        list.setBounds(0, 0, 644, 217);
                             TableModel jTable1Model = new DefaultTableModel(
                                  new String[][] { { "", "", "","", "" } },
                                  new String[]{ "UserId", "UserName", "ClientId", "ClientName", "ContactNumber"});
                             jTable1 = new JTable();
                             list.setViewportView(jTable1);
                             jTable1.setModel(jTable1Model);
                        close = new JButton();
                        getContentPane().add(close);
                        close.setText("Close");
                        close.setBounds(518, 231, 63, 28);
                        view = new JButton();
                        getContentPane().add(view);
                        view.setText("View");
                        view.setBounds(441, 231, 63, 28);
                        view.addActionListener(new ActionListener() {
                             public void actionPerformed(ActionEvent evt) {
                                  viewActionPerformed(evt);
                   pack();
                   this.setSize(652, 300);
              } catch (Exception e) {
                   e.printStackTrace();
         private void viewActionPerformed(ActionEvent evt) {
              System.out.println("view.actionPerformed, event=" + evt);
              new ViewClient();
    }

    can i display this table values in vertical .. if yes how can i do that.. please suggest me..
    this is the code iam using but it is displa in horizontally...
    package com.teamone.healthcare;
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.DriverManager;
    import java.util.Vector;
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.WindowConstants;
    import com.mysql.jdbc.Connection;
    import com.mysql.jdbc.ResultSet;
    import com.mysql.jdbc.ResultSetMetaData;
    import com.mysql.jdbc.Statement;
    public class ClientList extends javax.swing.JFrame {
         private static final long serialVersionUID = 1L;
         /*public static void main(String[] args) {
              ClientList inst = new ClientList();
              inst.setVisible(true);
         public ClientList() {
              super();
              initGUI();
              this.setVisible(true);
         private void initGUI() {
              try {
                   setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
                   pack();
                   setSize(600, 500);
                   Vector columnNames = new Vector();
                Vector data = new Vector();
                try
                          this.setSize(500, 400);
                      //  Connect to the Database
                      Class.forName("com.mysql.jdbc.Driver");
                      Connection connection = (Connection) DriverManager.getConnection("jdbc:mysql:///healthcare","yenmad","yenmad" );
                      //  Read data from a table
                      String sql = "Select User_id, Username, Citizen_ID, First_Name, Last_Name, Phone from register_users";
                      Statement stmt = (Statement) connection.createStatement();
                      ResultSet rs = (ResultSet) stmt.executeQuery( sql );
                      ResultSetMetaData md = (ResultSetMetaData) rs.getMetaData();
                      int columns = md.getColumnCount();
                      //  Get column names
                      for (int i = 1; i <= columns; i++)
                       columnNames.addElement( md.getColumnName(i) );
                      //  Get row data
                      while (rs.next())
                            Vector row = new Vector(columns);
                            for (int i = 1; i <= columns; i++)
                                  row.addElement( rs.getObject(i) );
                            data.addElement( row );
                      rs.close();
                      stmt.close();
                catch(Exception e)
                      System.out.println( e );
                //  Create table with database data
                JTable table = new JTable(data, columnNames);
                JScrollPane scrollPane = new JScrollPane( table );
                getContentPane().add( scrollPane );
                JPanel buttonPanel = new JPanel();
                getContentPane().add( buttonPanel, BorderLayout.SOUTH );
                buttonPanel.setPreferredSize(new java.awt.Dimension(200, 66));
                        JButton View = new JButton();
                        buttonPanel.add(View);
                        View.setText("View");
                        View.setLayout(null);
                        View.addActionListener(new ActionListener() {
                             public void actionPerformed(ActionEvent evt) {
                                  ViewActionPerformed(evt);
                        JButton Close = new JButton();
                        buttonPanel.add(Close);
                        Close.setText("Close");
                        Close.addActionListener(new ActionListener() {
                             public void actionPerformed(ActionEvent evt) {
                                  CloseActionPerformed(evt);
                        } catch (Exception e) {
                   e.printStackTrace();
         private void CloseActionPerformed(ActionEvent evt) {
              System.out.println("Close.actionPerformed, event=" + evt);
              this.setVisible(false);
         private void ViewActionPerformed(ActionEvent evt) {
              System.out.println("View.actionPerformed, event=" + evt);
              new ViewClient();
    }

  • How to fill the data in JTable at runtime

    Hi all,
    I am having a JButton and also a JTable.
    Now my problem is that intitially am setting the value of each column in the table to zero.
    But when I click the JButton i have to fill the JTable with all the new values.
    Please hepl me out solving this problem.
    I am really struck.
    Regards
    RAKESH SAGAR

    If other suggested links give you nothing - take a look at:
    http://forum.java.sun.com/thread.jspa?threadID=699117
    It seems Tjirpovf have code somewhat similar what you are asking for ("reply 5" - fill table with data from GUI). And you might even find my answer to his question useful ("reply 7" - fill table with data from file and save table data to file).

  • How to change the value of Label in runtime

    Hi All,
    I want to change the value of the Label in runtime. Is it possible to change? If so then can you please let me know how to do it?
    Regards,
    Raghu

    Hi Ram,
    Check the below thread
    Dialog program - label problem
    The above thread has been updated just couple of hours ago only
    if it is Standard Screen then try using SHD0 Tcode , but this donot dynamically change the Field labels
    for more info go through Transaction Variants might be helpful,
    This demands Field Exits to be implemented
    Cheerz
    Ram

  • How to get the value entered in input enabled field of a list output?

    Hi all,
    I am developing a program to display  list with two input enabled fields . After users enetered the values into these fields I need to do some calculations based on these values and modify the value of another field in the list.
    But i couldn't have an idea how to read the values after users enter into these fields.
    Please help me on solving this problem?  If possible please provide the sample code.
    Thanks,
    Aravind.

    You can enable disable screen fields in at selection screen output event.
    And by using loop at screen.
    And for changing the values you can do in initialization event.
    I Hope you are doing these in Reports.

  • How enter the values in to table when create entries option is not working

    hi everyone,
         can u please tell me How enter the values in to table when create entries option is not working.
    it's urgent.
    thanking u all

    Hi Shree,
    how many entries u want to insert ,,
    is it a ztable or custom table ..
    just tell me ur clear requirement ..
    clarify the same ..
    if no options avaliable then if its less entries or some value u can do it through debugging ..
    if its bulk entries then u can write a program ..
    just let me know ..
    regards,
    VIjay

  • How to enter the currency value Flex mobile

    Hi, friends, I type from Brazil
    how to enter the currency value in textinput
    format BR ( Brazil )?:
    Thank's

    Hello Ashok,
             Using the same BAPI , set the field R_3_USER of the tables parameter TELEFONDATA to 3 to save the mobile number.
    Hope it helps.
    Thanks,
    Sriram S

  • How to get the values from popup window to mainwindow

    HI all,
       I want to get the details from popup window.
          i have three input fields and one search button in my main window. when i click search button it should display popup window.whenever i click on selected row of the popup window table ,values should be visible in my main window input fields.(normal tables)
       now i am able to display popup window with values.How to get the values from popup window now.
       I can anybody explain me clearly.
    Thanks&Regards
    kranthi

    Hi Kranthi,
    Every webdynpro component has a global controller called the component controller which is visible to all other controllers within the component.So whenever you want to share some data in between 2 different views you can just make it a point to use the component controller's context for the same. For your requirement (within your popups view context) you will have have to copy the component controllers context to your view. You then will have to (programmatically) fill this context with your desired data in this popup view. You can then be able to read this context from whichever view you want. I hope that this would have made it clear for you. Am also giving you an [example|http://****************/Tutorials/WebDynproABAP/Modalbox/page1.htm] which you can go through which would give you a perfect understanding of all this. In this example the user has an input field in the main view. The user enters a customer number & presses on a pushbutton. The corresponding sales orders are then displayed in a popup window for the user. The user can then select any sales order & press on a button in the popup. These values would then get copied to the table in the main view.
    Regards,
    Uday

  • How to get the values of Select-options from the screen.

    The value of parameter can be obtained by function module 'DYNP_VALUES_READ' but How to get the values of Select-options from the screen? I want the F4 help values of select-options B depending on the values in Select-option A.So I want to read the Select-option A's value.

    Hi,
    Refer this following code..this will solve your problem...
    "Following code reads value entered in s_po select options and willprovide search
    "help for s_item depending upon s_po value.
    REPORT TEST.
    TABLES : ekpo.
    DATA: BEGIN OF itab OCCURS 0,
    ebelp LIKE ekpo-ebelp,
    END OF itab.
    SELECT-OPTIONS   s_po FOR ekpo-ebeln.
    SELECT-OPTIONS s_item FOR ekpo-ebelp.
    INITIALIZATION.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_item-low.
      DATA:
      dyn_field TYPE dynpread,
      temp_fields TYPE TABLE OF dynpread,
      zlv_dynpro TYPE syst-repid.
      zlv_dynpro = syst-repid.
      CALL FUNCTION 'DYNP_VALUES_READ'
        EXPORTING
          dyname     = zlv_dynpro
          dynumb     = syst-dynnr
          request    = 'A'
        TABLES
          dynpfields = temp_fields
        EXCEPTIONS
          OTHERS     = 0.
      LOOP AT temp_fields INTO dyn_field.
        IF dyn_field-fieldname EQ 'S_PO-LOW'.
            SELECT * INTO CORRESPONDING fields OF TABLE itab FROM ekpo
            WHERE ebeln EQ dyn_field-fieldvalue.
            EXIT.
        ENDIF.
      ENDLOOP.

  • How to hold the value in List box.

    Hi All,
    On my screen painter Screen I am displaying the Sold to party and ship to party with thier address.
    I am also displaying the Shipping condition based on ship to party. To display the shipping condition i am using list box. Once the user enter the sold to party automatically all the field is going to populate in their respective fields. I am facing the problem that, The list box getting populated with shipping condition but once you choose the shipping condition and hit the enter the list box getting refreshed. I am using this code in PAI event. And I can Only use this in PAI.
    The Function i am using for list box is CALL FUNCTION 'VRM_SET_VALUES'.
    Pls suggest me how to hold the value in List box.
    Thanks,
    Rakesh

    Hi,
    Now i am using in PBO.
    the code below in in PBO.It is still not holding the value.
          if list[] is initial.
          perform SHP_COND.
          endif.
    form SHP_COND .
    *DATA: SHOP(80).
        clear : GT_VSBED, list.
        refresh : GT_VSBED, list.
         select vsbed
           from knvv AS K
           into table GT_VSBED
          where Kvkorg = vbak-vkorg  "Kkunnr = GV_STPH
          and K~vtweg = vbak-vtweg
          and K~spart = vbak-spart.
        select VSBED vtext
          from TVSBT
        into table list
        for all entries in GT_VSBED
        where spras = sy-langu
        and vsbed = GT_VSBED-VSBED.
    *break-point.
    NAME = 'SHP_CON'.
    CALL FUNCTION 'VRM_SET_VALUES'
      EXPORTING
        id                    = NAME
        values                = LIST[]
    EXCEPTIONS
       ID_ILLEGAL_NAME       = 1
       OTHERS                = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    endform.                    " SHP_COND
    Thanks,
    Rakesh

  • How to Get the value in a new created view.

    Hi Experts,
    I have create a view along with the fields: Street No. , Street name, apt no,
    how should i capture these values . in a current situation i entering the value but when i check in the debugging mode : in a collection_wrapper (context node class) i am not able the see the value which i have entered. please help me out. it is  very urgent.
    Rohit

    Hi Ashish,
    Thanks for replying. i have already create the context node and in the using the request from field method ,i am getting the value in my work area but how to store the value in the custom fields of that particular order  as well as store the value in the crmd_customer_i table...
    Regards,
    Rohit

  • How to enter a value into datagrid cell in wpf through manually?

    Hi,
        Here my datagrid rows are in readonly mode here how can i enter the values in to the datagrid cell.(means how can i edit the cell value).i am adding the value to datagrid through programetically, I think  for this reason my datagrid rows
    are visible in readonly mode. Then how can i edit. Please guide me.
    Regards,
    Bhadram

    Hi Barry,
       Thank you for your reply, Now i sending my sample please check it once and suggest me.
    MainWindow.xaml.cs
    private void Save_Click(object sender, RoutedEventArgs e)
     List<CustomerMainViewModel> customer = new List<CustomerMainViewModel>(); customerviewmodel.NameTextField = tbName.Text;
    customerviewmodel.AddressTextField = tbAddress.Text;
    customerviewmodel.CountryField = countryddl.Text;
    customerviewmodel.StateField = stateddl.Text;
    customerviewmodel.Product = customerviewmodel.Product1 + "," + customerviewmodel.Product2;
    foreach(string str in customerviewmodel.actionCollection)
    customerviewmodel.ActionColl.Add(str);
    customerviewmodel.actionCollection.Clear();
    customer.Add(customerviewmodel);
    dataGrid1.Items.Add(customer);
    MessageBox.Show("Data Successfully Saved", " MessageBox", MessageBoxButton.OK, MessageBoxImage.Asterisk);
    clearValues();
    MainWindow.xaml
    <DataGrid
    Height="144"
    HorizontalAlignment="Left"
    Margin="79,447,0,0"
    Name="dataGrid1"
    VerticalAlignment="Top" CanUserAddRows="True"
    Width="399" Grid.RowSpan="2" IsReadOnly="False">
    <DataGrid.Columns>
    <DataGridTextColumn Header="NAME" Binding="{Binding NameTextField,Mode=TwoWay}" Width="Auto" IsReadOnly="False" />
    <DataGridTextColumn Header="ADDRESS" Binding="{Binding AddressTextField,Mode=TwoWay}" Width="Auto" IsReadOnly="False"/>
    <DataGridTextColumn Header="GENDER" Binding="{Binding GenderField,Mode=TwoWay}" Width="Auto" IsReadOnly="False"/>
    <DataGridTextColumn Header="COUNTRY" Binding="{Binding CountryField,Mode=TwoWay}" Width="Auto" IsReadOnly="False"/>
    <DataGridTextColumn Header="STATE" Binding="{Binding StateField,Mode=TwoWay}" Width="Auto" IsReadOnly="False"/>
    <DataGridTextColumn Header="PRODUCT" Binding="{Binding Product,Mode=TwoWay}" Width="Auto" IsReadOnly="False"/>
    <DataGridTemplateColumn Header="ACTION" MinWidth="140" IsReadOnly="False">
    <DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
    <ComboBox x:Name="actionddl" ItemsSource="{Binding ActionColl}"/>
    </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    </DataGrid.Columns>
    </DataGrid>
    In the above "xaml" file i am using the attribute "Readonly="False"" but its not effected on my code still my datagrid is in readonly mode, i don't know why it happens. 
    And I am adding data to my datagrid through "Wpf controls (TextBox,CheckBox,ComboBox and etc...)"  while click on "save" button the data added to grid. adding to grid works properly but the entire row is in readonly mode. How can
    i solve my problem.  

  • How to determine the value of a Standard Value in a routing operation

    Dear Experts,
    Kindly guide me on how to detemine the value of my Standard Value in the  operation of my routing, or in the phase of my Master Recipe.
    I mean what determines the value that I enter for the Standard Values: Machine  and Labor in the phase of my Master Recipe?

    Hi,
    In the Routing / Master Recipe, the standard values are based on the lot size.
    For Example, if you have the lot of 100 KG, then in recipe the machine time will be 2 hr and labor time will be 2 hours, it means to make 100 KG we require 2 hrs of machine and 2 hrs of labor.
    Normaaly all production manager / supervisor will have the date for the hours. The system will calculate will respect to batch / lot size.
    If you have order for 1000 KG, then the system will assign 20 hrs for Machine and 20 hrs for labor.
    This will be used for Capacity planning and Costing.
    Capacity plan here your requirement is 20 hrs for machine and labor. If you have a reacto which wil run for 24 hrs a day, then the order will be completed in a day.
    Costing is concerned, all std. valur key will be assigned with an activity type in work center / Resources and the prices for activity type / cost center will be maintained in KP26.
    Based on the cost and hours, the system will allocate cost for the order (it will be planned cost). When you are confirming the order you will enter the actual time for the operation, then that will be your actual cost.
    Pl do a sample test scenario in your sand box, and surely you will understand more.
    The data for Routing / Recipe will be provided by the production manager of the plant and activity price will be provided by the finance team.
    Thanks,
    JK

  • How to read the value of Non-Linear Transforme​r ?

    Hi there !
    I know that we could make "modified" transformer for special purpose (with Vsec=5V for example). But, instead of make a new transformer, it might be more easier if we could know how to read the value of those transformer. For example, NLT_PQ_4_120 or NLT_PQ_4_10. To be narrowed, what is the meaning of 4_120 and 4_10 ?
    Anyone ?
    Ghost Recon Team Leader

    To understand the models you mentioned you need to understand XSPICE.  I suggest you use the virtual transformer instead because it is easy to change the turn ratio, you can double clicking on the component and enter what ever ratio you want.  This component is found  by selecting the menu PlaceàComponent
    Group: Basic
    Family: Basic Virtual
    Component: TS Virtual
    Tien
    Tien P.
    National Instruments

Maybe you are looking for

  • How do you use Bonjour to download SoundAmp app recordings?

    I have the SoundAmp app installed on my iPhone 4s and use it to make recordings.  But some are too big to email, so you're supposed to be able to download them via Safari and Bonjour.  But enabling Bonjour on Safari is not helping to find the recordi

  • Can i get month, quarterly, half yearly, yearly wise sales report basing on

    hi, sap gurus, good evening to all, how can i get month, quarterly, half yearly, yearly wise sales report basing on division and material. is there any std transaction code for that. customization is requried for that. regards, balaji.t 09990019711

  • Size of Acrobat 9.0 program folder... RTP files?

    I have Acrobat Standard 9.5.2 installed on my Windows XP machine, which is a laptop with a 40GB hard drive. I am getting a bit low on drive space, so I would like to delete any unneccessary files or move them to an external drive. My C:\Program Files

  • Drives Going to Sleep

    I've been to the Energy Saver. I have turned off "Put the hard disk (s) to sleep when possible." I have it set to sleep in 3 hours. Yet continuously, the external Firewire drives go to sleep--sometimes even during the long Auto Save (rant previously

  • Different GC time on identical servers

    I have 3 identical servers in a clustered environment with the same hardware and applications, even the java arguments are the same. However, I am seeing a different GC timing across the 3 servers. One of the servers is doing major GC at about every