From an action or wherever you like you can call this:

 public void diff(final StreamSource local, final StreamSource remote){
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    DiffView view = Diff.getDefault().createDiff(local, remote);
                } catch (IOException ex) {

    public void showDiff(final DiffView view){
        SwingUtilities.invokeLater (new Runnable() {
            public void run() {
                //create our panel with our view
                //right now I am just going to use the diff component instead of a panel
                //create a top component with our panel
                DiffTopComponent tc = new DiffTopComponent(view);
                tc.setDisplayName("Some display name");

 Here is a top component to display it:

 public class DiffTopComponent extends TopComponent{

    /** Creates a new instance of DiffTopComponent */
    public DiffTopComponent(Component diffPanel) {
        setLayout(new BorderLayout());
        add(diffPanel, BorderLayout.CENTER);

getAccessibleContext().setAccessibleName(NbBundle.getMessage(DiffTopComponent.class ,
"ACSN_Diff_Top_Component")); // NOI18N

"ACSD_Diff_Top_Component")); // NOI18N

    public DiffTopComponent(DiffView view) {

    public int getPersistenceType(){
        return TopComponent.PERSISTENCE_NEVER;

    protected String preferredID(){
        return "DiffTopComponent";    //NOI18N

    public HelpCtx getHelpCtx() {
        return new HelpCtx(getClass());