?
Solved

How to use JTable

Posted on 2006-07-18
7
Medium Priority
?
351 Views
Last Modified: 2010-03-31
Hi Experts,
Please let me know how to rerange the column with of JTable in the code.
I have the default table as below:
STT    Menu   Series     Product  
1          D      12345..   LC27

The leght of series is 14, so I want to rerange the Series column or what the column I need with the width param.

I need to add a check box to cell of rows of JTable
I do as below- see at line 2:

                data[rowIndex][0] = Integer.toString(seriObj.getSeqNumber());

                data[rowIndex][1] =new Boolean(false);   //Bolean value to add a check box to cell

                data[rowIndex][2] = seriObj.getSeriCode();
                data[rowIndex][3] = seriObj.getProductName();

but it cause me the java.lang.ArrayStoreException: java.lang.Boolean exception

Thank you in advance!

It is correct to add a check box to cell? please let me know the way to do this?
0
Comment
Question by:CongUan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
7 Comments
 
LVL 26

Expert Comment

by:ksivananth
ID: 17135792
check the data type of the array!
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 17135794
it should be the type of Object
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 672 total points
ID: 17136093
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 664 total points
ID: 17136103
to resize the column width, set the setAutoResizeMode( int ) and pass JTable.AUTO_RESIZE_NEXT_COLUMN | AUTO_RESIZE_SUBSEQUENT_COLUMNS| AUTO_RESIZE_LAST_COLUMN

0
 
LVL 8

Assisted Solution

by:kaliyugkaarjun
kaliyugkaarjun earned 664 total points
ID: 17136276
Using a Basic JTable:

import java.awt.*;
import javax.swing.*;

public class BasicTable extends JFrame {
    public static void main(String args) {
        new BasicTable();
    }

    public BasicTable() {
        super("Basic Table");
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        Container c = getContentPane();

        c.add( new JScrollPane( new JTable() ), BorderLayout.CENTER );

        pack();
        setVisible(true);
    }
}

More Links

http://www.codeguru.com/java/Swing/JTable/index.shtml
http://everything2.com/index.pl?node_id=1682349
http://quicktable.org/jtable/quicktablemain.htm
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question