-7

i am trying to print set of months and dates to a colum of a table.. it shows {Ljava.lang.Object;@1d4481 eror.. but when i try to print days to the rows it works fine.. i searched stackover thread and found similar qustion also, it says object type something.. here is my table properties

enter image description here

here is my code

    Calendar calendar = Calendar.getInstance();
    //System.out.println("The current date is : " + calendar.getTime());
    System.out.println("The current date is : " + calendar.getTime()); 

    calendar.set(1995, 10, 2);
    for(int i=0; i<2 ; i=i+1){
    calendar.add(Calendar.DATE, 1);
    //System.out.println(" Dates later: " + calendar.getTime());
    System.out.println(" Dates later: " + calendar.get(Calendar.MONTH)+"/"+calendar.get(Calendar.DATE));

    //System.out.println(" Dates later: " + Arrays.toString(calendar.get(Calendar.MONTH).toArray())+"/"+Arrays.toString(calendar.get(Calendar.DATE).toArray()));


    SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd");
    String date = dFormat.format(jDateChooser1.getDate()); 
    DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
    //model.addRow(new Object[]{calendar});

     //model.addRow(new Object[]{calendar.get(Calendar.MONTH)+"/"+calendar.get(Calendar.DATE)});  
     model.addColumn(new Object[]{calendar.get(Calendar.MONTH)+"/"+calendar.get(Calendar.DATE)});
    }
bcdiss
  • 1

1 Answers1

0

You can try by putting as a row like : model.addRow(); and by this method pass the String array with all column values.

Please refer the link: What is the easiest way to display the contents of an ArrayList of Objects in a JTable?

Community
  • 1
  • 1
Arindam
  • 555
  • 1
  • 8
  • 24
  • no i'm trying to print date and month value to colum vice.(like topics of each coloum) not all value to a single colum thats why i use model.addColumn() function.... – bcdiss Mar 30 '17 at 06:01
  • You should be able to do by following way: model.addRow(new Object[]{calendar.get(Calendar.MONTH)+"/"+calendar.get(Calendar.DATE)}); but looks like you are printing object. Could you please also provide the screenshot of the screen how does it look like? – Arindam Mar 30 '17 at 06:15
  • model.addRow() works fine... i need to do using model.addColumn() function arrording to my requirement – bcdiss Mar 30 '17 at 06:36
  • model.addRow() works fine... i need to do using model.addColumn() function arrording to my requirement – bcdiss Mar 30 '17 at 06:44