JTable
below describes a program of research that results in a table, my problem is that this same table to see it only accepts a single line even if I have more than one view as he only accepts a single line ... I am asking you to rewrite my program so you can scroll and data exists in more than one line ...
Thank you in advance for your answer.
package validation;
/**
*
* @author ACER
*/
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;
class Search{
public static void main(String[] args) {
JLabel lab=new JLabel("Enter Name:");
final JTextField t=new JTextField(20);
JButton b = new JButton("Search");
JPanel p = new JPanel(new GridLayout(2,2));
p.add(lab);
p.add(t);
p.add(b);
JFrame f = new JFrame();
f.getContentPane().add(p);
f.pack();
f.setVisible(true);
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String nome=t.getText();
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/lista", "root", "");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from listas where nome='"+nome+"'");
int id;
String apelido = "";
String pnome = " ";
String nomedomeio = "";
String telefone = "";
String email = "";
String endereco1 = " ";
String endereco2 = "";
String cidade = "";
String estado = " ";
String codigopostal = "";
String pais = "";
if(rs.next()){
id = rs.getInt("id");
apelido = rs.getString("apelido");
pnome = rs.getString("nome");
nomedomeio = rs.getString("nomedomeio");
telefone = rs.getString("telefone");
email = rs.getString("email");
endereco1 = rs.getString("endereco1");
endereco2 = rs.getString("endereco2");
cidade = rs.getString("cidade");
estado = rs.getString("estado");
codigopostal = rs.getString("codigopostal");
pais = rs.getString("pais");
}
String data[][]=new String[1][11];
data[0][0]=pnome;
data[0][1]=apelido;
data[0][2]=nomedomeio;
data[0][3]=telefone;
data[0][4]=email;
data[0][5]=endereco1;
data[0][6]=endereco2;
data[0][7]=cidade;
data[0][8]=estado;
data[0][9]=codigopostal;
data[0][10]=pais;
JFrame frame=new JFrame();
String labels[]={"Nome","Apelido","Nome do meio","Telefone","Email","Endereco1","Endereco2","Cidade","Estado","Codigo Postal","Pais"};
JTable table=new JTable(data,labels);
JScrollPane pane=new JScrollPane(table);
frame.add(pane);
frame.setVisible(true);
frame.pack();
}
catch(Exception ex){
System.out.println(e);
}
}
});
}
}
View Answers
Related Tutorials/Questions & Answers:
JTableJTable Values to be displayed in JTextfield when Clicked on
JTable Cells
JTableJTable i want to delete record from
JTable using a MenuItem DELETE. and values of
JTable are fetched from database....please reply soon
Advertisements
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
JTableJTable need to add values to a
JTable having 4 coloumns ,2 of them are comboboxes
JTableJTable Hello, i cannot display data from my table in the database to the cells of my
JTable. please help me
jtablejtable 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
jtablejtable 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
jtablejtable 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 multiple checkboxes the data doesnt get inserted into new database and if only one
JTableJTable Hi
I have problems in setting values to a cell in
Jtable which is in a jFrame which implements TableModelListener which has a abstract method
tableChanged(TableModelEvent e) .
I'll be loading values from data base when
JTable"};
JTable table=new
JTable(data,labels);
JScrollPane pane=new JScrollPane
JTABLE OF JAVAJTABLE 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-JavaJtable-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
Swings JTableSwings JTable add values to
JTable with four coloums,two of them are comboboxes
sum in JTablesum in JTable how to calculate sum from
JTable's one field like total
JTABLE IssueJTABLE 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 jtablejava jtable Hello Sir, I am developing a desktop application in which i have to display database records in
jtable .now I want to read only... that in
jtable.
plz help me with the code
jtable queryjtable 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 JtableABOUT 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
jtable insert row swingjtable insert row swing How to insert and refresh row in
JTable?
Inserting Rows in a
JTable example
REPORT WITH JTABLE(Exception e){}
JTable table = new
JTable(data, columnNames);
JScrollPane scrollPane
JTable - JDBCJTable
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 - Swing AWTJTable row selection event Hi, it will be great if someone can share an example of row selection event in
JTable JTable PaginationJTable Pagination Hello , I have the following Code. I am able to fetch the Data from the Database. But i need to implement pagination for the same. Can someone please help me out with this ? I have tried out many things from
JTable in java - Java BeginnersJTable in java Sir , I have created an application with a
JTable showing the records of an MS Access database table. On the same frame I have... given one ,
JTable table; ....... .... table.print(); Here the error
restrict jtable editingrestrict
jtable editing How to restrict
jtable from editing or
JTable disable editing?
public class MyTableModel extends...){
return false;
}
}
Disabling User Edits in a
JTable Component
JTable - Java BeginnersJTable search example I've problem about
JTable, i wan to search records when i types words in
JTable cell,can u give the source code.I'm Beginner and i start begins learning java programming.Please send the example into my
regarding JTable - JDBCregarding JTable how to populate a
JTable with mysql data after clicking JButton
please explain with the example
Jtable with servlet - Java BeginnersJtable with servlet
Actually I have embedded the html... time I want the
JTable to display the record saved in the database,the
JTable... of the page and the bottom half will consists of
JTable to display the record information
Jbutton in JTable cellsJbutton in
JTable cells I am a Java Beginner... I want a code in which
I display data in
Jtable from database and correspondingly a JButton for each cell and when i click on that button a new window should open
JTable populate with resultset.JTable populate with resultset. How to diplay data of resultset using
JTable?
JTable is component of java swing toolkit.
JTable class is helpful in displaying data in tabular format. You can also edit data.
JTable JTable with Date PickerJTable with Date Picker Hi,
I'd like to implement the following but I have no idea where to start:
I have a
JTable with 1 column containing... in the backing object(that populated the
JTable jtable query compare with datejtable query compare with date how to transfer daytable data... in which i have to display database records in
jtable .now I want to transfer particular data which month is over to another
jtable.
plz sir give me the code
jtable query compare with datejtable query compare with date how to transfer daytable data... in which i have to display database records in
jtable .now I want to transfer particular data which month is over to another
jtable.
plz sir give me the code
jtable query compare with datejtable query compare with date how to transfer daytable data... in which i have to display database records in
jtable .now I want to transfer particular data which month is over to another
jtable.
plz sir give me the code
jtable displays search results jtable displays search results hi sir can u send me full source code for displaying search results into
jtable from database n
jtable n search button must be within same frame but in different Panel and the size of the frame
JTable - Swing AWTJTable Hi Deepak,
i want to display the
Jtable data... how could i show
jtable data on the console.
Thanks,
Prashant
Hi...*;
public class JTableToConsole extends JFrame {
public Object GetData(
JTable add XMl to JTableadd XMl to JTable Hi..
i saw the program of adding add XMl to
JTable using DOM parser,but i need to do that in JAXB ,is it possible to do? help me
jtable with table headers - Swing AWTjtable with table headers give me java code to create
jtable with table headers
and by which i can scroll
jtable and can retrieve height and width of the table
JTable - Swing AWTJTable 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
Java: Adding Row in JTable Java: Adding Row in
JTable how about if we already have the
JTAble created earlier.
And i just found nothing to get its DefaultTableModel, thus, I can't call insertRow() method.
Is there any work around for this?
I found
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