TableCellRenderer -- not showing as "selected" in JTable

Hi,
I have a a JTable, and for one of my columns, i do
for (int i = 0; i < dataModel.getColumnCount(); i++) {
     column = table.getColumnModel().getColumn(i);
          if (i ==0)
                 column.setCellRenderer(new NotificationCellRenderer());
     private class NotificationCellRenderer implements TableCellRenderer {
          public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
               JLabel label = new JLabel(String.valueOf(value));
               label.setToolTipText(label.getText() + " and more description goes here");
               return label;
     }so it looks fine...but then when i select a row in my table, all the cells of the row are "highlighted" with the blue color...except for the column which uses that cell renderer....
how can fix this?
thanks

Or, maybe an easier approach is to override the getToolTipText(...) method of JTable:
        JTable table = new JTable(data, columnNames)
            public String getToolTipText( MouseEvent e )
                int row = rowAtPoint( e.getPoint() );
                int column = columnAtPoint( e.getPoint() );
                Object value = getValueAt(row, column);
                return value == null ? null : value.toString();
        };

Similar Messages

  • Vertical ComboBox does not show its selected Item's label

    Hello,
    We have created a custom vertical ComboBox.
    Normal combobox has been rotated to -90 degrees.
    It aims to show its selected label and open up the menu at proper x,y coordinate.
    To open up the menu at proper x,y coordinate, we have overriden "downArrowButton_buttonDownHandler" function to move the dropdown accordingly.
    However, the selected label is not visible on screen. Rotated text does not show up without embedding fonts. Hence, We have tried embedding font for the same. It doesn't work though.
    Please help.
    Regards,
    Tanu

    Embedded font isn't working for rotated button/combobox. Though, it works fine with rotated label
    Please refer to below given code:
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Style>
         .mystyle1 {
            fontFamily:myPlainFont;
            fontSize: 32pt;
      </mx:Style>
      <mx:Script>
          * Embed a font by name.
         [Embed(systemFont='Arial',
            fontName='myPlainFont',
            mimeType='application/x-font'
         private var font1:Class; 
      </mx:Script>
      <mx:Panel title="Embedded Fonts Using ActionScript">
         <mx:VBox>
            <mx:Label            
                styleName="mystyle1"
                text="Embedded font"
                rotation="15"
            />      
            <mx:Button             
                styleName="mystyle1"
                label="Embedded"
                rotation="15"
                />
         </mx:VBox>
      </mx:Panel>
    </mx:Application>
    Regards,
    Tanu

  • 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);

  • Not showing Scene Selections

    Hi all,
    I've imported a movie I made in Final Cut Express that has chapter markers, but when I drag the movie into the background in iDVD, it doesn't automatically create two buttons ("Play Movie" and "Scene Selection"). This suggests that my chapter markers are not being recognized.
    I have definitely placed chapter markers in the movie in FCE, and I have exported it after selecting the 'Chapter Markers' option in the drop-down menu.
    What am I doing wrong?
    Andrew

    When I search the store for 'Comedy Bang Bang', on the results screen I get :
    To the far right of the Podcast Episodes heading is a 'see all' button/link. Or clicking on the podcast name above it takes me to that podcast's episodes.
    On the list for that particular podcast I see whitespace if I scroll down the screen too quickly, but scrolling back gets them to (slowly) appear.

  • Image in photoshop transparent and not showing image selected.

    My images are appearing in Photoshop as 'transparent' and not as the image selected. This is following a major fault created by hardware supplied to me which caused me to have to re-format my computer.

    Microcord,
    Did you try posting something via e-mail? All I see is a blank reply in the thread.
    Sometimes, e-mail/ attachments sent via e-mail never reach the forum. Please login to http://forums.adobe.com and respond to your post.
    -ST

  • Captivate 7 - quiz questions not showing tick/select boxes on ipad

    I'm having an issue when testing a course on ipad, on the question slides the radio buttons/tick boxes don't show. The module also doesn't show which answer you have selected. The course works fine across other browsers on desktops (both PC and MAC).
    I've checked the HTML5 tracker, and there are no reported errors. The questions are default captivate multiple choice question.
    Thanks,
    Chris.

    I have installed the 7.0.0, patch upgrade to 7.0.1.237, and instead of using the Master Slide I have uploaded a white background image. Within the properties tab>general, I have checked the project background option and uploaded my background image. Both Master slide objects on top and Use master slide background are unchecked.
    I have uploaded my module to Moodle 2.5, and tests have gone well on all desktops and all browsers. Only the last slide contains any interactivity, and has checkboxes and a submit button to confirm their attestation of completion. However, when tested on an iPad, this one slide that contains the check boxes and submit button appear white/or blank. Would anybody have insight into this issue?

  • LR 5 spot removal/heal tool does not show the selected area

    A week back I installed LR 5 on my 15-inch Retina MBP. My laptop has ample hardware to run LR5. The problem I faced was with the spot removal/heal tool. It goes like below.
    I selected the Spot removal tool and set the mode to HEAL and then selected an area on my image. In many tutorials I saw the selected area is shown as a circle with white border with an arrow pointing to another circle. But in my case, its all invisible. Same issue happened when I selected CLONE mode. I am attaching a video to demonstrate the issue.
    Could someone help me to understand what is going on? I am new to LR, but I like the software and want to invest time and money in it. However, with such issues I am little panic and not sure if this software is worth of those investments.
    Thank you all.
    - NN

    Have you tried the "H" for hide pin key???

  • Rulers not showing although selected on

    I'm just starting to use my new Creative Cloud version of InDesign on my iMac but the ID window doesn't show the rulers even though they are selected on in View.  I’m trying to change my document dimensions to inches but the only way to see the rulers is to open a document which then prevents any dimension changes from taking effect!  Also the work area is transparent instead of a white background, just in case that’s relevant.  Is there a setting somewhere that I can use to reset the display to show the rulers without a document open?

    It's normal to have no rulers until you have a document open. You can change the default units in the prefs (InDesign > Preferences > Units and Increments). This will affect new work, but you'll need to cahnge existing files one at a time.

  • I had recently tried to change the background of the lockscreen and it did not show the selected image as lockscreen background while charging, but earlier the image iused to keep as lockscreen background used to be always present even while charging???

    is it normal for the iphone to act like this ???

    Firstly I thank you very much ckuan to take out time and answer my question. But I seem to have tried all the three things but in my case the phone doesn't show background of lock screen in two out of three instances that you have pointed out. First being it shown to me while charging if I press the home key, but if I press home key once during charging it still appears dark and battery and I suppose date and time shown.
    Secondly the one at silent mode also doesn't work in my phone.

  • Print does not show a selected photo and won't print

    How do I get my photos printed? I select a photo but I get the maessage that no photo was selected.

    I finally called the help desk. I was told that sometimes the catalog needs to be reloaded. Instead of reloading the catalog, i ended up loading my entire library. Over 4200 pictures. This was without any filtering. But now the print feature works.
    Next I will need to figure out how get out all of the duplicates. Set up filters and get organized. I am new at this so after spending over 30 hours watching how to videos I am a little overwhelmed.
    It would be nice if the help desk guy could speak English. Well, English  that I could understand. Poor guy had to repeat everything several times. I asked if he could get me organized. Nope. Had to call back. That means sitting on hold for an hour and a half....but hey I have another 30 days of support. I am going to learn this. Although I am now convinced that I am dain bramaged and beyond help. Now how to get the e-mail notification turned off.. 50 e-mails a day. Isn't this fun.

  • Genius switched on but the symbol not showing on selected album in the iPod so unable to create a genius play list. This has only happened since last Apple update.

    Have tried all avenues to try and rectify this problem and is getting very annoying. In the past it has stopped me from creating a list stating not enough songs matching which i find odd seeing i have over 2,500 on my iPod.

    Dear Customer,
    As you can see, your pre-requisite checks are failing because you are not on supported OS version.
    Please verify supported OS from SRSP guide (If you are on prior Siebel version 8.1.1.8) or Certification tab for all siebel versions from 8.1.1.9.
    I hope it helps.
    Best Regards,
    Chetan

  • Pictures not showing in edit

    Hello. Iphoto is not showing the selected photo when I double click it or choose to edit it. Photos are uploaded to iphoto okay and show in the strip at the bottom but I get a blank box where the selected photo should go. This just started happening today.
    thanks for any help

    Back up your iPhoto library, Depress and hold the option (alt) and command keys and launch iPhoto - rebuild your iPhoto library database
    You have to keep them help down until the first aid window appears
    LN

  • Xml is not generating the selected column

    Hi experts,
    I have selected the 3 column in my slect statement with 3 bind variable . But when I save my datamodel and generate the xml , My xml is not showing the selected three column...please find the blow query.
    Select BAL_ATT.TRANSACTIONAL_AMOUNT_WD0,
    BAL_ATT.FUNCTIONAL_AMOUNT_WD0 ,
    SIGNOFF.CODE_COMBINATION_ID,
    RT.ROLE_NAME
    from
    MLC_BAL_ATTRIBUTE_T BAL_ATT /* A_MLC_BAL_ATTRIBUTE */ ,
    MLC_USER_T US/* A_MLC_USERS */ ,
    MLC_BAL_SEGMENT_T BAL_SEG/* A_MLC_BAL_SEGMENT */ ,
    MLC_SIGNOFF_T SIGNOFF /* A_MLC_SIGNOFF */ ,
    MLC_LEDGER_ROLE_HIERARCHY_T RHT,
    MLC_ROLE_T RT , MLC_LEDGER_T Leg,
    MLC_LEDGER_COMPONENT_T LC
    where ( SIGNOFF.CODE_COMBINATION_ID = BAL_ATT.CODE_COMBINATION_ID
    and SIGNOFF.CODE_COMBINATION_ID = BAL_SEG.CODE_COMBINATION_ID
    and SIGNOFF.MONTH_END_DATE = BAL_ATT.MONTH_END_DATE
    and RHT.LEDGER_ID= SIGNOFF.LEDGER_ID
    and RHT.LEDGER_COMPONENT_ID=SIGNOFF.LEDGER_COMPONENT_ID
    and RT.ROLE_ID=RHT.ROLE_ID
    and LC.LEDGER_ID=SIGNOFF.LEDGER_ID
    and LC.LEDGER_ID=LEG.LEDGER_ID
    and (US.USER_ID =SIGNOFF .ROLE4_USER_ID or
    US.USER_ID =SIGNOFF .ROLE3_USER_ID
    or US.USER_ID =SIGNOFF .ROLE1_USER_ID
    or US.USER_ID =SIGNOFF .ROLE2_USER_ID
    or US.USER_ID =SIGNOFF .ROLE5_USER_ID)
    and LEG.LEDGER_NAME IN (:LEG)
    and RT.ROLE_NAME IN(:ROLE)
    and LC.LEDGER_COMPONENT_NAME IN(:LEG_COMP)
    and (SIGNOFF.ROLE1_STATUS is null or SIGNOFF.ROLE2_STATUS is null or SIGNOFF.ROLE3_STATUS is null or SIGNOFF.ROLE4_STATUS is null or SIGNOFF.ROLE5_STATUS is null))
    Let me know If I need to do some configuration.
    I need to generate the xml and then need to import it my rtf template...

    Hi RavindraKshirsagar,
    We have a problem like you faced. Our requirement is that, we need to generate dynamically the PERSON element in our javabean.
    <xs:element name='SERVICE_REQUESTER'>
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref='ORGANIZATION' />
                        <xs:element ref='PERSON' maxOccurs='unbounded' />
                   </xs:sequence>
              </xs:complexType>
         </xs:element>For this maxOccurs, as JAXB is not generating any Setter Method. As we need to get data dynamically from external application. If you could help us in handling this case dynamically, it will be well and good.
    Please send us the script / code asap.

  • JTable Problem (table does not show rows and columns)

    Hi All,
    What the table is suppose to do.
    - Load information from a database
    - put all the values in the first column
    - in the second column put combobox (cell editor with numbers 1-12)
    - the 3rd column put another combobox for something else
    - the 4th column uses checkbox as an edit
    The number of rows of the table should be equal to the number of
    record from
    the database. If not given it default to 20 (poor but ok for this)
    The number of columns is 4.
    But the table does not show any rows or
    column when I put it inside a
    JScrollPane (Otherwise it works).
    Please help,
    thanks in advance.
    public class SubjectTable extends JTable {
    * Comment for <code>serialVersionUID</code>
    private static final long serialVersionUID = 1L;
    /** combo for the list of classes */
    protected JComboBox classCombo;
    /** combo for the list of subjects */
    protected JComboBox subjectsCombo;
    /** combo for the list of grade */
    protected JComboBox gradeCombo;
    boolean canResize = false;
    boolean canReorder = false;
    boolean canSelectRow = false;
    boolean canSelectCell = true;
    boolean canSelectColumn = true;
    // the row height of the table
    int rowHeight = 22;
    // the height of the table
    int height = 200;
    // the width of the table
    int width = 300;
    // the size of the table
    Dimension size;
    * Parameterless constructor. Class the one of the other constructors
    to
    * create a table with the a new <code>SubjectTableModel</code>.
    public SubjectTable() {
    this(new SubjectTableModel());
    * Copy constructor to create the table with the given
    * <code>SubjectTableModel</code>
    * @param tableModel -
    * the <code>SubjectTableModel</code> with which to
    initialise
    * the table.
    SubjectTable(SubjectTableModel tableModel) {
    setModel(tableModel);
    setupTable();
    * Function to setup the table's functionality
    private void setupTable() {
    clear();
    // set the row hieght
    this.setRowHeight(this.rowHeight);
    // set the font size to 12
    //TODO this.setFont(Settings.getDefaultFont());
    // disble reordering of columns
    this.getTableHeader().setReorderingAllowed(this.canReorder);
    // disble resing of columns
    this.getTableHeader().setResizingAllowed(this.canResize);
    // enable the horizontal scrollbar
    this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    // disable row selection
    setRowSelectionAllowed(this.canSelectRow);
    // disable column selection
    setColumnSelectionAllowed(this.canSelectColumn);
    // enable cell selection
    setCellSelectionEnabled(this.canSelectCell);
    setPreferredScrollableViewportSize(getSize());
    TableColumn columns = null;
    int cols = getColumnCount();
    for (int col = 0; col < cols; col++) {
    columns = getColumnModel().getColumn(col);
    switch (col) {
    case 0:// subject name column
    columns.setPreferredWidth(130);
    break;
    case 1:// grade column
    columns.setPreferredWidth(60);
    break;
    case 2:// class room column
    columns.setPreferredWidth(120);
    break;
    case 3:// select column
    columns.setPreferredWidth(65);
    break;
    } // end switch
    }// end for
    // set up the cell editors
    doGradeColumn();
    doClassColumn();
    //doSubjectColumn();
    * Function to clear the table selection. This selection is different
    to
    * <code>javax.swing.JTable#clearSelection()</code>. It clears the
    user
    * input
    public void clear() {
    for (int row = 0; row < getRowCount(); row++) {
    for (int col = 0; col < getColumnCount(); col++) {
    if (getColumnName(getColumnCount() - 1).equals("Select")) {
    setValueAt(new Boolean(false), row, getColumnCount() - 1);
    }// if
    }// for col
    }// for row
    * Function to set the cell renderer for the subjects column. It uses
    a
    * combobox as a cell editor in the teacher's subjects table.
    public void doSubjectColumn() {
    TableColumn nameColumn = getColumnModel().getColumn(0);
    nameColumn.setCellEditor(new DefaultCellEditor(getSubjectsCombo()));
    // set up the celll renderer
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for drop down list");
    nameColumn.setCellRenderer(renderer);
    // Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = nameColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer) headerRenderer)
    .setToolTipText("Click the Name to see a list of choices");
    }// end doSubjectsColumn----------------------------------------------
    /** Function to set up the grade combo box. */
    public void doGradeColumn() {
    TableColumn gradeColumn = getColumnModel().getColumn(1);
    gradeColumn.setCellEditor(new DefaultCellEditor(getGradeCombo()));
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for drop down list");
    gradeColumn.setCellRenderer(renderer);
    // Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = gradeColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer) headerRenderer)
    .setToolTipText("Click the Grade to see a list of choices");
    }// end doGradeColumn-------------------------------------------------
    * Function to setup the Class room Column of the subjects
    public void doClassColumn() {
    // set the column for the classroom
    TableColumn classColumn = getColumnModel().getColumn(2);
    classColumn.setCellEditor(new DefaultCellEditor(getClassCombo()));
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for drop down list");
    classColumn.setCellRenderer(renderer);
    // Set up tool tip for the sport column header.
    TableCellRenderer headerRenderer = classColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer) headerRenderer)
    .setToolTipText("Click the Class to see a list of choices");
    }// end doClassColumn--------------------------------------------------
    * Function to get the size of the table
    * @return Returns the size.
    public Dimension getSize() {
    if (this.size == null) {
    this.size = new Dimension(this.height, this.width);
    return this.size;
    * Function to set the size of the table
    * @param dim
    * The size to set.
    public void setSize(Dimension dim) {
    if (dim != null) {
    this.size = dim;
    return;
    * Function to create/setup the class room comboBox. If the comboBox
    is
    * <code>null</code> a nwew one is created else the functon returns
    the
    * function that was returned initially.
    * @return Returns the classCombo.
    private JComboBox getClassCombo() {
    if (this.classCombo == null) {
    this.classCombo = new JComboBox();
    // fill up the class name combo
    ArrayList classRooms = new ArrayList();
    try {
    //TODO classRooms = Settings.getDatabase().getClassRooms();
    for (int i = 0; i < 10; i++) {
    String string = new String("Class");
    string += i;
    if (!classRooms.isEmpty()) {
    classRooms.trimToSize();
    for (int i = 0; i < classRooms.size(); i++) {
    this.classCombo.addItem(classRooms.get(i));
    } catch (Exception e) {
    e.printStackTrace();
    return this.classCombo;
    * Function to create/setup the subjects comboBox. If the comboBox is
    * <code>null</code> a nwew one is created else the functon returns
    the
    * function that was returned initially.
    * @return Returns the subjectsCombo.
    private JComboBox getSubjectsCombo() {
    if (this.subjectsCombo == null) {
    this.subjectsCombo = new JComboBox();
    try {
    ArrayList subjects = loadSubjectsFromDatabase();
    if (!subjects.isEmpty()) {
    Iterator iterator = subjects.iterator();
    while (iterator.hasNext()) {
    // create a new subject instance
    //TODO Subject subct = new Subject();
    // typecast to subject
    //TODO subct = (Subject) iterator.next();
    String name = (String) iterator.next();
    // add this subject to the comboBox
    //TODO this.subjectsCombo.addItem(subct.getName());
    subjectsCombo.addItem(name);
    }// end while
    }// end if
    else {
    JOptionPane.showMessageDialog(SubjectTable.this,
    "Subjects List Could Not Be Filled");
    System.out.println("Subjects List Could Not Be Filled");
    } catch (Exception e) {
    e.printStackTrace();
    return this.subjectsCombo;
    * Function to load subjects from the <code>Database</code>
    * @return Returns the subjects.
    private ArrayList loadSubjectsFromDatabase() {
    // list of all the subject that the school does
    ArrayList subjects = new ArrayList();
    try {
    //TODO to be removed later on
    for (int i = 0; i < 10; i++) {
    String string = new String("Subject");
    string += i;
    subjects.add(i, string);
    // set the school subjects
    //TODO subjects = Settings.getDatabase().loadAllSubjects();
    } catch (Exception e1) {
    e1.printStackTrace();
    return subjects;
    * Function to create/setup the grade comboBox. If the comboBox is
    * <code>null</code> a nwew one is created else the functon returns
    the
    * function that was returned initially.
    * @return Returns the gradeCombo.
    private JComboBox getGradeCombo() {
    if (this.gradeCombo == null) {
    this.gradeCombo = new JComboBox();
    // fill with grade 1 to 12
    for (int i = 12; i > 0; i--) {
    this.gradeCombo.addItem(new Integer(i).toString());
    return this.gradeCombo;
    public static void main(String[] args) {
    try {
    UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
    System.out.println("Look and Feel has been set");
    } catch (UnsupportedLookAndFeelException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    SubjectTableModel model = new SubjectTableModel();
    int cols = model.getColumnCount();
    int rows = model.getRowCount();
    Object[][] subjects = new Object[rows][cols];
    for (int row = 0; row < rows; row++) {
    subjects[row][0] = new String("Subjectv ") + row;
    }//for
    model.setSubjectsList(subjects);
    SubjectTable ttest = new SubjectTable(model);
    JFrame frame = new JFrame("::Table Example");
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(ttest);
    frame.getContentPane().add(scrollPane);
    frame.pack();
    frame.setVisible(true);
    **************************************END
    TABLE******************************
    ----------------------------THE TABLE
    MODEL----------------------------------
    * Created on 2005/03/21
    * SubjectTableModel
    package com.school.academic.ui;
    import javax.swing.table.AbstractTableModel;
    * Class extending the <code>AbstractTableModel</code> for use in
    creating the
    * <code>Subject</code>s table. In addition to the implemented methods
    of
    * <code>AbstractTableModel</code> The class creates a model that has
    initial
    * values - the values have their own <code>getter</code> and
    * <code>setter</code> methods - but can still be used for values that
    a user
    * chooses.
    * <p>
    * @author Khusta
    public class SubjectTableModel extends AbstractTableModel {
    * Comment for <code>serialVersionUID</code>
    private static final long serialVersionUID = 3257850978324461113L;
    /** Column names for the subjects table */
    String[] columnNames = { "Subject", "Grade", "Class Room",
    "Select" };
    /** Array of objects for the subjects table */
    Object[][] subjectsList;
    private int totalRows = 20;
    protected int notEditable = 0;
    * Parameterless constructor.
    public SubjectTableModel() {
    // TODO initialise the list
    // add column to the default table model
    this.subjectsList = new
    Object[getTotalRows()][getColumnNames().length];
    * Copy constructor with the <code>subjectList</code> to set
    * @param subjects
    public SubjectTableModel(Object[][] subjects) {
    this(0, null, subjects, 0);
    * Copy constructor with the initial number of row for the model
    * @param rows -
    * the initial rows of the model
    * @param cols -
    * the initial columns of the model
    * @param subjects -
    * the initial subjects for the model
    * @param edit - the minimum number of columns that must be
    uneditable
    public SubjectTableModel(int rows, String[] cols, Object[][]
    subjects, int edit) {
    // set the initial rows
    setTotalRows(rows);
    // set the column names
    setColumnNames(cols);
    // set the subjectlist
    setSubjectsList(subjects);
    //set not editable index
    setNotEditable(edit);
    * Function to get the total number of columns in the table
    * @return int -- the columns in the table
    public int getColumnCount() {
    if (this.subjectsList == null) {
    return 0;
    return getColumnNames().length;
    * Function to get the total number of rows in the table
    * @return int -- the rows in the table
    public int getRowCount() {
    if (this.subjectsList == null) {
    return 0;
    return this.subjectsList.length;
    * Function to get the name of a column in the table.
    * @param col --
    * the column to be named
    * @return String -- the column in the table
    public String getColumnName(int col) {
    if (getColumnNames()[col] != null) {
    return getColumnNames()[col];
    return new String("...");
    * Function to get the value of the given row.
    * @param row --
    * the row of the object.
    * @param col --
    * the col of the object.
    * @return Object -- the value at row, col.
    public Object getValueAt(int row, int col) {
    return getSubjectsList()[row][col];
    * Function to return the data type of the given column.
    * @param c --
    * the column whose type must be determined.
    * @return Class -- the type of the object in this col.
    public Class getColumnClass(int c) {
    if (getValueAt(0, c) != null) {
    return getValueAt(0, c).getClass();
    return new String().getClass();
    * Function to put a value into a table cell.
    * @param value --
    * the object that will be put.
    * @param row --
    * the row that the object will be put.
    * @param col --
    * the col that the object will be put.
    public void setValueAt(Object value, int row, int col) {
    * TODO: Have a boolean value to determine whether to clear or
    to set.
    * if true clear else set.
    if (value != null) {
    if (getSubjectsList()[0][col] instanceof Integer
    && !(value instanceof Integer)) {
    try {
    getSubjectsList()[row][col] = new
    Integer(value.toString());
    fireTableCellUpdated(row, col);
    } catch (NumberFormatException e) {
    * JOptionPane .showMessageDialog( this., "The \""
    +
    * getColumnName(col) + "\" column accepts only
    values
    * between 1 - 12");
    return;
    System.out.println("Value = " + value.toString());
    System.out.println("Column = " + col + " Row = " + row);
    // column = Grade or column = Select
    switch (col) {
    case 2:
    try {
    // TODO
    if (Boolean.getBoolean(value.toString()) == false
    && getValueAt(row, 0) != null
    && getValueAt(row, 1) != null
    && getValueAt(row, 2) != null) {
    // subjectsList[row][col + 1] = new
    Boolean(true);
    System.out.println("2. false - Updated...");
    * this.subjectListModel.add(row,
    * this.subjectsList[row][0] + new String(" -
    ") +
    * this.subjectsList[row][2]);
    } catch (ArrayIndexOutOfBoundsException exception) {
    exception.printStackTrace();
    break;
    case 3:
    if (Boolean.getBoolean(value.toString()) == false
    && getValueAt(row, 0) != null
    && getValueAt(row, 1) != null
    && getValueAt(row, 2) != null) {
    System.out.println("3. If - Added...");
    getSubjectsList()[row][3] = new Boolean(true);
    this.subjectListModel.addElement(this.subjectsList[row][0] +
    * new String(" - ") + this.subjectsList[row][2]);
    // subjectListModel.remove(row);
    fireTableCellUpdated(row, col);
    fireTableDataChanged();
    // this.doDeleteSubject();
    } else if (Boolean.getBoolean(value.toString()) ==
    true
    && getValueAt(row, 0) != null
    && getValueAt(row, 1) != null
    && getValueAt(row, 2) != null) {
    setValueAt("", row, col - 1);
    setValueAt("", row, col - 2);
    setValueAt("", row, col - 3);
    System.out.println("3. Else - Cleared...");
    // this.subjectListModel.remove(row);
    break;
    default:
    break;
    }// end switch
    getSubjectsList()[row][col] = value;
    fireTableCellUpdated(row, col);
    fireTableDataChanged();
    }// end if
    }// end
    * Function to enable edition for all the columns in the table
    * @param row --
    * the row that must be enabled.
    * @param col --
    * the col that must be enabled.
    * @return boolean -- indicate whether this cell is editble or
    not.
    public boolean isCellEditable(int row, int col) {
    if (row >= 0
    && (col >= 0 && col <= getNotEditable())) {
    return false;
    return true;
    * Function to get the column names for the model
    * @return Returns the columnNames.
    public String[] getColumnNames() {
    return this.columnNames;
    * Function to set the column names for the model
    * @param cols
    * The columnNames to set.
    public void setColumnNames(String[] cols) {
    // if the column names are null the default columns are used
    if (cols != null) {
    this.columnNames = cols;
    * Function to get the rows of subjects for the model
    * @return Returns the subjectsList.
    public Object[][] getSubjectsList() {
    if (this.subjectsList == null) {
    this.subjectsList = new
    Object[getTotalRows()][getColumnNames().length];
    return this.subjectsList;
    * Function to set the subjects list for the model
    * @param subjects
    * The subjectsList to set.
    public void setSubjectsList(Object[][] subjects) {
    // if the subject list is null create a new one
    // using default values
    if (subjects == null) {
    this.subjectsList = new
    Object[getTotalRows()][getColumnNames().length];
    return;
    this.subjectsList = subjects;
    * Function to get the total number of rows for the model. <b>NB:
    </b> This
    * is different to <code>
    getRowCount()</code>.<code>totalRows</code>
    * is the initial amount of rows that the model must have before
    data can be
    * added.
    * @return Returns the totalRows.
    * @see #setTotalRows(int)
    public int getTotalRows() {
    return this.totalRows;
    * Function to set the total rows for the model.
    * @param rows
    * The totalRows to set.
    * @see #getTotalRows()
    public void setTotalRows(int rows) {
    // if the rows are less than 0 the defaultRows are used
    // set getTotalRows
    if (rows > 0) {
    this.totalRows = rows;
    * Function to get the number of columns that is not editble
    * @return Returns the notEditable.
    public int getNotEditable() {
    return this.notEditable;
    * Function to set the number of columns that is not editable
    * @param notEdit The notEditable to set.
    public void setNotEditable(int notEdit) {
    if (notEdit < 0) {
    notEdit = 0;
    this.notEditable = notEdit;
    ----------------------------END TABLE MODEL----------------------------------

    I hope you don't expect us to read hundreds of lines of unformatted code? Use the "formatting tags" when you post.
    Why are you creating your own TableModel? It looks to me like the DefaultTableModel will store you data. Learn how to use JTable with its DefaultTableModel first. Then if you determine that DefaultTableModel doesn't provide the required functionality you can write your own model.

  • Calendar.app not showing First Day of Week selected in iCal

    I have selected Monday as the first day of the week in iCal. After syncing, Calendar.app on my iPhone 4 does not show Monday as first day of week. My original iPhone 2G (3.1.3, jailbroken) does show the correct start day, Monday.)
    I do not need assistance with my iPhone 2G. I need a solution for my iPhone 4.
    How do I get my iPhone 4 to be in sync with my other calendars?

    That's a real pain. I'm in Australia and the regional settings have Monday as the first week, which throws me out because all my calendars and even settings in iCal have Sunday as the first day of the week (which is what it's supposed to be). To get what I want, I have to set my country as New Zealand, and this messes up my phone number formats (closest to Australia than any of the others that start the week correctly though). It should be an option in the settings!

Maybe you are looking for

  • Error in using plsql record type inside packages

    Dear Friends, Using Ora9iR2 on Windows 2000 Server. I am trying to declare a record type and a nested table of that record type in the package body and the initialise that in the package body then insert records into that. But I receive error msg. CR

  • How to include a new field for checking duplicate customer master

    Dear All we have activated the standard procedure to check duplicate customer master data. This is a standard procedure as below :- Procedure: Run SM30, key in Table V_T100C, select Display or Maintain, set App area F2. Here you can change current se

  • What's Empty List Good For?

    I'm having a hard time understanding the point of an empty list. The following code doesn't let me add anything to the list: public static void main(final String[] args) {    final List<String> mammalList = Collections.emptyList();    mammalList.add(

  • JRE 1.4 to 1.6 - Migration Question

    Thank you for reading this post and attempting to help me. I am being tasked with a project to migrate a application that was developed on JDK 1.4 to JDK 1.6, the application is not going to go through any functional change. I went about upgrading my

  • Top Contributors based on reputation points - Web part

    I am working on a requirement where a Task list with multiple subtasks is created, some reputations points are awarded to assignees on completion of sub/tasks. Now if a assignee is already carrying some points and some new points are awarded on compl