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

 
 


raja
JTable values are not gettiing properly
0 Answer(s)      2 years and 6 months 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();

} }

View Answers









Related Pages:
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
JTable  Values to be displayed in JTextfield when Clicked on JTable Cells
JTable
JTable  i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
JTable
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
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
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 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
Not get ans properly
!"); st.executeUpdate("insert into employee (empid,empname ) values (1
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
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
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
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 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
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
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
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
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.
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
problem scrolling jtable
;}}; table = new JTable(tableModel...); MAIN PROBLEM HERE'S M TABLE IS NOT PROPERLY SETTING IN SCROLLPANE...REPLY SOON
Not able to display jtable at runtime
Not able to display jtable at runtime  Hello, can anyone please help... database properly. But I am not getting why it is not creating the table...[][] taskcells; JTable ttable; public void BuildTable() { Statement st; ResultSet rs
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
CONVERT JTable DATA TO PDF FILE
(){ JFrame frame = new JFrame("Getting Cell Values in JTable"); JPanel panel = new...CONVERT JTable DATA TO PDF FILE  HOW TO CONVERT JTable DATA TO .PDF... the jtable data from the jframe and stored the data into the pdf file in the form
JTable Cell Validation? - Swing AWT
JTable Cell Validation?  hi there please i want a simple example of JTable with 3 columns Name,Number,Price and the first columns is string and second and third are integer and if you try to enter non numeric values
Multi-line cells in the JTable - Java Tutorials
Multi-line cells in the JTable 2002-04-11 The Java Specialists' Newsletter [Issue 045] - Multi-line cells in the JTable Author: Dr. Heinz M. Kabutz... in the JTable The last slide of all my courses says that my students may
Creating a JTable Component
[]): This is the constructor of JTable class that implements a JTable for displaying the values... Creating a JTable Component       Now you can easily create a JTable component. Here
Setting Grid Line in JTable
Setting Grid Line in JTable     ... JTable that contains predefined grid line with black color. But in this Java programming tutorial, you will learn how to set the colored grid line in JTable
Creating a Scrollable JTable
Creating a Scrollable JTable : Swing Tutorials ... section, you will learn how to create a scrollable JTable component. When any table has large volume of data, the use of scrollbar is applied in the JTable
Add XML to JTable
Add XML to JTable In this section, you will learn how to access the contents or data of xml document and display its information into the jtable. Java... from the document and stored in the NodeList. Now in order to get values from
Getting the Number of Rows and Columns in JTable
will learn how to get the number of rows and columns in JTable.  This program simply helps us for getting the number of rows and columns from the JTable by using... type values. getRowCount(): This method returns integer types value
Java convert jtable data to pdf file
Java convert jtable data to pdf file In this tutorial, you will learn how to convert jtable data to pdf file. Here is an example where we have created a jtable and add two rows and two columns to it through DefaultTableModel. Then we
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
Sharing a Table Model between JTable Components
Sharing a Table Model between JTable Components... how to share a table model between JTable components. Whenever, you want to do for sharing the resources between the JTable components, a table model
jtable problem
jtable problem  how to make a cell text hypertext
Enabling Row, Column and Cell Selections in a JTable
Enabling Row, Column and Cell Selections in a JTable... to describe how to enable the row, column and cell selections in a JTable... will see the enabling row, column and cell selections in a JTable. When you
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

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.