Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT JTable values are not gettiing properly
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


raja
JTable values are not gettiing properly
0 Answer(s)      4 years and a month ago
Posted in : Swing AWT


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();

} }


Advertisement
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... of  setting the cell values in JTable. This program sets the data
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... to get the cell values in a JTable. This program creates a JTable that contains some
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
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 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
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
JTable
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
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
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  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 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  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
Not get ans properly
!"); st.executeUpdate("insert into employee (empid,empname ) values (1
Why are my variables not dividing properly?
Why are my variables not dividing properly?  Why are my variables not dividing properly
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
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
jtable problem
jtable problem  how to make a cell text hypertext
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
 

 

 

DMCA.com