sir

sir

hi sir,Happy ugadi,how to place the database records into jtable ,i am using the oracle database plz provide the program how to retrieve the database records and placed into a jtable,i want one more column is added to my jtable,that column contains check boxes plz provide program how to add checkboxes column to my jtable.
plzzzzzzzzzzzzzzz
ThanQ
View Answers

March 16, 2010 at 12:59 PM

Hi Friend,

Try the following code:

import java.sql.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;

public class JTableDatabase{
JCheckBox check;
public static void main(String[] args) {
new JTableDatabase();
}
public JTableDatabase(){
JFrame frame = new JFrame();
JPanel panel = new JPanel();
String data[][] = {{"Name","Address"}};
String col[] = {"Name","Address"};
final DefaultTableModel model = new DefaultTableModel(data,col);
final JTable table = new JTable(model);
JScrollPane pane=new JScrollPane(table);
model.addColumn("ABC");
TableColumn includeColumn = table.getColumnModel().getColumn(2);
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
Statement st=conn.createStatement();
final ResultSet rs=st.executeQuery("select * from data");
check=new JCheckBox("",false);
while(rs.next()){
model.insertRow(table.getRowCount(),new Object[]{rs.getString("name"),rs.getString("address")});
includeColumn.setCellEditor(new DefaultCellEditor(check));
includeColumn.setCellRenderer(new checkboxCellRender());
}
model.removeRow(0);
}
catch(Exception e){}
panel.add(pane);
frame.add(panel);
frame.setSize(500,300);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
class checkboxCellRender extends JCheckBox
implements TableCellRenderer{
public Component getTableCellRendererComponent( JTable t,Object value, boolean isSelected, boolean hasFocus,
int row, int col)
{
JCheckBox cb = new JCheckBox();
boolean sel=check.isSelected();
if(sel){
cb.setSelected(Boolean.TRUE);
}
else{
cb.setSelected(Boolean.FALSE);
}
return cb;
}
}
}

Thanks









