Show Some Love

add jcheckBox to Jtable using GUI

This forum was posted on Friday, May 24, 2013 10:58:19 AM

after searching in google and solutionoferror and going over little solutions I am still stuck with this issue.
I have jtable and I am filling it from DB(derpy-JDBC).
i need add checkout box to my jtable using GUI..I hv update column type to boolean and add these lines

JCheckBox checkBox = new javax.swing.JCheckBox();
jTable1.getColumn("status").setCellEditor(new DefaultCellEditor(checkBox));

but it does not work perfectly.
this my try
public class showp1 extends javax.swing.JFrame implements ActionListener {
/** Creates new form showp1 */
public showp1() {
/** This method is called from within the constructor to
* initialize the form.
* WARNING: don't change this code snippet. The content of this method is
* generally regenerated by the Form Editor.
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowOpened(java.awt.event.WindowEvent evt) {
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object {
{null null null null}
{null null null null}
{null null null null}
{null null null null}
new String {
"id" "area" "location" "status"
) {
Class kinds = new Class {
java.language.Object.class java.language.Object.class java.language.Object.class java.language.Boolean.class
public Class getColumnClass(int columnIndex) {
return kinds columnIndex;
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE Short.MAX_VALUE)
.addComponent(jTextField1 javax.swing.GroupLayout.PREFERRED_SIZE 320 javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING layout.createSequentialGroup()
.addGap(73 73 73)
.addGap(166 166 166))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING layout.createSequentialGroup()
.addComponent(jScrollPane1 javax.swing.GroupLayout.PREFERRED_SIZE 375 javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10 10 10))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING layout.createSequentialGroup()
.addComponent(jTextField1 javax.swing.GroupLayout.DEFAULT_SIZE 23 Short.MAX_VALUE)
.addComponent(jScrollPane1 javax.swing.GroupLayout.PREFERRED_SIZE 155 javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18 18 18)
.addGap(64 64 64))
private void formWindowOpened(java.awt.event.WindowEvent evt) {
myDbConnection dbconnect;
// TODO add your handling code snippet here:
ArrayList list = new ArrayList();
try {
dbconnect = new myDbConnection();
ResultSet resultSet =null;
resultSet = dbconnect.excuteQuery("SELECT id area location status1 FROM pledges ");
while ({
} catch (Exception e) {
Object record;
int myListCount = list.size()/4;
record = new ObjectmyListCount4;
int count = 1;
// JCheckBox checkBox = new javax.swing.JCheckBox();
for (int ii = 1; ii getColumnClass(int columnIndex) {
if (getColumnName(columnIndex).equals("status1")) {
return Boolean.class;
return super.getColumnClass(columnIndex);
public static void main(String args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void execute() {
new showp1().setVisible(true);
} }

sorry for this awful code^^"
Thank You in advance

67 Viewed this Question

 Recent Replies on "add jcheckBox to Jtable using GUI"

  • Nobody has replied on this post, be first to post answer.

Post Your Solution for this Question

Note: Please Put Code into <code></code> block.

Threads related to "add jcheckBox to Jtable using GUI":

How to avoid inner class' name collision?

If I hv a class A and a class B which is A's inner class.Also I hv other class B. it's not in A.class A { ... class B { ... } ...}class B { ...}How can i make an instance of outer B in A?class A { B name = new B();}will get an instance of inner B.

why I cannot get the url parameter with jsf?

I use jsf 1.x. I do not understand where I am wrong with my code snippet snippet.faces-config.xml mainNavigationParametersHandlerBean com.test.MainNavigationParametersHandlerBean request userType java.language.String #{param.userType} My bean:package com.test;public class MainNavigationParametersHandlerBean { // url parameters private String userType = ""; public String getUserType() { return userType; } public void setUserType(String userType) { this.userType = userType; }}And my jsp page (r

Generic Methods and inheritance in Java

Lets say class C and D extend class B which extends class AI hv a methods in class E that i require to be capable to use either an object C or object D in. I know that class A provides all the methods that I require. How can i go about writing a method that lets me pass either a object C or object D as a parameter?Am I right in thinking i require to make a generic class? If so does anyone have specific examples that are closer to what I require that this which only seems to tell me How do I u

How do you create a PDF document using iText that has pages with differing page sizes?

I am trying to generate a PDF document using iText that has pages with differing page sizes. (That is the PDF document can have a some pages little legal size little letter size in no particular order.) it's my code snippet snippet snippet that I hv that is not it working: Document pdfDocument = new Document();PdfWriter writer = PdfWriter.getInstance(pdfDocument ServletActionContext.getResponse().getOutputStream());;for (int i = 0; i Rectangle pageSize = PageSize.LETTER; // c

How can I write multiple XML files using one sketch

Does anybody have little advice on how I can write multiple XML files with only the code snippet snippet of one sketch. I'm trying to do this using the ProXML library but that doesn't work. For little reason one of the two XML files is 'polluted' with data that should only be in the other file.Thanks

Tomcat configuration for analytics application

I am working on an analytics application very similar to Google Analytics.It generally stores the statistics from various websites in a database. The application has the following properties:large number of requests (2.5k/s at peak time)little processing per requestI am working with Tomcat 6 and the Apache HTTPD 2.What values I should set for Tomcat's maxThreads and connectionTimeout properties for this particular type of application?

Jax-ws @PreDestroy When does it get called exactly?

I hv a simply web service using @PostConstruct and @PreDestory annotations. @PostConstructprivate void init() {...} //initialize little database connection@PreDestroyprivate void release() {...} //release data base resourcesthen a member will call little web methods to do little database operations. I did a simply testing by setting break points in the code snippet snippet. The @PostConstruct works best. but @PreDestroy method never get called. I thought @PreDestroy will generally get called when a member finish calli

Implementing a drop down form in Java Swing

I generally wish to have a form that can toggle between a simple and a detailed mode.Whats the best approach to go about implementing this in Swing?various thanks

get data from a Db display in combobox in java

Hello Everyone I have it code snippet snippet but don't know why it doesn't work!rset = stmt.executeQuery("SELECT categoryName FROM DB_Library.dbo.categories");while ( { String s = rset.getString("categoryName"); jComboBox1.addItem(rset.getString(s).trim());}do not show me any thing * This code snippet snippet is printing all the items in database:rset = stmt.executeQuery("select * from DB_Library.dbo.categories");while ( { String s = rset.getString("categoryName&qu

In Java, why is insertion or deletion in a Linked List a constant time operation? Isn't it misleading?

Insertion or deletion of an element at a specific point of a list assuming that we have a pointer to the node already is a constant-time operation. - from the Wikipedia Article on Linked listLinked list traversal in a single linked list generally starts from the head. We have to keep going till we satisfy a given condition.So that will make any operation worst case O(n) unless we are dealing with the head node.We can not DIRECTLY go to a given pointer in a linked list. So why is it said that