public void changeLAF(int iLAFIndex) {
    try {
      // Change LAF
      if (iLAFIndex >= marrLaf.length) iLAFIndex = marrLaf.length - 1;
      UIManager.setLookAndFeel(
          (LookAndFeel) Class.forName(marrLaf[iLAFIndex].getClassName()).newInstance());

      // Update UI
      ((JMenuItem) mvtLAFItem.elementAt(iLAFIndex)).setSelected(true);
      SwingUtilities.updateComponentTreeUI(this);
      SwingUtilities.updateComponentTreeUI(mnuMain);
      WindowManager.updateLookAndField();

      // Store config
      try {
        Hashtable prt = Global.loadHashtable(Global.FILE_CONFIG);
        prt.put("LAF", String.valueOf(iLAFIndex));
        Global.storeHashtable(prt, Global.FILE_CONFIG);
      } catch (Exception e) {
      }
    } catch (Exception e) {
      e.printStackTrace();
      MessageBox.showMessageDialog(this, e, Global.APP_NAME, MessageBox.ERROR_MESSAGE);
    }
  }
示例#2
1
  /**
   * Sets the mute status icon to the status panel.
   *
   * @param isMute indicates if the call with this peer is muted
   */
  public void setMute(final boolean isMute) {
    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              setMute(isMute);
            }
          });
      return;
    }

    if (isMute) {
      muteStatusLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.MUTE_STATUS_ICON)));
      muteStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3));
    } else {
      muteStatusLabel.setIcon(null);
      muteStatusLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    }

    // Update input volume control button state to reflect the current
    // mute status.
    if (localLevel.isSelected() != isMute) localLevel.setSelected(isMute);

    this.revalidate();
    this.repaint();
  }
  public static boolean isFocused(@Nullable Component[] components) {
    if (components == null) return false;

    Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();

    if (owner == null) return false;

    Window wnd;
    if (owner instanceof Window) {
      wnd = (Window) owner;
    } else {
      wnd = SwingUtilities.getWindowAncestor(owner);
    }

    for (Component each : components) {
      if (each != null && SwingUtilities.isDescendingFrom(owner, each)) {
        Window eachWindow =
            each instanceof Window ? (Window) each : SwingUtilities.getWindowAncestor(each);
        if (eachWindow == wnd) {
          return true;
        }
      }
    }

    return false;
  }
  /**
   * Constructs the model with information passed to the constructor and the players chosen
   * characters.<br>
   * After it has constructed the model it displays the GameScreen.
   *
   * @param aiEnabled true if ai is enabled, otherwise false
   * @param tournament true if tournament mode is enabled, otherwise false
   * @param one Player one's character
   * @param two Player two's character
   */
  public void startGame(boolean aiEnabled, boolean tournament, Character one, Character two) {
    // CONSTRUCT Game with the 2 characters and tournament
    Game game = new Game(tournament, one, two);
    // CONSTRUCT Controller with Game
    Controller controller = new Controller(game, ai);
    // GET the mainscreen test deck
    String test = ((MainScreen) SwingUtilities.getRoot(this)).getTest();
    // IF test deck is not null
    if (test != null) {
      // SET the players' decks to test deck
      game.setDeck(test, PlayerNum.ONE);
      game.setDeck(test, PlayerNum.TWO);
    }
    // END IF

    // IF ai is true
    if (aiEnabled) {
      // CONSTRUCT the AI with the controller, game, and tournament
      new AI(controller, game, tournament);
    }
    // CONSTRUCT the GameScreen with Game, Controller, and both characters
    GameScreen gameScreen = new GameScreen(game, controller, one, two);
    ((MainScreen) SwingUtilities.getRoot(this)).addScreen(gameScreen, "GameScreen");
    ((MainScreen) SwingUtilities.getRoot(this)).changeScreen("GameScreen");
    // SHOW gameScreen on master panel
  }
示例#5
0
  private void populatePortTable(List ports) {

    logger.debug("Filling port table");
    // get an array of ports
    final PortInfoController[] portcontrollers =
        (PortInfoController[]) ports.toArray(new PortInfoController[ports.size()]);

    // setup the panel
    boxControllers.removeAll();

    // add the ports to the data array
    for (int index = 0; index < portcontrollers.length; index++) {

      final int indexFinal = index;
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {

              boxControllers.add(portcontrollers[indexFinal].getView());
            }
          });
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            boxControllers.add(Box.createVerticalGlue());
          }
        });
  }
