need help with a render a cell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andrea8288
    New Member
    • Mar 2007
    • 5

    #1

    need help with a render a cell

    please, i need to change only one cell, but i only get change all the column of the table... i am beginner, and im learning english, je je je sorry
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Originally posted by andrea8288
    please, i need to change only one cell, but i only get change all the column of the table...
    Could you be a bit more specific - what are you working with, is this a database, an excel sheet? If so, what kind? What is the statement you are using to try to change the cell?

    Comment

    • andrea8288
      New Member
      • Mar 2007
      • 5

      #3
      Originally posted by sicarie
      Could you be a bit more specific - what are you working with, is this a database, an excel sheet? If so, what kind? What is the statement you are using to try to change the cell?
      i am using a render that extends from a tablecellrender er and i create the jtable and set the table cell renderer, im not using a database, and i need change the cell to a combo or a checkbox, but this change all the column... :-(

      look at this

      /**
      *
      * @author adelacruz
      */
      public class Renderer extends JComboBox implements TableCellRender er{

      private String type;
      /**
      * Creates a new instance of Renderer
      */
      public Renderer(String type) {
      super();
      if (type == null)
      return;
      if (type.equals("a ttribute")){
      addItem("String "); addItem("Long") ; addItem("Intege r"); addItem("Short" );
      addItem("Byte") ; addItem("Charac ter"); addItem("Double "); addItem("Float" );
      } else if (type.equals("v alidation")){
      addItem("TXT_UP PR"); addItem("INTEGE R"); addItem("DATE") ; addItem("NUMERI C"); addItem("NUMERI C_TEL");
      } else if (type.equals("w idget")){
      addItem("textfi eld"); addItem("checkb ox"); addItem("combob ox"); addItem("option button");
      } else if (type.equals("d b")){
      addItem("VARCHA R"); addItem("CHAR") ; addItem("BOOL") ; addItem("BIGINT "); addItem("INT");
      addItem("MEDIUM INT"); addItem("DOUBLE "); addItem("DECIMA L"); addItem("FLOAT" ); addItem("BLOB") ;
      } else if (type.equals("r elClass")){
      addItem("*"); addItem("1..*") ; addItem("1..1") ; addItem("*..1") ;
      }
      this.type = type;
      }

      public Component getTableCellRen dererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

      if (type.equals("a ttribute") || type.equals("va lidation") || type.equals("wi dget")
      || type.equals("db ") || type.equals("re lClass")){
      setSelectedItem (value);
      return this;
      }else if(value.equals ("true") || value.equals("f alse")){
      JCheckBox check = new JCheckBox();
      check.setSelect ed((value.equal s("true")?Boole an.TRUE:Boolean .FALSE));
      return check;
      }
      return new JTextField(valu e.toString());
      }

      }

      each node have a type, and depends for the type the combo im gonna display...

      Comment

      • andrea8288
        New Member
        • Mar 2007
        • 5

        #4
        well, i got it, dont worry... i get render only one cell. thanks a lot at sicarie ;-)

        Comment

        • sicarie
          Recognized Expert Specialist
          • Nov 2006
          • 4677

          #5
          Originally posted by andrea8288
          well, i got it, dont worry... i get render only one cell. thanks a lot at sicarie ;-)
          Awesome! Sorry I couldn't help. May I ask how you did it?

          Comment

          • andrea8288
            New Member
            • Mar 2007
            • 5

            #6
            no problem, i know you are too busy, not is only me who need help
            well, it was so easy, that i feel like a fool... i did a renderer class and an editor class, i too did a class tableproperties and there i overwrite getCellRenderer and getCellEditor ;-)

            Comment

            • andrea8288
              New Member
              • Mar 2007
              • 5

              #7
              jejeje... but if you feel too bad, you still can help me, jejeje, because now the problem is that i cant set the value of the cell ;-D

              Comment

              Working...