Problems comparing two Floats

Hello all,
I keep getting exceptions using the code for a table cell renderer listed below.
Basically, the program blows up whenever the renderer is asked to compare two floats.
Two string values, a string and a float, it does not have the desired effect, but a least it runs.
"     public Object[][] aaTableValues = {
          { new Float( 700.00 ), new Float( 300.00 ), new Float( 400.00 ), "Fred", "Snead", "inform", "detail" },
          { new Float( 1000.00 ), new Float( 200.00 ), new Float( 800.00 ), "Jane", "Smith", "limit", "detail" },
          { new Float( 500.00 ), new Float( 200.00 ), new Float( 300.00 ), "Mary", "Ellis", "inform", "detail" },
          table1.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
            public Component getTableCellRendererComponent(JTable table,
                                                    Object value,
                                                    boolean isSelected,
                                                    boolean hasFocus,
                                                    int row,
                                                    int column) {
                super.getTableCellRendererComponent(table, value, isSelected,
                        hasFocus, row, column);
                // Prepare default color        
                Color color = isSelected ? table.getSelectionForeground(): table.getForeground();
                if (column == 1) {
                    float val1 = 0.0F;
                        val1 = ((Float)value).floatValue();
                    float val2 = ((Float)table.getValueAt(row, column - 1)).floatValue();
                    if( val1 > val2) {
                        color = isSelected ? Color.red.brighter() : Color.red;
                setForeground(color);
                return this;
        });I get the runtime exceptions like the following:
"Caught exception updating ExitableJFrame[frame0,0,0,618x430,invalid,layout=java.awt.BorderLayout,resizable,title=AccountActivityTable,defaultCloseOperation=,rootPane=javax.swing.JRootPane[,0,0,618x430,invalid,layout=javax.swing.JRootPane$RootLayout,alignmentX=null,alignmentY=null,border=,flags=2,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true,EXIT_ON_CLOSE]:
java.lang.NullPointerException
     at FloatRenderer.getTableCellRendererComponent(Compiled Code)
     at javax.swing.JTable.prepareRenderer(JTable.java:2897)
     at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:968)
     at javax.swing.plaf.basic.BasicTableUI.paintRow(BasicTableUI.java:899)
     at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:811)
     at javax.swing.plaf.ComponentUI.update(ComponentUI.java:43)
Does anyone know how to fix this?

If you look again at the error message, you'll see it's a NullPointerException. You are using a null reference. Nothing at all to do with comparing two float values. I'd guess that "table.getValueAt(row, column - 1)" is returning null, but it's hard to tell without a line number. You need to do some debugging in that code to see where you are using the null reference.