示例#6
0
 /**
  * Manages mouse clicks
  *
  * @param e the event
  * @see javax.swing.text.DefaultCaret#mouseClicked(java.awt.event.MouseEvent)
  */
 public void mouseClicked(MouseEvent e) {
   if (SwingUtilities.isMiddleMouseButton(e) && e.getClickCount() == 1) {
     /** * PASTE USING MIDDLE BUTTON ** */
     JTextComponent c = (JTextComponent) e.getSource();
     if (c != null) {
       Toolkit tk = c.getToolkit();
       Clipboard buffer = tk.getSystemSelection();
       if (buffer != null) {
         Transferable trans = buffer.getContents(null);
         if (trans.isDataFlavorSupported(DataFlavor.stringFlavor)) {
           try {
             String pastedText = (String) trans.getTransferData(DataFlavor.stringFlavor);
             ((JTextPane) getConsole().getConfiguration().getInputCommandView())
                 .replaceSelection(pastedText);
           } catch (UnsupportedFlavorException e1) {
             e1.printStackTrace();
           } catch (IOException e1) {
             e1.printStackTrace();
           }
         }
       }
     }
   } else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 1) {
     /** * SEND THE FOCUS TO THE INPUT COMMAND VIEW ** */
     ((JTextPane) getConsole().getConfiguration().getInputCommandView()).requestFocus();
     ((JTextPane) getConsole().getConfiguration().getInputCommandView())
         .getCaret()
         .setVisible(true);
   } else {
     /** * DELEGATE TO THE SYSTEM ** */
     super.mouseClicked(e);
   }
 }
    protected void preCache(List<Position> grid, Position centerPosition)
        throws InterruptedException {
      // Pre-cache the tiles that will be needed for the intersection calculations.
      double n = 0;
      final long start = System.currentTimeMillis();
      for (Position gridPos : grid) // for each grid point.
      {
        final double progress = 100 * (n++ / grid.size());
        terrain.cacheIntersectingTiles(centerPosition, gridPos);

        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                progressBar.setValue((int) progress);
                progressBar.setString(null);
              }
            });
      }

      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              progressBar.setValue(100);
            }
          });

      long end = System.currentTimeMillis();
      System.out.printf(
          "Pre-caching time %d milliseconds, cache usage %f, tiles %d\n",
          end - start, terrain.getCacheUsage(), terrain.getNumCacheEntries());
    }
 /**
  * Called whenever a full reply has been received from the 430. Also called with value=-1 if a
  * timeout occurs waiting for a reply or if a garbled reply is received.
  *
  * @param what The parameter that the value refers to. For one byte replies (ACK, NACK, or NACK0)
  *     the command that produced this reply.
  * @param value The value of the "what" parameter. For one byte replies, the <i>negated</i> value
  *     of that byte as an integer.
  */
 protected void processReply(String what, boolean value) {
   if (SwingUtilities.isEventDispatchThread()) {
     processReplyInEventThread(what, value);
   } else {
     SwingUtilities.invokeLater(new ReplyProcessor(what, value));
   }
 }
  private void showOperation(OperationItemId id, OperationInfo op) {

    final OperationItemId finalId = id;
    final OperationInfo finalInfo = op;
    // check if the panel was already added i.e. some input was being entered
    // check if that input is saved or not
    if (TableUtil.checkIfExists(rightPanel, addOperationPanel)) {
      checkNewOperationSave(addOperationPanel);
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              rightPanel.remove(addOperationPanel);
              rightPanel.add(displayDataPanel);
            }
          });

    } else if (TableUtil.checkIfExists(rightPanel, displayDataPanel)) {
      checkDisplayOperationSave(displayDataPanel);
    } else {
      rightPanel.add(displayDataPanel);
    }
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            displayDataPanel.populate(finalId, finalInfo);
            rightPanel.revalidate();
            rightPanel.repaint();
          }
        });
  }