Related Tutorials/Questions & Answers:
ModuleNotFoundError: No module named 'SIR'
ModuleNotFoundError: No module named 'SIR'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'SIR' How to remove the ModuleNotFoundError: No module named 'SIR' error
hi sir - Java Beginners
hi sir  Hi,sir,i am try in netbeans for to develop the swings,plz provide details about the how to run a program in netbeans and details about... the details sir, Thanks for ur coporation sir  Hi Friend
Advertisements
sir - Java Beginners
sir   hi sir,in this program there is a jtable,i am insert... sir,i am mentioning the error as <<>>>......main bug here>........ in this program,plz see and provide solution sir,database Tables
sir - Java Beginners
sir   hi sir,Happy ugadi,how to place the database records into jtable ,i am using the oracle database plz provide the program how to retrieve the database records and placed into a jtable,i want one more column is added to my
ModuleNotFoundError: No module named 'mesa-SIR'
ModuleNotFoundError: No module named 'mesa-SIR'  Hi, My Python... 'mesa-SIR' How to remove the ModuleNotFoundError: No module named 'mesa-SIR... to install padas library. You can install mesa-SIR python with following
ModuleNotFoundError: No module named 'mih-sir'
ModuleNotFoundError: No module named 'mih-sir'  Hi, My Python...-sir' How to remove the ModuleNotFoundError: No module named 'mih-sir... to install padas library. You can install mih-sir python with following command
ModuleNotFoundError: No module named 'sir-hiss'
ModuleNotFoundError: No module named 'sir-hiss'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'sir-hiss' How to remove the ModuleNotFoundError: No module named 'sir-hiss
more doubts sir. - Java Beginners
more doubts sir.  Hello sir, Sir i have executed your code and i got the result but the problem is whenever i click on the link in my... own browser.Hope you will help me out.And also sir i need the progressbar
sir i,have a assignment for these question plz help me sir - JavaMail
sir i,have a assignment for these question plz help me sir   1.Design a Java interface for ADT Stack. Develop two different classes that implement this interface, one using array and the other using linked-list. Provide
sir plz send the project on quiz system code
sir plz send the project on quiz system code  sir plz send the client server based project in core java database in my sql
ModuleNotFoundError: No module named 'sir-bot-a-lot'
ModuleNotFoundError: No module named 'sir-bot-a-lot'  Hi, My... 'sir-bot-a-lot' How to remove the ModuleNotFoundError: No module named 'sir-bot-a-lot' error? Thanks   Hi, In your python
hii sir
Dear Sir I need to join u
Dear Sir I need to join u  Dear Sir i am santosh Rai from Saudi Arabia please make me understood how to join u and i have one question i want to working with you what is ur process for working with u please send me
swing program plz urgent sir - Java Beginners
swing program plz urgent sir   hi sir,i waan a jtable swings program table having column names "itemid","price".Initially table having single empty row.whenever we click the "enter" button automatically new row will be insert
pls help me sir its urgent
pls help me sir its urgent  thanks for reply, but i am getting this error pls help me its urgent type Exception report message description The server encountered an internal error () that prevented it from
sir i,have a another assignment for these question plz help me sir - JavaMail
sir i,have a another assignment for these question plz help me sir  1. Design classes for Currency, Rupee, and Dollar. Write a program... to both. plz help me sir
Hello Sir I Have problem with My Java Project - Java Beginners
Hello Sir I Have problem with My Java Project  Hello Sir I want Ur Mail Id To send U details and Project Source Code, plz Give Me Ur Mail Id
Plz reply me sir Its urgent - JSP-Servlet
Plz reply me sir Its urgent  Respected Sir/madam, I am R.Ragavendran..Actuaaly,I request you to remember the code which you have provided for me using radio buttons.. You have used the following syntax for checking whether
please do respond to my problem sooooon sir - Java Beginners
please do respond to my problem sooooon sir  Hello sir, Sir i have executed your code and i got the result but the problem is whenever i click... to open the link also in my own browser.Hope you will help me out.And also sir i need
hello sir, please give me answer - Java Beginners
hello sir, please give me answer  Write a program in Java that calculates the sum of digits of an input number, prints... ways in java? so , sir please tell me full solution of this program   Here is your complete
sir - Java Beginners
sir plz do respond to my problem immediately - Java Beginners
sir plz do respond to my problem immediately  Hello sir, Iam very happy that you have responded to my problem.The code u sent for the progree bar is a separate program. sir i need to put it in my web browser.sir iam
sir i want small project with of health care system with struts and hibernate plz help me
sir i want small project with of health care system with struts and hibernate plz help me  sir i want small project on health care system with struts and hibernate plz help me
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
Please guide me sir - EJB
sir, how to convert excel file to csv file using java? please send me sample code.
sir, how to convert excel file to csv file using java? please send me sample code.  please send me sample code for converting excel file into csv file uisng java
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out
sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out  sir/mam i want to have knowledge on live projects of java/jsp/servlets.Can you plz help me out.I want to have a through knowledge
sir plz help in design a jsp page whichis as follow username [_____] select [__>]password [_____] after selection then onlypassword text box is visible
sir plz help in design a jsp page   sir plz help in design a jsp page which is as follow username [ _ ] select [ > ] password [ _ ] after selection then only password text box is visible
delete retailer jsp file (sir..is this a good logic.. jsp file is useful for what purpose)
delete retailer jsp file (sir..is this a good logic.. jsp file is useful for what purpose)  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http
i have problem in that program sir - JavaMail
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code   //here my file...); } } } sir, the above code is my sample code for reading excel file
i have problem in that program to my assignment sir - JavaMail
About Metcalfe House of Delhi
was built as a home for Sir Thomas Metcalfe in 1835. Metcalfe was a leader... Khan in the sixteenth century. However, it was taken in by Sir Theophilus Metcalfe, the son and heir of Sir Thomas Metcalfe. He had then redesigned the area
JSP - Java Beginners
JSP  sir
java.lang.OutOfMemoryError - Applet
java.lang.OutOfMemoryError  Sir/Madam
date picker componnt - Java Beginners
date picker componnt  sir i need code for date picker in java swing for my project sir please send me sir
C Structure
C Structure  Respected sir, Can a structure in C contain a pointer to itself ? if yes means how sir ? plz help me sir
thanks - JSP-Servlet
thanks  thanks sir its working
hi - Java Beginners
hi  hi sir,create a new button and embed the datepicker code to that button sir,plzzzzzzzzzzzzzzzzzzzzzzzzzzz
jsp
jsp  sir i want to jsp code for online examination like as bank po,,,,,,plz help me sir
programming of foxpro
programming of foxpro  hello sir , sir i am use the foxpro . but i know about c . sir how can i learn fox pro . i know about something about foxpro
java - Swing AWT
java  hello sir pls answer..need that urgently
JDBC in JSP - JDBC
JDBC in JSP   Sir, This is the code showing the problem. regards sreejith

Ads