SwingUtilities.invokeLater(new Runnable() { public void run() { cbFrame.requestFocus(); System.out.println("Focus requested"); } });
    private void buildFrame() {        try {            try {                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());            } catch (Exception e) {            }            cbFrame = new JFrame("FS ComparaBrowser");            final JFrame frame = cbFrame;            frame.setExtendedState(JFrame.NORMAL);            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);            SwingUtilities.invokeLater(new Runnable() {                public void run() {                    geckoBrowser = new WebBrowser();                    geckoBrowser.setSize(new Dimension(0, 0));                    geckoBrowser.addWebBrowserListener(                            new WebBrowserListener() {                                boolean isFirstPage = true;                                public void downloadStarted(WebBrowserEvent event) {                                    XRLog.load("JDIC: browser loading " + event.getData());                                }                                public void downloadCompleted(WebBrowserEvent event) {                                }                                public void downloadProgress(WebBrowserEvent event) {                                    ;                                }                                public void downloadError(WebBrowserEvent event) {                                    ;                                }                                public void documentCompleted(WebBrowserEvent event) {                                }                                public void titleChange(WebBrowserEvent event) {                                    frame.setTitle(event.getData());                                }                                public void statusTextChange(WebBrowserEvent event) {                                    ;                                }                            });                    final JScrollPane gscroll = new JScrollPane(geckoBrowser);                    gscroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);                    //gscroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);                    gscroll.addComponentListener(new ComponentAdapter() {                        public void componentResized(ComponentEvent e) {                            geckoBrowser.setSize(gscroll.getSize());                        }                    });                    JPanel gPanel = new JPanel();                    gPanel.setLayout(new BorderLayout());                    gPanel.setPreferredSize(new Dimension(0, 0));                    gPanel.add(gscroll, BorderLayout.CENTER);                    html = new XHTMLPanel();                    html.setLayoutInProgressMsg("");                    html.setAntiAliased(false);                    FSScrollPane fspane = new FSScrollPane(html);                    fspane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);                    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, fspane, gPanel);                    splitPane.setDividerLocation(0.5D);                    splitPane.setDividerSize(5);                    splitPane.setResizeWeight(.5);                    splitPane.setContinuousLayout(false);                    splitPane.setOpaque(true);                    frame.getContentPane().add(splitPane);                    frame.pack();                    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);                    frame.setVisible(true);                    frame.addComponentListener(new ComponentAdapter() {                        public void componentResized(ComponentEvent e) {                            html.relayout();                        }                    });                    nextDemoAction = new NextDemoAction();                    reloadPageAction = new ReloadPageAction();                    chooseDemoAction = new ChooseDemoAction();                    growAction = new GrowAction();                    shrinkAction = new ShrinkAction();                    increase_font = new FontSizeAction(FontSizeAction.INCREMENT, KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_MASK));                    reset_font = new FontSizeAction(FontSizeAction.RESET, KeyStroke.getKeyStroke(KeyEvent.VK_0, InputEvent.CTRL_MASK));                    decrease_font = new FontSizeAction(FontSizeAction.DECREMENT, KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK));                    reloadFileList = new ReloadFileListAction();                    showGrid = new ShowGridAction();                    showHelp = new ShowHelpAction();                    frame.setJMenuBar(new JMenuBar());                    JMenu doMenu = new JMenu("Do");                    doMenu.add(new JMenuItem(reloadPageAction));                    doMenu.add(new JMenuItem(nextDemoAction));                    doMenu.add(new JMenuItem(chooseDemoAction));                    doMenu.add(new JMenuItem(growAction));                    doMenu.add(new JMenuItem(shrinkAction));                    doMenu.add(new JMenuItem(increase_font));                    doMenu.add(new JMenuItem(reset_font));                    doMenu.add(new JMenuItem(decrease_font));                    doMenu.add(new JMenuItem(showGrid));                    doMenu.add(new JMenuItem(reloadFileList));                    doMenu.add(new JMenuItem(showHelp));                    doMenu.setVisible(true);                    frame.getJMenuBar().add(doMenu);                }            });        } catch (Exception ex) {            ex.printStackTrace();        }    }