示例#10
0
    private boolean shouldIgnore(MouseEvent e) {

      System.out.println(
          " in shouldIgnore ret  " + (!SwingUtilities.isLeftMouseButton(e) || !table.isEnabled()));

      return !SwingUtilities.isLeftMouseButton(e) || !table.isEnabled();
    }
示例#11
0
  @Override
  public final void mousePressed(final MouseEvent e) {
    if (!isEnabled() || !isFocusable()) return;

    requestFocusInWindow();
    caret(true);

    if (SwingUtilities.isMiddleMouseButton(e)) copy();

    final boolean shift = e.isShiftDown();
    final boolean selected = editor.selected();
    if (SwingUtilities.isLeftMouseButton(e)) {
      final int c = e.getClickCount();
      if (c == 1) {
        // selection mode
        if (shift) editor.startSelection(true);
        select(e.getPoint(), !shift);
      } else if (c == 2) {
        editor.selectWord();
      } else {
        editor.selectLine();
      }
    } else if (!selected) {
      select(e.getPoint(), true);
    }
  }
  @Override
  public void mouseDragged(MouseEvent arg0) {
    if (dragging) {
      setDragTileLocation(new Point(arg0.getXOnScreen(), arg0.getYOnScreen()));

      // find drop target on world
      Point os = new Point(arg0.getXOnScreen(), arg0.getYOnScreen());
      SwingUtilities.convertPointFromScreen(os, parent.world);

      Component component =
          SwingUtilities.getDeepestComponentAt(parent.world, (int) os.getX(), (int) os.getY());

      if (component instanceof TileView) {
        // available drop target reached
        draggedOverTile = ((TileView) component);

        // change cursor symbol to drop target symbol
        Cursor cursor = DragSource.DefaultCopyDrop;
        draggedTile.setCursor(cursor);
      } else {
        draggedOverTile = null;

        // reset cursor symbol
        draggedTile.setCursor(null);
      }
    }
  }
    public void actionPerformed(ActionEvent e) {
      final KeyboardFocusManager currentKeyboardFocusManager =
          KeyboardFocusManager.getCurrentKeyboardFocusManager();
      final Window activeWindow = currentKeyboardFocusManager.getActiveWindow();
      if (activeWindow instanceof JDialog
          && ((JDialog) activeWindow).isModal()
          && !SwingUtilities.isDescendingFrom(
              Controller.getCurrentController().getViewController().getMapView(), activeWindow)) {
        popup.hide();
        hideTimer.removeActionListener(this);
        hideTimer.stop();
      }

      if (tip.getMousePosition(true) != null || mouseOverComponent()) {
        hideTimer.restart();
        return;
      }
      final Component focusOwner = currentKeyboardFocusManager.getFocusOwner();
      if (focusOwner != null) {
        if (SwingUtilities.isDescendingFrom(focusOwner, tip)) {
          hideTimer.restart();
          return;
        }
      }

      popup.hide();
      hideTimer.removeActionListener(this);
      hideTimer.stop();
    }
示例#14
0
 /** prints error text in the answer pane, reenables buttons and adds retry button. */
 public final void printErrorAndRetry(String text, final String ans, final int exitCode) {
   if (ans != null) {
     text += "\n" + Tools.getString("Dialog.Dialog.PrintErrorAndRetry") + exitCode + "\n" + ans;
   }
   answerPaneSetTextError(text);
   addRetryButton();
   if (buttonClass(retryButton()) != null) {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             buttonClass(retryButton()).requestFocus();
           }
         });
   }
   if (buttonClass(nextButton()) != null) {
     enableComponents(new JComponent[] {buttonClass(nextButton())});
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             buttonClass(nextButton()).setEnabled(false);
           }
         });
   }
 }
  @SuppressWarnings("unused")
  private void showDialog() {

    if (!SwingUtilities.isEventDispatchThread()) {
      selectedOption =
          JOptionPane.showOptionDialog(
              this,
              panel,
              tr("PT_Assistant Proceed Request"),
              JOptionPane.DEFAULT_OPTION,
              JOptionPane.QUESTION_MESSAGE,
              null,
              options,
              0);
    } else {

      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              showDialog();
            }
          });
    }
  }
