JTable values are not gettiing properly

JTable values are not gettiing properly

Sir, I created one JTable with two columns and one row i have given two values,but i getting only one value .That is a[1][1] is String array. if i have given 8,9 then i got 8 only but not 9.i.e a[0][0]=8 a[0][1]= (nothing printed) Please go through my code

import java.util.*; import java.awt.*;

import javax.swing.*; import javax.swing.event.*; import java.awt.event.*; import java.awt.print.*; import java.sql.*; public class sd25 extends JFrame implements ActionListener { //3 month table details JTable table=null; JScrollPane js=null; Container cp=null; JPanel p=null; JLabel months3=null,date=null,ghba1c=null,per=null; JButton jb1=null; String a[][]=new String[2][2]; Connection con=null; Statement stmt=null; ResultSet rs=null; public sd25()throws Exception { cp=getContentPane(); cp.setLayout(null); cp.setBackground(Color.pink);

//3monts details months3=new JLabel("3 Months-Report"); date=new JLabel("Date"); ghba1c=new JLabel("GHbA1c"); per=new JLabel("%");

//3 monts details

final Object colheads[]={"Date","%"}; final Object rowdata[][]={{"",""},{"",""}}; table=new JTable(rowdata,colheads); p=new JPanel(null); months3.setBounds(40,10,300,40); date.setBounds(190,20,300,40); ghba1c.setBounds(400,20,300,40); per.setBounds(470,20,300,40); table.setBounds(100,50,460,15); jb1=new JButton("submit"); jb1.setBounds(790,400,100,40); int h=ScrollPaneConstants.HORIZONTALSCROLLBARAS_NEEDED; int v=ScrollPaneConstants.VERTICALSCROLLBARAS_NEEDED;

jb1.addActionListener(this); cp.add(per); cp.add(ghba1c); cp.add(date); cp.add(months3); cp.add(table); cp.add(jb1);

addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we)
{ dispose(); //System.exit(0); } }); } public void actionPerformed(ActionEvent ae) { System.out.println("hi"); if(ae.getSource()==jb1) { try { for(int i=0;i<1;i++) { for(int j=0;j<=1;j++) {

a[i][j]=(String)table.getModel().getValueAt(i,j); } }

for(int i=0;i<1;i++) { for(int j=0;j<=1;j++) { System.out.println("\n"+i+""+j+""+a[i][j]); } }

cp.setBackground(Color.red);

    }catch(Exception e)

{ e.printStackTrace(); }
} } public static void main(String args[])throws Exception { sd25 o=new sd25(); o.setSize(900,900); o.show();

} }

View Answers









