Example usage for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW

List of usage examples for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW

Introduction

In this page you can find the example usage for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW.

Prototype

int WHEN_IN_FOCUSED_WINDOW

To view the source code for javax.swing JComponent WHEN_IN_FOCUSED_WINDOW.

Click Source Link

Document

Constant used for registerKeyboardAction that means that the command should be invoked when the receiving component is in the window that has the focus or is itself the focused component.

Usage

From source file:org.languagetool.gui.Main.java

private void tagTextAndDisplayResults() {
    JLanguageTool langTool = ltSupport.getLanguageTool();
    // tag text//from   w ww . j  a  va 2s  .c o  m
    List<String> sentences = langTool.sentenceTokenize(textArea.getText());
    StringBuilder sb = new StringBuilder();
    if (taggerShowsDisambigLog) {
        sb.append("<table>");
        sb.append("<tr>");
        sb.append("<td><b>");
        sb.append(messages.getString("token"));
        sb.append("</b></td>");
        sb.append("<td><b>");
        sb.append(messages.getString("disambiguatorLog"));
        sb.append("</b></td>");
        sb.append("</tr>");
        boolean odd = true;
        try {
            for (String sent : sentences) {
                AnalyzedSentence analyzed = langTool.getAnalyzedSentence(sent);
                odd = appendTagsWithDisambigLog(sb, analyzed, odd);
            }
        } catch (Exception e) {
            sb.append(getStackTraceAsHtml(e));
        }
        sb.append("</table>");
    } else {
        try {
            for (String sent : sentences) {
                AnalyzedSentence analyzed = langTool.getAnalyzedSentence(sent);
                String analyzedString = StringTools.escapeHTML(analyzed.toString(","))
                        .replace("&lt;S&gt;", "&lt;S&gt;<br>").replace("[", "<font color='" + TAG_COLOR + "'>[")
                        .replace("]", "]</font><br>");
                sb.append(analyzedString).append('\n');
            }
        } catch (Exception e) {
            sb.append(getStackTraceAsHtml(e));
        }
    }
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (taggerDialog == null) {
                taggerDialog = new JDialog(frame);
                taggerDialog.setTitle(messages.getString("taggerWindowTitle"));
                taggerDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
                taggerDialog.setResizable(true);
                taggerDialog.setSize(640, 480);
                taggerDialog.setLocationRelativeTo(frame);
                KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
                ActionListener actionListener = actionEvent -> taggerDialog.setVisible(false);
                taggerDialog.getRootPane().registerKeyboardAction(actionListener, stroke,
                        JComponent.WHEN_IN_FOCUSED_WINDOW);
                JPanel panel = new JPanel(new GridBagLayout());
                taggerDialog.add(panel);
                taggerArea = new JTextPane();
                taggerArea.setContentType("text/html");
                taggerArea.setEditable(false);
                GridBagConstraints c = new GridBagConstraints();
                c.gridx = 0;
                c.gridwidth = 2;
                c.gridy = 0;
                c.weightx = 1.0;
                c.weighty = 1.0;
                c.insets = new Insets(8, 8, 4, 8);
                c.fill = GridBagConstraints.BOTH;
                panel.add(new JScrollPane(taggerArea), c);
                c.gridwidth = 1;
                c.gridx = 0;
                c.gridy = 1;
                c.weightx = 0.0;
                c.weighty = 0.0;
                c.insets = new Insets(4, 8, 8, 8);
                c.fill = GridBagConstraints.NONE;
                c.anchor = GridBagConstraints.EAST;
                JCheckBox showDisAmbig = new JCheckBox(messages.getString("ShowDisambiguatorLog"));
                showDisAmbig.setSelected(taggerShowsDisambigLog);
                showDisAmbig.addItemListener((ItemEvent e) -> {
                    taggerShowsDisambigLog = e.getStateChange() == ItemEvent.SELECTED;
                    ltSupport.getConfig().setTaggerShowsDisambigLog(taggerShowsDisambigLog);
                });
                panel.add(showDisAmbig, c);
                c.gridx = 1;
                JButton closeButton = new JButton(messages.getString("guiCloseButton"));
                closeButton.addActionListener(actionListener);
                panel.add(closeButton, c);
            }
            // orientation each time should be set as language may is changed
            taggerDialog.applyComponentOrientation(
                    ComponentOrientation.getOrientation(languageBox.getSelectedLanguage().getLocale()));

            taggerDialog.setVisible(true);
            taggerArea.setText(HTML_FONT_START + sb + HTML_FONT_END);
        }
    });
}