示例#16
0
  /** Updates the scrollbar to reflect the current size of the document */
  private void updateScrollBar() {

    final int value, maximum;

    int documentSize = this.documentSize.get();

    value = this.fastTextView.getParagraph();
    maximum = Math.max(0, documentSize - 1) + 10;

    Runnable scrollbarUpdater =
        new Runnable() {

          @Override
          public void run() {

            FastTextPane.this.ignoreAdjustmentChange = true;
            FastTextPane.this.scrollBar.setValues(value, 10, 0, maximum);
            FastTextPane.this.ignoreAdjustmentChange = false;
          }
        };

    if (SwingUtilities.isEventDispatchThread()) {
      scrollbarUpdater.run();
    } else {
      SwingUtilities.invokeLater(scrollbarUpdater);
    }
  }
示例#17
0
  public final void runBare() throws Throwable {
    final Throwable[] throwables = new Throwable[1];

    SwingUtilities.invokeAndWait(
        new Runnable() {
          public void run() {
            try {
              ourTestThread = Thread.currentThread();
              startRunAndTear();
            } catch (Throwable throwable) {
              throwables[0] = throwable;
            } finally {
              ourTestThread = null;
              try {
                cleanupApplicationCaches();
              } catch (Throwable e) {
                e.printStackTrace();
              }
            }
          }
        });

    if (throwables[0] != null) {
      throw throwables[0];
    }

    // just to make sure all deffered Runnable's to finish
    SwingUtilities.invokeAndWait(EmptyRunnable.getInstance());

    if (IdeaLogger.ourErrorsOccurred != null) {
      throw IdeaLogger.ourErrorsOccurred;
    }
  }
  public void runGame() {
    SwingUtilities.invokeLater(a);
    try {
      sleep(delay);
    } catch (InterruptedException e) {
      System.out.println("interrupted.");
    }
    while (!world.endGame()) {
      // System.out.println("Game playing. Making move.");
      int action1 = -1;
      int action2 = -1;
      action1 = policy1.getBestAction(world.getState1());
      action2 = policy2.getBestAction(world.getState2());
      System.out.println("action2 " + action2);
      SwingUtilities.invokeLater(a);

      try {
        sleep(delay);
      } catch (InterruptedException e) {
        System.out.println("interrupted.");
      }
    }
    a.agentsScore += world.agent1Score;
    a.catScore += world.fail;

    // turn off gameOn flag if only single game
    if (single) gameOn = false;
  }
  @Override
  protected void finish() {
    if (canceled) return;
    if (lastException != null) {
      ExceptionDialogUtil.explainException(lastException);
    }
    Runnable r =
        new Runnable() {
          public void run() {
            ChangesetCache.getInstance().update(downloadedChangesets);
          }
        };

    if (SwingUtilities.isEventDispatchThread()) {
      r.run();
    } else {
      try {
        SwingUtilities.invokeAndWait(r);
      } catch (InterruptedException e) {
        e.printStackTrace();
      } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();
        if (t instanceof RuntimeException) {
          BugReportExceptionHandler.handleException(t);
        } else if (t instanceof Exception) {
          ExceptionUtil.explainException(e);
        } else {
          BugReportExceptionHandler.handleException(t);
        }
      }
    }
  }
  protected void executeScript(final String script) {
    if (webBrowser == null || script.length() == 0) return;

    if (!SwingUtilities.isEventDispatchThread()) {
      SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              webBrowser.runInSequence(
                  new Runnable() {
                    public void run() {
                      webBrowser.executeJavascript(script);
                    }
                  });
              logJavaScript(script, null);
            }
          });
    } else {
      webBrowser.runInSequence(
          new Runnable() {
            public void run() {
              webBrowser.executeJavascript(script);
            }
          });
      logJavaScript(script, null);
    }
  }
示例#21
0
 /** Inits the dialog after it becomes visible. */
 @Override
 protected void initDialogAfterVisible() {
   final DrbdResourceInfo dri = getDrbdVolumeInfo().getDrbdResourceInfo();
   final boolean ch = dri.checkResourceFieldsChanged(null, PARAMS);
   final boolean cor = dri.checkResourceFieldsCorrect(null, PARAMS);
   if (cor) {
     enableComponents();
   } else {
     /* don't enable */
     enableComponents(new JComponent[] {buttonClass(nextButton())});
   }
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           makeDefaultButton(buttonClass(nextButton()));
         }
       });
   if (Tools.getConfigData().getAutoOptionGlobal("autodrbd") != null) {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             pressNextButton();
           }
         });
   }
 }