Related Tutorials/Questions & Answers:
JTable values are not gettiing properly
JTable values are not gettiing properly  Sir, I created one JTable with two columns and one row i have given two values,but i getting only one... details JTable table=null; JScrollPane js=null; Container cp=null; JPanel p=null
JTable duplicate values in row
JTable duplicate values in row  JTable duplicate values in row
Advertisements
sum of all values in a column of jtable
, is there a code to display the sum of all values in a column of a jtable namely CARTtbl... or deleted.   Here is an example of jtable that sums up the values of two...("Setting Cell Values in JTable"); JPanel panel = new JPanel(); Integer data
Setting Cell Values in JTable
Setting Cell Values in JTable     ... values in JTable component. For this you must have the some previous knowledge... will see the process of  setting the cell values in JTable. This program sets
Getting Cell Values in a JTable
Getting Cell Values in a JTable     ... values in a JTable component. It is a same as setting the cell values in a JTable... This program helps you to get the cell values in a JTable. This program creates a JTable
JTable
JTable  Values to be displayed in JTextfield when Clicked on JTable Cells
How to read and retrieve jtable row values into jtextfield on clicking at particular row ...
How to read and retrieve jtable row values into jtextfield on clicking... application in which i have to display database records in jtable .now I want to read all the values of particular row at which mouse is clicked. and display
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  Hello Sir, I am working on a project in which i have to fetch the values from database to jtable .Now as per my requirement i need to update and delete
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  Hello Sir, I am working on a project in which i have to fetch the values from database to jtable .Now as per my requirement i need to update and delete the database
JTable
JTable  i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... is shown in the jtable.. of my jframe window.Now as per my requirement i have to add ,update,delete database values from jtable only so i added three buttons add
How to update,Delete database values from jtable cells ..
How to update,Delete database values from jtable cells ..  hello Sir... from database into jtable of a jpanel.. Now Sir, According to my need i have to update the cell values from there only means that whatever values i ma entering
JTable
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... in the jtable.. of my jframe window.Now as per my requirement i have to add ,update,delete database values from jtable only so i added three buttons add,update
How to insert and update all column values of database from jtable.
How to insert and update all column values of database from jtable.  ... in the jtable.. of my jframe window.Now as per my requirement i have to add ,update,delete database values from jtable only so i added three buttons add,update
jtable
jtable  hey i have build a form and i m also able to add data from database to jtable along with checkbox.the only problem is that if i select... checkbox is selected it works properly. plzz help..itz urgent
jtable
jtable  hi Sir i am working netbeans IDE,I have a jtable when i insert values in jtable then i am unable to print all inserted values,For eg if i insert 1,2,3,4,5,6,7,8 values then , i am getting output
jtable
jtable  how to get the values from database into jtable and also add a checkbox into it and then when selected the checkbox it should again insert into database the selected chewckbox.plzz help
JTable
JTable  Hi I have problems in setting values to a cell in Jtable... method tableChanged(TableModelEvent e) . I'll be loading values from data base when i enter id in a column. and i want to load other table columns the values
JTable
JTable   how to select a definite cell which containing a similar text containg to the one which the user entering from a jtable at runtime in java
JTable
JTable  Hello, i cannot display data from my table in the database to the cells of my JTable. please help me
JTable
"}; JTable table=new JTable(data,labels); JScrollPane pane=new JScrollPane
Swings JTable
Swings JTable  add values to JTable with four coloums,two of them are comboboxes
JTABLE Issue
JTABLE Issue  Hi Eveyone, I am developing a small application on Swing-AWT. I have used JTABLE to show data. There is "input field" and "search... on basis of input data provided in input field. For JTABLE is on some other
java jtable
in which i have to display database records in jtable .now I want to read only the values of particular row at which the jtextfield has been set. and display that in jtable. plz help me with the code
Why are my variables not dividing properly?
Why are my variables not dividing properly?  Why are my variables not dividing properly
Not get ans properly
!"); st.executeUpdate("insert into employee (empid,empname ) values (1
jtable problem
jtable problem  how to make a cell text hypertext
JTable - Swing AWT
JTable  Hi Deepak, i m facing a problem with jtable. i am able to display the values from the database into the jtable. but not able to modifying multiple cell values in a row. also i want to store those modified
JTABLE OF JAVA
JTABLE OF JAVA  i have a jtable in java,i have used checkbox in jtable. now i want to add(submit) only those records that i have checked by checkbox how? i want small example with coding
Jtable-Java
Jtable-Java  Hi all,I have a Jtable And i need to clear the data in the table .I only Need to remove the data in the table.not the rows.Please help me
Jtable with servlet - Java Beginners
Jtable with servlet   Actually I have embedded the html... and will submit the values which will be saved in the database(MySql).At the same time I want the JTable to display the record saved in the database,the JTable
sum in JTable
sum in JTable  how to calculate sum from JTable's one field like total
jtable query
jtable query  I need a syntax...where i could fetch the whole data from the database once i click the cell in jtable...and that must be displayed in the nearby text field which i have set in the same frame
regarding jtable...
regarding jtable...  sir, im working with jtables. i wanted to populate a jtable from the database and when i click any row it should add a container... a container on the jtable. kindly help me sir. thanks in advance regards, rajahari
ABOUT Jtable
ABOUT Jtable  My Project is Exsice Management in java swing Desktop Application. I M Use Netbeans & Mysql . How can retrive Data in Jtable from Mysql Database in Net Beans
How to insert rows in jTable?
How to insert rows in jTable?  Hi, I need to take input from user using JTable. I want an empty row to appear after clicking a insert button. The values will be entered in this empty row. I have searched on this but could
output not coming properly - JSP-Servlet
output not coming properly  I am not getting the output properly when i had written my code like below: Add Employee Details for( j=0;j<11;j++) { out.println("Department code
How to add JTable in JPanel
How to add JTable in JPanel  How to add JTable in JPanel
jtable insert row swing
jtable insert row swing  How to insert and refresh row in JTable?   Inserting Rows in a JTable example
ModuleNotFoundError: No module named 'properly-model-python'
ModuleNotFoundError: No module named 'properly-model-python'  Hi...: No module named 'properly-model-python' How to remove the ModuleNotFoundError: No module named 'properly-model-python' error? Thanks   Hi
ModuleNotFoundError: No module named 'properly-util-python'
ModuleNotFoundError: No module named 'properly-util-python'  Hi...: No module named 'properly-util-python' How to remove the ModuleNotFoundError: No module named 'properly-util-python' error? Thanks   Hi
jtable in java swing
jtable in java swing  hai friends... i am creating 1 GUI having 1 table, that table contain 3 fields(columns) and 10 rows.. user can enter values... entering the values in d 2nd column the user hit on the enter button.then the focus
REPORT WITH JTABLE
(Exception e){} JTable table = new JTable(data, columnNames); JScrollPane scrollPane
JTable - JDBC
JTable   Hello..... I have Jtable with four rows and columns and i have also entered some records in MsSql database. i want to increase Jtable's... { JFrame f; JPanel p; JLabel l; JTextField tf; JButton btn; JTable tb
jtable
JTable - Swing AWT
JTable row selection event   Hi, it will be great if someone can share an example of row selection event in JTable
JTable hold different components
JTable hold different components  create Jtable with two coloums,one coloumn is combobox and other normal
Connecting JTable to database - JDBC
(){ JFrame frame = new JFrame("Getting Cell Values in JTable"); JPanel...Connecting JTable to database  Hi.. I am doing a project on Project... to store this JTable content in my database table.. This is a very important
java swing (jtable)
java swing (jtable)  hii..how to get values of a particular record in jtable from ms access database using java swing in netbeans..?? please help... from database and display it in jtable. import java.awt.*; import java.sql.

Ads