From source file:org.ngrinder.recorder.ui.AboutDialog.java

private void initKeyStroke() {
    addKeyListener(new KeyAdapter() {
        @Override/*from   www  .j  av a 2s  .  co  m*/
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                dispose();
            }
        }
    });

    JRootPane rootPane = getRootPane();
    rootPane.getActionMap().put("ESCAPE", new AbstractAction() {
        private static final long serialVersionUID = 421791976774749694L;

        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });

    KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(keyStroke, "ESCAPE");
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Adds the close action with escape key.
 * /*from  w ww  . j ava2  s . c  om*/
 * @param dialog
 *            the dialog
 */
public static void addCloseActionWithEscapeKey(final JDialog dialog) {
    //  Handle escape key to close the dialog

    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    Action escapeAction = new AbstractAction() {
        private static final long serialVersionUID = 0L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    };
    dialog.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    dialog.getRootPane().getActionMap().put("ESCAPE", escapeAction);
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Adds the close action with escape key.
 * /*ww w. j  a  v  a 2 s. co  m*/
 * @param frame
 *            the frame
 */
public static void addCloseActionWithEscapeKey(final JFrame frame) {
    //  Handle escape key to close the dialog

    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    Action escapeAction = new AbstractAction() {
        private static final long serialVersionUID = 0L;

        @Override
        public void actionPerformed(ActionEvent e) {
            frame.setVisible(false);
        }
    };
    frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    frame.getRootPane().getActionMap().put("ESCAPE", escapeAction);
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Adds the dispose action with escape key.
 * /*ww  w.ja  v  a2s . c o  m*/
 * @param dialog
 *            the dialog
 */
public static void addDisposeActionWithEscapeKey(final JDialog dialog) {
    //  Handle escape key to close the dialog

    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    Action disposeAction = new AbstractAction() {
        private static final long serialVersionUID = 0L;

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    };
    dialog.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    dialog.getRootPane().getActionMap().put("ESCAPE", disposeAction);
}

From source file:org.notebook.gui.widget.GuiUtils.java

/**
 * Adds the dispose action with escape key.
 * /* w ww.  ja  v  a2 s .  com*/
 * @param frame
 *            the frame
 */
public static void addDisposeActionWithEscapeKey(final JFrame frame) {
    //  Handle escape key to close the dialog

    KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
    Action disposeAction = new AbstractAction() {
        private static final long serialVersionUID = 0L;

        @Override
        public void actionPerformed(ActionEvent e) {
            frame.dispose();
        }
    };
    frame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
    frame.getRootPane().getActionMap().put("ESCAPE", disposeAction);
}

From source file:org.nuclos.client.main.MainController.java

void init() throws CommonPermissionException, BackingStoreException {
    debugFrame = new SwingDebugFrame(this);
    try {/*from   w w  w.  ja v a2  s  . c  o m*/
        // force to load real permission (tp)
        SecurityCache.getInstance().revalidate();

        cmdExecuteRport = createEntityAction(NuclosEntity.REPORTEXECUTION);

        /** @todo this is a workaround - because Main.getMainController() is called to get the user name */
        Main.getInstance().setMainController(this);

        LOG.debug(">>> read user rights...");
        loginController.increaseLoginProgressBar(StartUp.PROGRESS_INIT_SECURITYCACHE);

        if (!getSecurityCache().isActionAllowed(Actions.ACTION_SYSTEMSTART)) {
            throw new CommonPermissionException(getSpringLocaleDelegate().getMessage("MainController.23",
                    "Sie haben nicht das Recht, {0} zu benutzen.",
                    ApplicationProperties.getInstance().getName()));
        }

        loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_ATTRIBUTES);

        // DefaultCollectableEntityProvider.setInstance(NuclosCollectableEntityProvider.getInstance());

        Thread threadGenericObjectMetaDataCache = new Thread("MainController.readMetaData") {

            @Override
            public void run() {
                LOG.debug(">>> read metadata...");
                // GenericObjectMetaDataCache.getInstance();
                SpringApplicationContextHolder.getBean(GenericObjectMetaDataCache.class);
            }
        };

        loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_LOMETA);

        Thread threadSearchFilterCache = new Thread("MainController.readSearchFilter") {

            @Override
            public void run() {
                LOG.debug(">>> read searchfilter...");
                // SearchFilterCache.getInstance();
                SpringApplicationContextHolder.getBean(SearchFilterCache.class);
            }
        };

        loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_SEARCHFILTER);

        Thread threadRuleCache = new Thread("MainController.readRules") {

            @Override
            public void run() {
                LOG.debug(">>> read rules...");
                // RuleCache.getInstance();
                SpringApplicationContextHolder.getBean(RuleCache.class);
            }
        };

        loginController.increaseLoginProgressBar(StartUp.PROGRESS_READ_RULES);

        List<Thread> lstCacheThreads = new ArrayList<Thread>();
        lstCacheThreads.add(threadGenericObjectMetaDataCache);
        lstCacheThreads.add(threadSearchFilterCache);
        lstCacheThreads.add(threadRuleCache);
        threadGenericObjectMetaDataCache.start();
        threadSearchFilterCache.start();
        threadRuleCache.start();

        for (Thread t : lstCacheThreads) {
            try {
                t.join();
            } catch (InterruptedException e) {
                // do noting here
                LOG.warn("MainController: " + e);
            }
        }

        // !!! init messagelisteners here.
        // initialzing chaches in these threads will cause an deadlock situation at realSubscribe in TopicNotificationReceiver. 
        // genericObjectMetaDataCache.initMessageListener();
        // searchFilterCache.initMessageListener();
        // ruleCache.initMessageListener();
        SpringApplicationContextHolder.getBean(GenericObjectMetaDataCache.class).initMessageListener();
        SpringApplicationContextHolder.getBean(SearchFilterCache.class).initMessageListener();
        SpringApplicationContextHolder.getBean(RuleCache.class).initMessageListener();

        LOG.debug(">>> create mainframe...");
        // this.frm = new MainFrame(this.getUserName(), this.getNuclosServerName());
        setMainFrame(SpringApplicationContextHolder.getBean(MainFrameSpringComponent.class).getMainFrame());
        final MainFrame frm = getMainFrame();
        frm.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        // Attention: Do not use ListenerUtil here! (tp)
        frm.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent ev) {
                cmdWindowClosing(new ResultListener<Boolean>() {
                    @Override
                    public void done(Boolean result) {
                    }
                });
            }
        });
        loginController.increaseLoginProgressBar(StartUp.PROGRESS_CREATE_MAINFRAME);

        LOG.debug(">>> init client communication...");
        this.notificationdlg = new NuclosNotificationDialog(frm);
        getTopicNotificationReceiver().subscribe(JMSConstants.TOPICNAME_RULENOTIFICATION, messagelistener);
        loginController.increaseLoginProgressBar(StartUp.PROGRESS_INIT_NOTIFICATION);

        LOG.debug(">>> setup menus...");
        this.setupMenus();
        loginController.increaseLoginProgressBar(StartUp.PROGRESS_CREATE_MAINMENU);

        LOG.debug(">>> create explorer controller...");
        this.ctlExplorer = new ExplorerController();

        LOG.debug(">>> create task controller...");
        this.ctlTasks = new TaskController(getUserName());

        this.ctlTasks.setExplorerController(ctlExplorer);
        this.ctlExplorer.setTaskController(ctlTasks);

        initActions();

        LOG.debug(">>> restore last workspace...");
        try {
            Main.getInstance().getMainFrame().readMainFramePreferences(prefs);
            getRestoreUtils().restoreWorkspaceThreaded(MainFrame.getLastWorkspaceIdFromPreferences(),
                    MainFrame.getLastWorkspaceFromPreferences(),
                    MainFrame.getLastAlwaysOpenWorkspaceIdFromPreferences(),
                    MainFrame.getLastAlwaysOpenWorkspaceFromPreferences());
        } catch (Exception ex) {
            final String sMessage = getSpringLocaleDelegate().getMessage("MainController.4",
                    "Die in der letzten Sitzung ge\u00f6ffneten Fenster konnten nicht wiederhergestellt werden.");
            Errors.getInstance().showExceptionDialog(null, sMessage, ex);
        } finally {
            loginController.increaseLoginProgressBar(StartUp.PROGRESS_RESTORE_WORKSPACE);
        }

        LOG.debug(">>> show mainFrame...");
        frm.setVisible(true);

        try {
            LOG.debug(">>> restore last controllers (for migration only)...");
            reopenAllControllers(ClientPreferences.getUserPreferences());
        } catch (Exception ex) {
            final String sMessage = getSpringLocaleDelegate().getMessage("MainController.4",
                    "Die in der letzten Sitzung ge\u00f6ffneten Fenster konnten nicht wiederhergestellt werden.");
            Errors.getInstance().showExceptionDialog(null, sMessage, ex);
        }

        LOG.debug(">>> restore task views (for migration only)...");
        try {
            ctlTasks.restoreGenericObjectTaskViewsFromPreferences();
        } catch (Exception ex) {
            final String sMessage = getSpringLocaleDelegate().getMessage("tasklist.error.restore",
                    "Die Aufgabenlisten konnten nicht wiederhergestellt werden.");
            LOG.error(sMessage, ex);
            Errors.getInstance().showExceptionDialog(null, sMessage, ex);
        }

        Thread theadTaskController = new Thread("MainController.refreshTasks") {
            @Override
            public void run() {
                LOG.debug(">>> refresh tasks...");
                ctlTasks.run();
            }
        };
        theadTaskController.start();

        /* Release note HACK:
        Caused by: java.lang.NullPointerException
           at org.nuclos.client.help.releasenotes.ReleaseNotesController.showNuclosReleaseNotesNotice(ReleaseNotesController.java:148)
           at org.nuclos.client.help.releasenotes.ReleaseNotesController.showReleaseNotesIfNewVersion(ReleaseNotesController.java:161)
           at org.nuclos.client.main.MainController.showReleaseNotesIfNewVersion(MainController.java:1752)
           at org.nuclos.client.main.MainController.<init>(MainController.java:382)
            */
        while (getHomePane() == null) {
            Thread.sleep(200);
        }

        // Show the release notes for this version, if the user hasn't seen it yet.
        showReleaseNotesIfNewVersion();

        // Debug purposes
        final String sKeyWindowShow = "CtlShiftF11";
        frm.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
                KeyStroke.getKeyStroke(KeyEvent.VK_F11, (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)),
                sKeyWindowShow);
        frm.getRootPane().getActionMap().put(sKeyWindowShow, new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent ev) {
                debugFrame.showComponentDetails(frm.findComponentAt(frm.getMousePosition()));
            }
        });

        //Call wikipage
        final String sKeyWikiShow = "CtlShiftF1";
        frm.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
                KeyStroke.getKeyStroke(KeyEvent.VK_F1, (KeyEvent.SHIFT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK)),
                sKeyWikiShow);
        frm.getRootPane().getActionMap().put(sKeyWikiShow, new AbstractAction() {

            @Override
            public void actionPerformed(ActionEvent ev) {
                Component fundComponent = frm.getFocusOwner() != null ? frm.getFocusOwner()
                        : frm.findComponentAt(frm.getMousePosition());
                CollectController<?> clctctrl = getControllerForTab(UIUtils.getTabForComponent(fundComponent));

                WikiController wikiCtrl = WikiController.getInstance();
                wikiCtrl.openURLinBrowser(wikiCtrl.getWikiPageForComponent(fundComponent, clctctrl));

            }
        });
    } catch (Throwable e) {
        LOG.fatal("Creating MainController failed, this is fatal: " + e.toString(), e);
        throw new ExceptionInInitializerError(e);
    }
}

From source file:org.omegat.gui.align.AlignPanelController.java

private static void setKeyboardShortcut(JComponent comp, Object actionName, char stroke) {
    comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(stroke), actionName);
}

From source file:org.owasp.jbrofuzz.ui.viewers.WindowViewerFrame.java

/**
 * <p>//w  ww  .  j  ava  2  s .  c  o m
 * The window viewer that gets launched for each request within the
 * corresponding panel.
 * </p>
 * 
 * @param parent The parent panel that the frame will belong to
 * @param name The full file name of the file location to be opened
 * 
 * @author subere@uncon.org
 * @version 2.0
 * @since 2.0
 */
public WindowViewerFrame(final AbstractPanel parent, final String name) {

    super("JBroFuzz - File Viewer - " + name);

    setIconImage(ImageCreator.IMG_FRAME.getImage());

    // The container pane
    final Container pane = getContentPane();
    pane.setLayout(new BorderLayout());

    // Define the Panel
    final JPanel listPanel = new JPanel();
    listPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(name),
            BorderFactory.createEmptyBorder(1, 1, 1, 1)));
    listPanel.setLayout(new BorderLayout());

    // Get the preferences for wrapping lines of text
    final boolean wrapText = JBroFuzz.PREFS.getBoolean(JBroFuzzPrefs.FUZZING[3].getId(), false);

    if (wrapText) {

        listTextArea = new JTextPane();

    } else {

        listTextArea = new NonWrappingTextPane();

    }

    // Refine the Text Area
    listTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12));
    listTextArea.setEditable(false);

    // Define the search area
    entry = new JTextField(10);
    status = new JLabel("Enter text to search:");

    // Initialise the highlighter on the text area
    hilit = new DefaultHighlighter();
    painter = new DefaultHighlighter.DefaultHighlightPainter(HILIT_COLOR);
    listTextArea.setHighlighter(hilit);

    entryBg = entry.getBackground();
    entry.getDocument().addDocumentListener(this);

    final InputMap im = entry.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    final ActionMap am = entry.getActionMap();
    im.put(KeyStroke.getKeyStroke("ESCAPE"), CANCEL_ACTION);
    am.put(CANCEL_ACTION, new CancelAction());

    // Right click: Cut, Copy, Paste, Select All
    AbstractPanel.popupText(listTextArea, false, true, false, true);

    // Define the Scroll Pane for the Text Area
    final JScrollPane listTextScrollPane = new JScrollPane(listTextArea);
    listTextScrollPane.setVerticalScrollBarPolicy(20);
    listTextScrollPane.setHorizontalScrollBarPolicy(30);

    // Define the progress bar
    final JProgressBar progressBar = new JProgressBar();
    progressBar.setString("   ");
    progressBar.setStringPainted(true);

    // Define the bottom panel with the progress bar
    final JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 15, 15));
    bottomPanel.add(status);
    bottomPanel.add(entry);
    bottomPanel.add(progressBar);

    listTextArea.setCaretPosition(0);
    // doSyntaxHighlight();
    /*      listTextArea.setEditorKit(new StyledEditorKit() {
            
             private static final long serialVersionUID = -6085642347022880064L;
            
             @Override
             public Document createDefaultDocument() {
    return new TextHighlighter();
             }
            
          });
    */

    listPanel.add(listTextScrollPane);

    // Global Frame Issues
    pane.add(listPanel, BorderLayout.CENTER);
    pane.add(bottomPanel, BorderLayout.SOUTH);

    this.setLocation(parent.getLocationOnScreen().x + 100, parent.getLocationOnScreen().y + 20);
    this.setSize(SIZE_X, SIZE_Y);

    setResizable(true);
    setVisible(true);
    setMinimumSize(new Dimension(SIZE_X, SIZE_Y));
    setDefaultCloseOperation(2);

    listTextArea.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent ke) {
            if (ke.getKeyCode() == 27) {
                WindowViewerFrame.this.dispose();
            }
            if (ke.getKeyCode() == 10) {
                search();
            }
        }
    });

    entry.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(final KeyEvent ke) {
            if (ke.getKeyCode() == 10) {
                search();
            }
        }
    });

    class FileLoader extends SwingWorker<String, Object> { // NO_UCD

        @Override
        public String doInBackground() {

            progressBar.setIndeterminate(true);

            String dbType = JBroFuzz.PREFS.get(JBroFuzzPrefs.DBSETTINGS[11].getId(), "-1");

            if (dbType.equals("SQLite") || dbType.equals("CouchDB")) {

                String sessionId = parent.getFrame().getJBroFuzz().getWindow().getPanelFuzzing()
                        .getSessionName();

                if (sessionId == null || sessionId.equals("null")) {
                    sessionId = JBroFuzz.PREFS.get("sessionId", "");
                }

                Logger.log("Reading Session: " + sessionId + " with name: " + name, 3);

                MessageContainer mc = parent.getFrame().getJBroFuzz().getStorageHandler()
                        .readFuzzFile(name, sessionId, parent.getFrame().getJBroFuzz().getWindow()).get(0);

                listTextArea.setText("Date: " + mc.getEndDateFull() + "\n" + "FileName: " + mc.getFileName()
                        + "\n" + "URL: " + mc.getTextURL() + "\n" + "Payload: " + mc.getPayload() + "\n"
                        + "EncodedPayload: " + mc.getEncodedPayload() + "\n" + "TextRequest:"
                        + mc.getTextRequest() + "\n" + "Message: " + mc.getMessage() + "\n" + "Status: "
                        + mc.getStatus() + "\n"

                );

            } else {
                Logger.log("Loading data from file", 3);
                final File inputFile = new File(parent.getFrame().getJBroFuzz().getWindow().getPanelFuzzing()
                        .getFrame().getJBroFuzz().getStorageHandler().getLocationURIString(), name + ".html");

                listTextArea.setText(

                        FileHandler.readFile(inputFile)

                );
            }
            return "done";
        }

        @Override
        protected void done() {
            progressBar.setIndeterminate(false);
            progressBar.setValue(100);
            listTextArea.repaint();
        }
    }

    (new FileLoader()).execute();

}

From source file:org.pentaho.reporting.designer.core.xul.ActionSwingButton.java

protected void installAction(final Action newAction) {
    if (newAction != null) {
        setTooltiptext((String) action.getValue(Action.SHORT_DESCRIPTION));
        setLabel((String) action.getValue(Action.NAME));
        setDisabled(action.isEnabled() == false);
        setIcon((Icon) action.getValue(Action.SMALL_ICON));

        getButton().setAction(newAction);
        newAction.addPropertyChangeListener(actionChangeHandler);

        final Object o = newAction.getValue(Action.ACCELERATOR_KEY);
        if (o instanceof KeyStroke) {
            final KeyStroke k = (KeyStroke) o;
            getButton().registerKeyboardAction(newAction, k, JComponent.WHEN_IN_FOCUSED_WINDOW);
        }/*from ww  w.j a va 2s  .  c  o m*/

        if (newAction instanceof ToggleStateAction) {
            final ToggleStateAction tsa = (ToggleStateAction) action;
            setSelected(tsa.isSelected());
        }
    }

}