示例#22
0
  public static void main(String[] args) {

    // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

    if (args.length == 1 && args[0].equals(TEST_FLAG)) {

      String[] filesToTest =
          new String[] {
            "examples/l22_cylsoma.swc",
            "examples/l22_sphersoma.swc",
            "examples/l22.swc",
            "examples/l22_small.swc",
            "examples/dCH-cobalt.CNG_small.swc",
            "examples/dCH-cobalt.CNG.swc"
          };

      for (String f : filesToTest) {
        String[] argsNew = new String[] {f, TEST_FLAG};
        SwingUtilities.invokeLater(new main(argsNew));
      }

    } else {
      SwingUtilities.invokeLater(new main(args));
    }
  }
示例#23
0
  public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    robot.setAutoDelay(350);

    SwingUtilities.invokeAndWait(
        new Runnable() {

          public void run() {
            createAndShowGUI();
          }
        });

    robot.waitForIdle();

    SwingUtilities.invokeAndWait(
        new Runnable() {

          public void run() {
            spane.requestFocus();
            sbar.setValue(sbar.getMaximum());
          }
        });

    robot.waitForIdle();

    Point point = getClickPoint(0.5, 0.5);
    robot.mouseMove(point.x, point.y);
    robot.mousePress(InputEvent.BUTTON1_MASK);

    robot.waitForIdle();

    SwingUtilities.invokeAndWait(
        new Runnable() {

          public void run() {
            final int oldValue = sbar.getValue();
            sbar.addAdjustmentListener(
                new AdjustmentListener() {

                  public void adjustmentValueChanged(AdjustmentEvent e) {
                    if (e.getValue() >= oldValue) {
                      passed = false;
                    }
                    do_test = true;
                  }
                });
          }
        });

    robot.waitForIdle();

    point = getClickPoint(0.5, 0.2);
    robot.mouseMove(point.x, point.y);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.waitForIdle();

    if (!do_test || !passed) {
      throw new Exception("The scrollbar moved with incorrect direction");
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#getPreferredSize(javax
   * .swing.JComponent)
   */
  @Override
  public Dimension getPreferredSize(JComponent c) {
    AbstractCommandButton button = (AbstractCommandButton) c;
    SubstanceButtonShaper shaper = SubstanceCoreUtilities.getButtonShaper(button);

    Dimension superPref = super.getPreferredSize(button);
    if (superPref == null) return null;

    if (shaper == null) return superPref;

    // fix for issue 35 on Flamingo - do not enforce
    // min size on buttons in the ribbon
    // Additional fix - buttons with popup action should
    // not have min size enforced as well
    // Additional fix - buttons in popup menus and breadcrumb bars should
    // not have min size enforced
    if ((button.getDisplayState() == CommandButtonDisplayState.MEDIUM)
        && (SwingUtilities.getAncestorOfClass(AbstractRibbonBand.class, button) == null)
        && (SwingUtilities.getAncestorOfClass(JBreadcrumbBar.class, button) == null)
        && (SwingUtilities.getAncestorOfClass(JCommandPopupMenu.class, button) == null)) {
      JButton dummy = new JButton(button.getText(), button.getIcon());
      Dimension result = shaper.getPreferredSize(dummy, superPref);
      if (FlamingoUtilities.hasPopupAction(button)) {
        result.width = superPref.width;
      }
      return result;
    }
    return superPref;
  }
