Using v 1.6.1
OS: Windows 7
If I change the DockingWindowExamples as described below, the focus request works for floating windows and the static windows, but does not work for newly added dynamic windows. I think this has to do with the optimizeAfter logic. Is there a way to get around this?
..
static Component nextFocusItem;
..
createLayoutMenu()
...
layoutMenu.addSeparator();
layoutMenu.add("Add new").addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
rootWindow.getWindow().split(getDynamicView(getDynamicViewId()), Direction.DOWN, 0.6f);
}
});
...
createViewComponent(String text)
...
JTextArea txtArea = new JTextArea(sb.toString());
nextFocusItem = txtArea;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run()
{
if(null != nextFocusItem)
nextFocusItem.requestFocusInWindow();
System.out.println("DWE.createViewComponent(): The focus event was just triggered. ");
}
});
return new JScrollPane(txtArea);
}
After reviewing the InfoNode code more, I found a solution, or hack, for this issue. When the new View is created and visible set to true, try the code below. I found that I must have two invokeLater calls. One was not enough to postpone the focus request.
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
//request focus to item here.
comp.requestFocusInWindow();
}
});
}
});
Please note: I am writing this code by memory. There might be a few typos, but it should provide a general idea.