Similar Messages

  • VORowImpl problem - comparing two ROW[] lists

    Hi Everyone,
    I have a huge proble right now, I'm trying to compare two VO list with the same values, this is because one it's attached to an advancedtable in the xml page wich the user can change some values, and the other one is from the values of the table but from the DB, the reason is to made a validation to compare the original values from the DB with the list from the tabla and update only the rows that the users made changes in their values, here's my code for a better explain of what I'm doing:
    public void saveChanges(){
    OADBTransactionImpl oadbtransactionimpl = (OADBTransactionImpl)getDBTransaction();
    Row[] rows1 = getAppVO1().getAllRowsInRange();
    Row[] rows2 = getDBVO1().getAllRowsInRange();
    for(int i = 0; i < rows1.length; i++){
    int j = i;
    //Colections to compare
    //r1: colection from the app
    //r2: colection from BD
    AppVORowImpl r1 = (AppVORowImpl) rows1;
    DBVORowImpl r2 = (DBVORowImpl) rows2[j]; //<--- here in the second iteration appears the following error:
    // "oracle.apps.fnd.framework.OAException: java.lang.ArrayIndexOutOfBoundsException: 1"
    //variables string to check if got changes in the column
    String columnAPP = r1.getId().toString();
    String columnBD = r2.getId().toString();
    //'if' that validates changes
    if(!columnAPP.equals(columnBD)){
    //String variable SP
    StringBuilder procedureCall = new StringBuilder();
    //calling to SP
    try{
    procedureCall.append("... stored proc...");
    OracleCallableStatement oraclecallablestatement = (OracleCallableStatement)oadbtransactionimpl.createCallableStatement(procedureCall.toString(), -1);
    oraclecallablestatement.execute();
    getOADBTransaction().commit();
    }catch(SQLException sqlexception){
    System.err.println("SQL Exception: "+ sqlexception.getMessage());
    getOADBTransaction().rollback();
    throw OAException.wrapperException(sqlexception);
    }catch(Exception e){
    System.err.println("Exception: "+ e.getMessage());
    getOADBTransaction().rollback();
    throw OAException.wrapperException(e);
    the first iteration works fine, but the second and futher shows an exception error, what can I do to make this method works?
    I'll be pending to your answers, I really hope you can help me with this one
    Regards,
    Mentor

    Here is the dump code for you. Code you have to write in AmImpl and call the same from Controller class.
    AMImpl Code
    public void executeBothViewObjects() //Calls this method from Controller *ProcessRequest*
            OAViewObject vo = (OAViewObject)getMainViewObjectVO1();
            OAViewObject dvo = (OAViewObject)getDBViewObjectVO1();
           if (vo != null && dvo != null)
                         //1st VO
                           dvo.setWhereClauseParams(null);
                          //Set where clause if Any  dvo.setWhereClauseParam(0,xx);
                          dvo.executeQuery();  
                         //2nd VO
                         vo.setWhereClauseParams(null);
                          //Set where clause if Any  dvo.setWhereClauseParam(0,xx);
                         vo.executeQuery(); 
    public void compareViewObject()   // Calling this method to compare Attribute of both View Object *Process Form Request*
          OAViewObject vo = getMainViewObjectVO1();
          OAViewObject OrigVO = getDBViewObjectVO1();
          MainViewObjectVORowImpl rowi = null;
          DBViewObjectVORowImpl rowii = null;
          int fetchedRowCount = vo.getRowCount();
          int OriginalfetchedRowCount = OrigVO.getRowCount();  
         RowSetIterator originalSelectIter = OrigVO.createRowSetIterator("originalSelectIter");
         RowSetIterator selectIter = vo.createRowSetIterator("selectIter");
         if (fetchedRowCount > 0 && OriginalfetchedRowCount >0)
              selectIter.setRangeStart(0);
              selectIter.setRangeSize(fetchedRowCount);
              originalSelectIter.setRangeStart(0);
              originalSelectIter.setRangeSize(OriginalfetchedRowCount);
              for (int i = 0; i < fetchedRowCount; i++)
                rowi = (MainViewObjectVORowImpl)selectIter.getRowAtRangeIndex(i);
                rowii = (DBViewObjectVORowImpl)originalSelectIter.getRowAtRangeIndex(i);
               //Compare Attribute here
                   if((!(rowi.getRoleStartDate().equals(rowii.getRoleStartDate()))
                            // Comparing Start date here of both View Object
                 else if(((rowi.getRoleEndDate().equals(rowii.getRoleEndDate()))
                       // Comparing End date here of both View Object
    }Thanks
    --Anil
    http://oracleanil.blogspot.com/

  • Problem comparing two ArrayLists, elements must match, order not important.

    Hello,
    I am new to Java and my assignment is:
    Write a method for the Purse class - public boolean sameCoins(Purse other), that checks whether the other purse has the same coins, perhaps in a different order.
    For example, the purses:
    *Purse[Quarter,Dime,Nickel,Dime]*
    and
    *Purse [Nickel,Dime,Dime,Quarter]*
    should be considered equal.
    You will probably need one or more helper methods.
    I was able to make a method to check if the purses match(sameContents), but I have not been able to check if they match just based on elements(sameCoins). We are not using Collections.
    Below is my Purse Class:
    import java.util.ArrayList;
    public class Purse {
        private ArrayList<String> coins;
        public Purse() {
            coins = new ArrayList<String>();
        public void addCoin(String coinName) {
            coins.add(coinName);
        public String toString() {
            String text = "Purse[ ";
            for (String a : coins)
                text += a;
            text += "]";
            return text;
        public boolean sameContents(Purse other) {
            boolean content = false;
            if (other.coins.equals(coins))
                content = true;
            return content;
        public boolean sameCoins(Purse other){
            boolean samecoins = true;
            for(String a: coins)
                for(String b: other.coins)
                    if (a.contains(b))
                        samecoins = true;
                    else
                        samecoins=false;
            return samecoins;
    }Any help would be appreciated.

    tipalm wrote:
    Well then my prof cant hold it against me can he!He sure can, if he wants to. I'll bet you 30 duke stars that if you hand in the program as-is and try to argue for using the Collections framework, he's going to say "I meant you couldn't use any of the static methods in the Collections framework, the whole point of the assignment was to work through the logic of iterating through the Lists" But hey, it's not my assignment, so good luck!
    Edit- I'm not saying that using the Collections framework (and its myriad static methods) is bad in any way. It's actually what you should use, assuming there are no academic "but don't use this shortcut" rules being applied. I just doubt that's your case here. I'd recommend looking into how the Collections framework works, and then implement your own algorithm based on that.
    Edited by: kevinaworkman on Oct 29, 2009 10:13 AM

  • How to compare two files in java & uncommon text should print in text file.

    Hi,
    Can any one help me to write Core java program for this.
    How to compare two files in java & uncommon text should print in other text file.
    thanks
    Sam

    Hi All,
    i m comparing two HTML file.. thats why i am getting problem..
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class textmatch{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
    BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
    String s;
    String y;
    while ((s=fh.readLine())!=null)
    if ( s.equals(y=sh.readLine()) ){    
    System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
    sh.close();
    fh.close(); }
    thanks
    Sam

  • How to compare two files in Java & uncommon text should print in Diff text

    Hi All,
    can any one help me to write a java program..
    How to compare two files in Java & uncommon text should print in Diff text file..
    Thanks
    Sam

    Hi All,
    i m comparing two HTML file.. thats why i am getting problem..
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class textmatch{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
    BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
    String s;
    String y;
    while ((s=fh.readLine())!=null)
    if ( s.equals(y=sh.readLine()) ){    
    System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
    sh.close();
    fh.close(); }
    thanks
    Sam

  • Compare two records within a view

    Hi,
    I wonder if it is possible to compare two or more records within a view, and how to do it.
    Thanks in advance.

    M. Comi wrote:
    I wanted to compare two records of the view and see if they are the same or not...
    My data are as follows:
    Soglia Ingresso_CL_PF     10     10
    Downgrade MDP 3     2102     2101
    I want to check if the "downgrade" records have the same values for the second and the third column, and in this case replace the values on the second record.
    But I did it with a select on the same fields of the original tables, plus two fields obtained with lag function...
    I don't know if it is clear or not, the important is that I got what I wanted.Sorry, it's not clear.
    Are you still having a problem? If so:
    (1) Please describe the problem.
    (2) What results do you want to see from the sample data you posted?
    (3) Is the second column of
    Downgrade MDP 3 2102 2101'Downgrade', 'MDP', 3, 2102, 2101, some combination, or NULL? When posting data, the most helpful thing is to post INSERT (or CREATE TABLE AS ...) statements. The second-best thing is to post formatted data. Type &#123;code&#125; before and after sections where spacing is important, and post column headers.

  • How do we compare two images in labview?

    I have created a back end code which is comparing two images using LABVIEW.i have used a comparator and put a tolerance factor which will help me filter out almost same images.the problem i am facing is that on subtraction of the given two images i am getting a completely random output with noise surrounding the parts of the image which are being compared.Also the tolerance percentage i have given has not been working very effectively.Kindly let me know if there is an easier solution to my task or what needs to be done
    Thank you

    Can you post your code?
    Randall Pursley

  • Compare two secured PDF documents

    Hi,
    I am using a licensed version of Adobe acrobat 11.0 professional. I have a requirement of comparing two secured PDF documents (which have the lock symbol displayed). But, the 'compare documents' option does not allow comparing two Secured PDFs. It gives a message 'This operation is not permitted'. Is there a way I can compare them ?
    Earlier, I was using the version 5.0 in which we can compare secured documents without any problem.

    Actually, its asking for a password when i tried to do that. So, is there a way to do it through the acrobat 11.0 tool itself ? (This feature of comparing secured documents was present in the versions 5.0 & 6.0. But, in later versions, it was removed)

  • Comparing two pdf

    Hi All,
    I have compared two pdf files using below method
    DigSigCompareWords
    (docA, docB, true);
    The report will be generated as document A document B where i'm seeing
    all the compare words and matched text.
    But i need to get  the consolidated report like the one i'm getting from adobe acrobat XI professional compare document with text only.
    Any help will be appreciated.

    Thanks Irosenth.
    I have another problem i have sucecssfully compare two documents but i couldn't able to save 3rd document if i use activedocument to copy to pddoc and save also its not saving.
    Please suggest ideas.
    Note:
    i have read all the forums releated to this that all the user expect this feature[comparison] as automation from 2010 stil not available in sdk XI,X.

  • Compare two XML files: Analysis and Design

    Hi, Java/XML/JDOM experts,
    I realised that an open source of Java utility to compare two XML is still missing. So I would like to write one for my JDOM excises.
    I plan to do it in three steps:
    1.Define the problem domain.
    2.Design the classes to be developed.
    3.Coding
    Below is the problem domain. Would you review it and tell me if it is fine?
    Best regards,
    AG
    Compare two XML files
    Schema assumption:
    The xml files used for the comparison must have the same schema.
    Definition:
    1. Two elements of simple type are said equal if their name and value are identical.
    2. Two elements of complex type are said comparable if their name, attributes are identical.
    3. Two elements of complex type are said equal if they are comparable and their children elements are identical.

    Hi,
    Thanks for reviewing my idea.
    The xml files used for the comparison must have the
    same schema.Including not having a schema at all? And if they do
    have a schema, must they be valid according to the
    schema?I will only support schema based xml files. To include a schema is a good practice. So I will valid them agaisnt schema (is this possible with JDOM? I am testing ...)
    >
    2. Two elements of complex type are said comparableif
    their name, attributes are identical.
    3. Two elements of complex type are said equal ifthey
    are comparable and their children elements are
    identical.Do you plan to require child elements to appear in the
    same order for the two documents to be equal? (Note
    that XML specifically says that the order of
    attributes is not significant.)No. The order is not significant as I use the attributes as the keys to find comparable element counterpart.
    Here is the sample code already tested. Any comments are welcome!
    The next step is to define the "delta xml schema" that will guide me to store the comparasion results. Do you have any suggestions?
    Regards.
    AG
    public static boolean comparable(Element element1, Element element2)
         boolean returnValue=false;
         if (element1.getName()!=element2.getName()) {
              return returnValue;
    } else {
              returnValue=true;
                        System.out.println ("place 2");
         List attributeList=element1.getAttributes();
         Iterator attributeIterator=attributeList.iterator();
         Attribute workingAttribute=null;
         while (attributeIterator.hasNext()) {
                             if (!workingAttribute.getValue().equals(
                             element2.getAttribute(workingAttribute.getName(), workingAttribute.getNamespace()).getValue()))
                                  returnValue=false;
                                  break;
         return returnValue;

  • Problems with the floating lens.

    Hello Nokia,
    My Lumia 920 has a very wierd problem with the floating lens. When I tilt the device up it blurrs the image for a sec or two and it makes a squirk sound which also records on the footage.
    Here is a video made with my Lumia 920.
    http://youtu.be/jlzzOBlAT6Q
    I sent my phone for a replacement, but I just wanted to let you know that this could happen and maybe stimulate those little chinese people in your factories to do a better job.

    Hello Nokia,
    My Lumia 920 has a very wierd problem with the floating lens. When I tilt the device up it blurrs the image for a sec or two and it makes a squirk sound which also records on the footage.
    Here is a video made with my Lumia 920.
    http://youtu.be/jlzzOBlAT6Q
    I sent my phone for a replacement, but I just wanted to let you know that this could happen and maybe stimulate those little chinese people in your factories to do a better job.

  • Compare two pulse counts

    Hello,
    I'm trying to compare two simultaneous pulse counts using a cDAQ-9172 chassis, a 9401 card, and LabVIEW 8.2. What I want to do is set up a single output pulse that lasts for, say, 1000 incoming pulses on ctr0, and then use that single output pulse as a gate on ctr1 to count the input pulses that it sees during those 1000 pulses on ctr0. In other words, I want to synchronize the two counters, and as soon as ctr0 reaches 1000 pulses, they should both stop so I can compare the two counts. The issue is slightly complicated by the fact that both counter inputs are very noisy and require a pulse width filter in order to be read properly.
    I more or less understand what needs to happen conceptually, but I'm at a loss for how to make it happen. A simple walkthrough would help enormously. Alternatively, if there's a better way to accomplish this, that would be helpful as well.
    Thanks.

    Thanks for the advice. I set up a program (attached) that tries to implement basically what you suggest, but there are still problems. The main issue is that it gives me an error -200141 message telling me to change the data transfer mechanism to DMA. When I set up a channel property node to do this, it tells me that DMA is not available.
    The other concern I have involves the pulse width filter on the counter output task. The 1000 pulse signal is extremely noisy, and without any filtering, the noise will increase the frequency by a significant amount. I've set up the filters as you can see in the program, but I have no idea whether I've done this properly.
    Any further help you could offer would be greatly appreciated.
    Attachments:
    even more gating.vi ‏39 KB

  • How can compare two xml files.........

    Hi developers..........
    I have a problem in compare two xml files.My project description is I take two xml(file1,file2) files.Compare file1 with file2. Now I want what are the same words in to the file2.
    file1:
    <hello>
    <html>
    <jsp:plugin>
    file2:
    <hello>
    <jsp:usebean>
    <html>
    result:
    <hello>
    any give the code for this logic.....

    hi...can u pls send me the code which compares two
    xml files and gives the output as difference between
    two fileshttp://www.bmsi.com/java/#diff

  • How to compare two libraries

    I recently bought a 17-inch MBP to replace my old WindTunnel G4 as my primary machine. (The G4 will still be in service as a server.) I'm in the process of bringing my iTunes library over to the MBP, a process that has been made much easier by Home Sharing in iTunes 9. Thank you, Apple, for this feature!
    My question is, when I connect to the shared library, iTunes on the MBP shows 41 fewer tracks than iTunes on the G4 shows. With nearly 200GB of music (over 40,000 tracks) in my library, manually comparing the two libraries to determine which tracks are missing would be an exercise in boredom and futility. Is there any automated way, any software, that I can use to compare the contents of the two libraries so I can locate the missing tracks and figure out what's wrong with them? I'm not averse to using Terminal if that's going to be the most straightforward way to do it.

    I am in the same boat as you are Mark. I only have about 88G and 16,000 tracks of music (that does not include any video), and in trying to manually compare two libraries from directory listings by hand is not the way to do things. I am also thinking that creating some output listings for the directory is the solution, but the directory structure is not the same, and would require some level of automation for dumping the differences. I am a tad rusty at my unix scripting to say the least, but I guess I could pull out some of the old reference books. Even if a properly specified ls command could give an output format to pull into an excel file? and then be able to do the diff there with some small tweaking ? I've gotten myself into a bit of a mess with this (nothing that can not be resolved with some careful cleanup), but I don't want to have to rebuild another new library from my old master if I could do a diff between the two, so I can add the remaining 10G (estimated) that is missing in the new library.
    Hopefully by replying to your thread someone else will spot this and can give an assist.
    I am missing a lot more than 41 tracks, I am guessing a few hundred (200 - 300 plus?).
    One place to check on the old library is in the unknown folders? (unknown album or unknown artist?) and also to check under what is labeled as a compilations folder.
    I think what created part of my problem is that I suspect the new directory structure (part of the new iTunes version) placed on top of the old directory structure (prior iTunes versions - when the orig library was created back in 2003 and then moved to an external device) was something I did not clearly understand or investigate sufficiently prior to starting to move things around. I have not lost anything (i.e. the physical files are all still there in the old master, along with a backup), but certainly the new master is not in full synch with the old master.
    I would have preferred to be far less cognizant of some of these things, but as this exercise continues some of this gets unearthed.

  • I want to compare two programs ....

    actually i have a requirement where in i have to compare two programs and have to sight the difference line by line....
    so guys please help me out with this ....is their any tool which will solve the problem for me
    thanks in advance
    rajeev

    hi Rajeev,
    SE39 allows you to compare 2 programs.
    if u find it useful mark the points
    ~~guduri

Maybe you are looking for