aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Graphical compare of two text files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Graphical compare of two text files" Watch "Graphical compare of two text files" New topic
Author

Graphical compare of two text files

beda meda
Greenhorn

Joined: Jul 15, 2010
Posts: 6
Hi all,

I have a task of creating GUI comparator of two text files, something like WinMerge or the function in Total Commander. And what I'm looking for here is not any source code or anything like that, but some hints where to look for inspiration, some starting tips, etc. I never did anything like this before and I'm little confussed about where to start, if you can understand what I mean. I'll appreciate anything, hints, links, whatever you can think of.

Thanks.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1089
    
  10

NetBeans RCP (Rich Client Platform) has a Diff API and a DiffView which shows the difference graphically. But, this is part of the NetBeans platform and you would have to create a NetBeans platform application to use it.

Nevertheless, as you were looking for inspiration, I wanted to post this.

Also, the whole NetBeans platform is built on top of standard Swing components. So, that is itself an inspiration.

And the API is logically divided into 2 parts. First is the actual Diff API - this basically calculates the differences between 2 streams and stores the differences (in a class named, well, Difference). So, the diff calculating method returns an array of Difference (one Difference object for each difference). The difference here is calculated comparing lines. This can be used from a normal program without any GUI - say if you want to print the differences textually - like when we work with some version control systems. So, you will first have to develop something like that.

The DiffView is separate. This is a JPanel which then takes in the needed stuff (like the Difference[]) and then show the differences using colors. Same way, you can build the GUI separately which will then use the initial API you developed.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
 
Consider Paul's rocket mass heater.
 
subject: Graphical compare of two text files