Issue
I'm developing an application based on netbeans platform, and I'm reusing the diff component. I have the next code:
panel = new javax.swing.JPanel();
panel.setLayout(new java.awt.BorderLayout());
DiffView view = Diff.getDefault().createDiff(original, processed);
panel.add(view.getComponent(), BorderLayout.CENTER);
But the Diff component its not added to the panel. If I add another panel instead of the Diff component it works. At the same time if I use the next code:
DiffView view = Diff.getDefault().createDiff(original, processed);
TopComponent tc = new TopComponent();
tc.setDisplayName("Diff Viewer");
tc.setLayout(new BorderLayout());
tc.add(view.getComponent(), BorderLayout.CENTER);
tc.open();
tc.requestActive();
It works but shows the component in another window, which its not what I want to do.
What is wrong with my code and how can I add the Diff component to the panel?
Solution
after adding DiffView to the panel, call below code to resolve the problem
panel.revalidate();
//or
panel.repaint();
Answered By - Mehdi Varse
Answer Checked By - Robin (JavaFixing Admin)