Results 1 to 3 of 3
  1. #1
    maddy14 is offline Member
    Join Date
    May 2013
    Posts
    25
    Blog Entries
    1
    Rep Power
    0

    Default PreapareRenderer doesnt give proper row and column numbers

    I have a code like this :
    Java Code:
    table = new JTable(){
    			MarketWatchValues mktvalues = null;
    			public Component prepareRenderer(TableCellRenderer renderer, int index_row, int index_col){
    				Component comp = super.prepareRenderer(renderer, index_row, index_col);
    				
    				int row = index_row;
    				int col=index_col;
    
    				System.out.println("First value of row "+row+" "+col);
    			if(null!=table && null!=defTableModel && table.getModel().equals(defTableModel))
    			{
    			if(null!=table.getModel().getValueAt(row,col))
    				{
    				System.out.println("Value of row and col "+row +" "+col);
    				
    				if( marketwatchHashMap.containsKey(table.getModel().getValueAt(row, col)))
    				{
    					mktvalues = (MarketWatchValues) marketwatchHashMap.get(table.getModel().getValueAt(row, col));
    					System.out.println("MarketWatchValue previous bid and next bid"+mktvalues.prevBidQty+" "+mktvalues.bidQty);
    				}
    				if(null!=mktvalues && col==14 && (mktvalues.getPrevBidQty() < mktvalues.getBidQty()))
    				{
    					System.out.println("SETING COLOR GREEN");
    					comp.setBackground(Color.green);
    				}
    				else{
    					System.out.println("Inside else ..."+row+" "+col);
    					comp.setBackground(Color.white);
    				}
    				
    				}
    				
    			}	
    				return comp;
    			}
    		};
    Output:
    Java Code:
    First value of row 1 3
    Value of row and col 1 3
    Inside else ...1 3
    First value of row 1 4
    First value of row 1 5
    First value of row 1 6
    First value of row 1 7
    First value of row 1 8
    First value of row 1 9
    Value of row and col 1 9
    Inside else ...1 9
    First value of row 1 10
    Value of row and col 1 10
    Inside else ...1 10
    First value of row 1 11
    Value of row and col 1 11
    Inside else ...1 11
    First value of row 1 12
    Value of row and col 1 12
    Inside else ...1 12
    First value of row 1 13
    Value of row and col 1 13
    Inside else ...1 13
    First value of row 2 0
    First value of row 2 1
    Value of row and col 2 1
    Inside else ...2 1
    First value of row 2 2
    Value of row and col 2 2
    MarketWatchValue previous bid and next bid0.0 118.0
    Inside else ...2 2
    First value of row 2 3
    The output which it produces is random..i dont understand why dont i get proper row and column values in the output.Any help will be highly appreciated.Thanks for your time
    Last edited by maddy14; 11-13-2013 at 05:20 AM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,598
    Rep Power
    5

    Default Re: PreapareRenderer doesnt give proper row and column numbers

    Please provide a Short, Self Contained, Correct Example which demonstrates the problem. Since you are concerned only about rows and columns, the above code from line 12 on is not necessary (except for return value of course).

    Regards,
    Jim
    Last edited by jim829; 11-12-2013 at 02:02 PM.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    maddy14 is offline Member
    Join Date
    May 2013
    Posts
    25
    Blog Entries
    1
    Rep Power
    0

    Default Re: PreapareRenderer doesnt give proper row and column numbers

    Thanks for pointing out the mistake.The code was really looking lengthy.Done with editing some of its part

Similar Threads

  1. Replies: 0
    Last Post: 10-18-2013, 06:03 PM
  2. Replies: 0
    Last Post: 01-17-2013, 12:43 PM
  3. Applet doesnt start or it doesnt show
    By 3dprogger in forum Java Applets
    Replies: 2
    Last Post: 01-07-2011, 07:03 PM
  4. Replies: 7
    Last Post: 09-28-2010, 12:17 AM
  5. JTable format numbers in column
    By mine0926 in forum NetBeans
    Replies: 7
    Last Post: 06-07-2010, 05:10 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •