コード例 #1
0
 private void addButtonsAvailabilityListeners(JButton backButton, JButton forwardButton) {
   Platform.runLater(
       () ->
           myEngine
               .getLoadWorker()
               .stateProperty()
               .addListener(
                   (ov, oldState, newState) -> {
                     if (newState == Worker.State.SUCCEEDED) {
                       final WebHistory history = myEngine.getHistory();
                       boolean isGoBackAvailable = history.getCurrentIndex() > 0;
                       boolean isGoForwardAvailable =
                           history.getCurrentIndex() < history.getEntries().size() - 1;
                       ApplicationManager.getApplication()
                           .invokeLater(
                               () -> {
                                 backButton.setEnabled(isGoBackAvailable);
                                 forwardButton.setEnabled(isGoForwardAvailable);
                               });
                     }
                   }));
 }
コード例 #2
0
 private JButton makeGoButton(
     @NotNull final String toolTipText, @NotNull final Icon icon, final int direction) {
   final JButton button = new JButton(icon);
   button.setEnabled(false);
   button.addMouseListener(
       new MouseAdapter() {
         @Override
         public void mouseClicked(MouseEvent e) {
           if (e.getClickCount() == 1) {
             Platform.runLater(() -> myEngine.getHistory().go(direction));
           }
         }
       });
   button.setToolTipText(toolTipText);
   return button;
 }