Can not show the JCheckBox in JTable cell

I want to place a JCheckBox in one JTable cell, i do as below:
i want the column "d" be a check box which indicates "true" or "false".
String[] columnNames = {"a","b","c","d"};
Object[][] rowData = {{"", "", "", Boolean.FALSE}};
tableModel = new DefaultTableModel(rowData, columnNames);
dataTable = new JTable(tableModel);
dataTable.getColumnModel().getColumn(3).setCellEditor(new DefaultCellEditor(new JCheckBox()));
But when i run it, the "d" column show the string "false" or "true", not the check box i wanted.
I do not understand it, can you help me?
Thank you very much!
coral9527

Do not use DefaultTableModel, create your own table model and you should implement the method
getColumnClass to display the boolean as checkbox ...
I hope the following colde snippet helps you :
class MyModel extends AbstractTableModel {
          private String[] columnNames = {"c1",
"c2"};
public Object[][] data ={{Boolean.valueOf(true),"c1d1"}};
     public int getColumnCount() {
     //System.out.println("Calling getColumnCount");
     return columnNames.length;
public int getRowCount() {
//System.out.println("Calling row count");
return data.length;
public String getColumnName(int col) {
return columnNames[col];
public Object getValueAt(int row, int col) {
return data[row][col];
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
* Don't need to implement this method unless your table's
* editable.
public boolean isCellEditable(int row, int col) {
//Note that the data/cell address is constant,
//no matter where the cell appears onscreen.
return true;
* Don't need to implement this method unless your table's
* data can change.
public void setValueAt(Object value, int row, int col) {
data[row][col] = value;
fireTableCellUpdated(row, col);

Similar Messages

  • I am a Taiwanese. My iPod nano can not show the lyrics

    My iPod nan can not show the lyrics.It will be like"ifhfjdghuiadhghjkbdbdjkbdgdnkjn589d567g564h54df+.......................... "
    Why?
    How to solve it?

    Right->click on these tracks in iTunes and choose Get Info.  Then head to Lyrics tab.  Are the correct lyrics listed there?
    B-rock

  • Jsp include can not show the full page

    When i use jsp to include other jsp which have around 1000 lines. the included jsu can only show the last 500 lines. how can i solve lt?

    Having JSPs of this size is very bad practice. You should design your solution so as to avoid this at all costs.
    There is an upper size limit on JSPs which you may be running into here, check the JSP spec but it's something like 64k
    Regards,
    Gareth
    (PDK team)

  • Zen Nano 512 Does not show the remaining time

    i realise that it can not show the remaining time of the songs..
    how can we set it up? can we set it to show the remaining time?
    best wishes
    ozzy

    It only shows the time elapsed.
    PB

  • Can not get the Cisco TSP to show UP - 2003 64bit

    Can not get the Cisco TSP to show up on the list of Providers in Phone and Modem Options- Advance tab. Installed ver. 4.1, it seems to install correctly, with no errors but when I restart the server, there is no Cisco TSP001.tsp in the providers list. It works perfectly on my Windows 2003 servers, but will not work on this new Windows 2003 64 bit server. Any tricks to getting this to load?
    Thanks
    Keith

    Hi
    There is no 64-bit TSP yet. Whilst 32-bit apps will work OK for the most part on 64-bit via the WoW function, drivers tend to not be so flexible, and that's what TSP is...
    You'll have to bother your Cisco accounts folks to get this prioritised, it is upsetting a lot of people...
    Aaron
    Please rate helpful posts...

  • Epub books show up in ipad on itunes but do not show up on ipad. Also can not delete the books from ipad in itunes

    epub books show up in ipad on itunes but do not show up on ipad. Also can not delete the books from ipad in itunes

    You have no choice but to lose your data back to the last backup you made.
    Here's how to do the recovery.  Note you may have to try to get into recovery mode more than once to succeed:
    HT1808
    I'm sure next time, you'll be more vigilant about keeping current backups.

  • Good evening, my name is Ludmila I have a problem. im buy second hand iphone 5 but I can not use the screen shows asking me apple id but I do not know this is my first iphone I do not know what the police thought it was stolen or lost but I you can help m

    Good evening, my name is Ludmila I have a problem. im buy second hand iphone 5 but I can not use the screen shows asking me apple id but I do not know this is my first iphone I do not know what the police thought it was stolen or lost but I you can help me. Someone told me we should stop function Find my iphone but how?? email does not even know the first lord. It cost me 400 euros but may not use iphone. someone laugh at me because I deceived. Please help me tell me his email talk to you should stop off iCloud or ID

    Scuzati de engleza google translate

  • My MacBook Pro does not recognize my Android Incredible 2 cell phone and I can not transfer my photos from my cell phoen to my Mac. I was able to do this in the past, but can no longer do so. i havenot upgraded to any new software.

    My MacBook Pro does not recognize my Android Incrdible 2 cell phone and therefore I can not transfer any photos from my cell phone to my Mac. I was able to do this in the past, but can not do so now. I have not upgraded to any new software. My USB cable is plugged in properly and I just get an error message -- "No Android Device Found". What could be the problem?

    I had the same issue with the Galaxy S4 trying to see what the hype was about and was my first and last android phone. With that being said unfortunately it is a hit or miss with the Mac recognizing an android device or not.  It worked perfectly fine the first time around and then it stopped working for no apparent reason. Through trial and error nothing I did solved the issue.   I did however plug it in my Mac and left it connected for about 30-40 min to charge for a bit and all of the sudden it recognizes the phone. So I just launched Android File Transfer and everything else became fluid after that.    I have no explanation as to why it happened that way, but what I gathered from this is maybe you just have to let it sit for a minute while plugged in before the Mac recognizes it, after all they are opposing software.  On a side note this is why I will always be an apple user, Iphones and the like never have this problem

  • I have an I phone 4s and I have many contacts in my phone.  However, whne my phone rings or I receive a text, the phone does not show the name of the contact person only the phone number.  I have checked every setting I can think of ?

    I have an I phone 4s and I have many contacts in my phone.  However, when my phone rings or I receive a message.  The phone does not show the name of the caller.  It only shows the phone number that is calling.  I am sure this is a setting problem, but I have checked every setting I can think of.  Any suggestions??

    If you are a Verizon user try this:
    Open the phone and dial *228. This is a Verizon over-the-air programming number.
    When the system answer press 1 for "Program or activate your phone"
    Wait for the call to disconnect. You should get a prompt stating "Settings updated."
    Double tap the Home button to bring up the recently used apps list at the bottom.  Locate the Phone, Message, and Contacts apps, swiping if necessary, and press and hold until they jiggle then press the red minus sign to stop them.
    Wait a 3-5 minutes.
    Try your phone again and see if it's fixed.

  • TS1363 why the i tunes can not show in my ipod?

    please kindly help me because i can not connect the itunes to my ipod?

    There is a glitch with the calendar app and April 1st, 2013,  SInce that is the beginning of daylight savings time, and the true length of the day is relative, if you have any all day events on April 1, it messes with the whole month (since 'all day' can be 23, 24 or 25 hours due to the springing forward)
    Make that all day app only last a few hours and the rest of the month will show back up.

  • HT4009 I purchased an upgrade inside the free app, however it shows I paid for the free app & now I can not download the full version.  What should I do?

    I purchased an upgrade inside the free app, however it shows I paid for the free app & now I can not download the full version.  What should I do?
    Thanks!
    Kristine

    Finish the download on your computer in iTunes and then sync the app to the iPad and then delete it. You will probably have to let it fully download before you can delete it.
    You can try restarting the iPad and see if the download will resume - Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Yoy can try  this as well and see if the download will resume. Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    Look in iTunes and see if there is a pending download in there that might be causing the delay. If there is a download there, try to finish that one first.

  • How can I show the photos of the person that im calling? now that im using IOS 7 when i want to call someone the photo /imagine does not appear , how can i fix it? iPhone 5, iOS 7

    how can I show the photos of the person that im calling? now that im using IOS 7 when i want to call someone the photo /imagine does not appear , how can i fix it?
    iPhone 5, iOS 7

    jlfcba wrote:
    IOS 7.1.1 doesn't show a "days to sync" parameter anywhere in SETTINGS/Mail,Contacts,Calendars/ACCOUNTS/GMAIL Account/ GMAIL Acccount Info.  There is nothing in iTunes relating to such an option either.  So, it seems I'm back to square one.
    If you have a decent mail provider like Microsoft Hotmail or Outlook.com mail it does.
    If you have Gmail it does not.  Quite right. Gmail is rubbish.

  • Safari status bar disappears.  I have tried clicking on show status bar and it will only appear when I move the cursor to the top of the screen.  I can not minimize the open page only full screen or close the browser.  Any idea how the rectify this

    Safari status bar disappears. I have tried clicking on show status bar, under the View tab and it will only appear when I move the cursor to the top of the screen. I can not minimize the open page, only full screen or close the browser. Any idea how the rectify this issue?

    One enters and exits full-screen with control+command+F keys. This is on the View menu in Safari. Optionally, the green traffic light in your browser title bar, if you roll over it, has the full-screen control it it. While in full-screen mode with Safari, moving your mouse pointer virtually up, and off-screen reveals the Safari title bar again, and you can click the green traffic light to exit full-screen mode.
    You can hide/show the status bar by simply typing command+/. This too, is on the Safari View menu. and in 10.10.1 — it works reliably for me.

  • Upon launch of Lightroom after initial instalation a warning came up that said lightroom needs to create temporary files and cant open.  The it opened and the catalog i imported will not show the images.  How can I give permission? Running windows 8.1 64

    Upon launch of Lightroom after initial installation a warning came up that said lightroom needs to create temporary files and cant open.  Then it opened and the catalog i imported will not show the images.  How can I give permission? Running windows 8.1 64 bit.  I have avast virus software.

    Upon launch of Lightroom after initial installation a warning came up that said lightroom needs to create temporary files and cant open.  Then it opened and the catalog i imported will not show the images.  How can I give permission? Running windows 8.1 64 bit.  I have avast virus software.

  • HT4972 i got my new iphone 4s , can not download the OS 5 it says error 9006 on my windows 7. also the phone does not show the capacity and serial number details on the itunes summery ?? please help

    i got my new iphone 4s , can not download the OS 5 it says error 9006 on my windows 7. also the phone does not show the capacity and serial number details on the itunes summery ?? please help

    Hi Kevin,
    The iPhone 4S comes automatically loaded with iOS 5, and any updates after iOS 5.0 can be completed directly from on the phone in Settings > General > Software Update. If you are having trouble using iTunes to update software, I suggest you reset iTunes so that you can pair your phone to the computer again, because if you can't see the serial number and capacity, that generally means your phone isn't paired.  For any problems this doesn't fix, please contact Apple directly through their automated help line, 1(800)MYAPPLE.

Maybe you are looking for

  • Insert special character in keynote

    Hi folks I wonder if there's any way to insert a "Smiley" logo in Keynote in iPad2, and also as part of the text? I've looked up the Help Menu, online, etc, but couldn't find the answer. It'll be nice to be able to insert such stuffs, plus other "Spe

  • Error dropping user in Oracle 9.2.0.8 on Windows

    When I do a drop user either command line or using OEM, I get the following error: ERROR at line 1: ORA-01001: invalid cursor ORA-00600: internal error code, arguments: [qmxiUnpPacked2], [121], [], [], [] Has anyone seen this? Cheers/

  • Microsoft apps quit working on hp g7

    Hello I have an Hp G7 windows 8.1 and my microsoft apps will not open there was no changes made too my computer when I try too open them they are blank and will not open how can I reinstall them

  • Administrator API: Login to specific instance with username, password

    1) How do I login to a specific instance of ColdFusion administrator with a username and password.  The example I see everywhere is variations of: adminObj = createObject("component","cfide.adminapi.administrator"); adminObj.login("password"); which

  • How to update my old tugsten T3

    I have an old but trustworthy Tungsten T3 with version 4.5.1P. I think it has 16bit &  64MB RAM. Is it possible to install Palm OS v 5.0 on my T3? Lot of the new software for Palm (eg. video player) requires this as a minimum requirement. I have lot