示例#25
0
  public void addNewPortController(final PortInfoView portcontroller) {

    // add the row to the table
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            logger.debug("Adding portcontroller");

            if (boxControllers.getComponentCount() > 0) {
              boxControllers.remove(boxControllers.getComponentCount() - 1);
            }

            boxControllers.add(portcontroller);
            revalidate();
          }
        });

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {

            boxControllers.add(Box.createVerticalGlue());
          }
        });
  }
    public static void showExceptionDialog(Component owner, String title, String message, Exception exc) {
        if (SwingUtilities.isEventDispatchThread()) {
            ExceptionDialog eDlg;
            if (!(owner instanceof Window)) {
                if (owner != null) {
                    owner = SwingUtilities.getWindowAncestor(owner);
                }
                if (owner == null) {
                    owner = Launcher2.application.getFrame();
                }
            }


            if (owner instanceof Dialog) {
                eDlg = new ExceptionDialog((Dialog)owner, title, message, exc);
            } else if (owner instanceof Frame) {
                eDlg = new ExceptionDialog((Frame)owner, title, message, exc);
            } else {
                JOptionPane.showMessageDialog(owner, message + "\n" + exc.getMessage(), Utils._("Error"), JOptionPane.ERROR_MESSAGE);
                return;
            }
            eDlg.setVisible(true);
        } else {
            try {
                SwingUtilities.invokeAndWait(new DisplayRunnable(owner, title, message, exc));
            } catch (InterruptedException e) {
                log.log(Level.WARNING, "Error showing exception dialog.", e);
            } catch (InvocationTargetException e) {
                log.log(Level.WARNING, "Error showing exception dialog.", e);
            }
        }
    }
 @Override
 public void addNotifications(
     final NotificationChannel channel, Collection<NotificationItem> items) {
   channel.addNotifications(items);
   if (!channel.isVisible()) {
     boolean hasVisibleChannel = false;
     for (NotificationChannel ch : NotificationChannel.values()) {
       hasVisibleChannel |= ch.isVisible();
     }
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             channel.saveNormalColor();
             channel.getButton().setBackground(channel.getColor());
             showNotification(channel);
           }
         });
     if (!hasVisibleChannel) {
       SwingUtilities.invokeLater(
           new Runnable() {
             @Override
             public void run() {
               showNotification(channel);
             }
           });
     }
   }
 }
  /**
   * Sets the jobs for that model
   *
   * @param jobs
   * @throws SQLException
   */
  public void setJobs(final ArrayList<ExperimentResult> jobs) throws SQLException {

    Runnable updateTable =
        new Runnable() {

          @Override
          public void run() {
            ExperimentResultsBrowserTableModel.this.jobs = jobs;
            if (jobs != null) {
              gridQueues = new HashMap<Integer, GridQueue>();
              parameters = new HashMap<Integer, String>();
              try {
                ArrayList<GridQueue> queues = GridQueueDAO.getAll();
                for (GridQueue q : queues) {
                  gridQueues.put(q.getId(), q);
                }
              } catch (Exception e) {
              }
            }
            ExperimentResultsBrowserTableModel.this.fireTableDataChanged();
          }
        };
    if (SwingUtilities.isEventDispatchThread()) {
      // already in EDT
      updateTable.run();
    } else {
      // we have to run this in the EDT, otherwise sync exceptions
      SwingUtilities.invokeLater(updateTable);
    }
  }
示例#29
0
 public static void doSafely(Runnable run) {
   if (SwingUtilities.isEventDispatchThread()) {
     run.run();
   } else {
     SwingUtilities.invokeLater(run);
   }
 }
  /**
   * Paint the component, which is an {@link AbstractButton}, according to its current state.
   *
   * @param g The graphics context to paint with
   * @param c The component to paint the state of
   */
  public void paint(Graphics g, JComponent c) {
    AbstractButton b = (AbstractButton) c;

    Rectangle tr = new Rectangle();
    Rectangle ir = new Rectangle();
    Rectangle vr = new Rectangle();

    Font f = c.getFont();

    g.setFont(f);

    if (b.isBorderPainted()) SwingUtilities.calculateInnerArea(b, vr);
    else vr = SwingUtilities.getLocalBounds(b);
    String text =
        SwingUtilities.layoutCompoundLabel(
            c,
            g.getFontMetrics(f),
            b.getText(),
            currentIcon(b),
            b.getVerticalAlignment(),
            b.getHorizontalAlignment(),
            b.getVerticalTextPosition(),
            b.getHorizontalTextPosition(),
            vr,
            ir,
            tr,
            b.getIconTextGap() + defaultTextShiftOffset);

    if ((b.getModel().isArmed() && b.getModel().isPressed()) || b.isSelected())
      paintButtonPressed(g, b);

    paintIcon(g, b, ir);
    if (text != null) paintText(g, b, tr, text);
    if (b.isFocusOwner() && b.isFocusPainted()) paintFocus(g, b, vr, tr, ir);
  }