Пример #1
0
  @Override
  public void resetEditor() {
    this.editor.setEnabled(true);
    this.editorField.setFont(this.editorFont);
    this.editorField.setBackground(null);
    this.editorIconLabel.setIcon(null);

    SwingUtils.setOpaque(this.editorIconLabel, false);
    SwingUtils.setOpaque(this.editorField, false);
  }
Пример #2
0
  @Override
  public void resetRenderer() {
    this.renderer.setEnabled(true);

    this.rendererField.setBorder(this.defaultBorder);
    this.rendererField.setOpaque(false);
    this.rendererField.setBackground(null);
    this.rendererField.setFont(this.rendererFont);

    this.renderer.setOpaque(false);
    this.rendererIcon.setIcon(null);

    SwingUtils.setOpaque(this.rendererIcon, false);
    SwingUtils.setOpaque(this.rendererField, false);
  }
Пример #3
0
 public static Window getWindowForComponent(final Component parentComponent) {
   if (parentComponent == null) {
     return JOptionPane.getRootFrame();
   }
   if (parentComponent instanceof Frame || parentComponent instanceof java.awt.Dialog) {
     return (Window) parentComponent;
   }
   return SwingUtils.getWindowForComponent(parentComponent.getParent());
 }
Пример #4
0
  /**
   * @param frame
   * @param string
   */
  public static JComponent getComponentByName(final JComponent frame, final String name) {
    JComponent ret = null;
    for (final Component c : frame.getComponents()) {

      if (c instanceof JComponent) {
        if (c.getName() != null && c.getName().equals(name)) {
          return (JComponent) c;
        } else {
          ret = SwingUtils.getComponentByName((JComponent) c, name);
          if (ret != null) {
            return ret;
          }
        }
      }
    }
    return null;
  }
        public ConnectionTooltip(DownloadLink link) {
            JLabel lbl;
            this.panel = new TooltipPanel("ins 3,wrap 1", "[grow,fill]", "[grow,fill]");
            DownloadInterface dli = link.getDownloadInstance();
            SingleDownloadController sdc = link.getDownloadLinkController();
            {
                if (dlWatchdog.isLinkForced(link)) {
                    panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_DownloadIsForced(), forced, JLabel.LEADING));
                    SwingUtils.setOpaque(lbl, false);
                    lbl.setForeground(new Color(this.getConfig().getForegroundColor()));
                }
                if (link.isSkipped()) {
                    panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_DownloadIsSkipped(), skipped, JLabel.LEADING));
                    SwingUtils.setOpaque(lbl, false);
                    lbl.setForeground(new Color(this.getConfig().getForegroundColor()));
                }

                /* is the Link resumeable */
                if (link.isResumeable()) {
                    panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_DownloadIsResumeable(), resumeIndicator, JLabel.LEADING));
                    SwingUtils.setOpaque(lbl, false);
                    lbl.setForeground(new Color(this.getConfig().getForegroundColor()));
                }
            }
            if (sdc != null) {
                {
                    /* connection? */
                    HTTPProxy proxy = sdc.getCurrentProxy();
                    if (proxy == null) proxy = HTTPProxy.NONE;
                    panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_getStringValue_connection(proxy), proxy.isRemote() ? proxyConnection : directConnection, JLabel.LEADING));
                    SwingUtils.setOpaque(lbl, false);
                    lbl.setForeground(new Color(this.getConfig().getForegroundColor()));
                }
                if (sdc.getAccount() != null) {
                    /* account in use? */
                    panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_DownloadUsesAccount(sdc.getAccount().getUser()), accountInUse, JLabel.LEADING));
                    SwingUtils.setOpaque(lbl, false);
                    lbl.setForeground(new Color(this.getConfig().getForegroundColor()));
                }
            }
            if (dli != null) {
                panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_getStringValue_chunks(dli.getManagedConnetionHandler().size()), connections, JLabel.LEADING));
                SwingUtils.setOpaque(lbl, false);
                lbl.setForeground(new Color(this.getConfig().getForegroundColor()));
            }
            this.panel.setOpaque(false);
            if (panel.getComponentCount() > 0) add(panel);
        }
Пример #6
0
 private JLabel header(String buyAndAddPremiumAccount_layoutDialogContent_get) {
   JLabel ret = SwingUtils.toBold(new JLabel(buyAndAddPremiumAccount_layoutDialogContent_get));
   ret.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, ret.getForeground()));
   return ret;
 }
Пример #7
0
  public EndCaptchaTooltip(ServicePanel owner, final EndCaptchaSolver solver) {

    super(new TooltipPanel("ins 0,wrap 1", "[grow,fill]", "[grow,fill]"));
    this.owner = owner;
    color = (LAFOptions.getInstance().getColorForTooltipForeground());
    JProgressBar progress = new JProgressBar();
    progress.setIndeterminate(true);
    panel.setLayout(new MigLayout("ins 0,wrap 1", "[grow,fill]", "[]"));
    JLabel header =
        new JLabel("EndCaptcha.com Solver", new AbstractIcon("endCaptcha", 18), JLabel.LEFT);
    header.setBorder(
        BorderFactory.createMatteBorder(
            0, 0, 1, 0, LAFOptions.getInstance().getColorForTooltipForeground()));
    SwingUtils.toBold(header);
    header.setForeground(LAFOptions.getInstance().getColorForTooltipForeground());
    panel.add(header, "gapbottom 5,spanx");
    panel.add(progress);
    // panel.setPreferredSize(new Dimension(300, 100));
    new Thread() {
      public void run() {

        final EndCaptchaAccount account = solver.loadAccount();
        new EDTRunner() {

          @Override
          protected void runInEDT() {
            panel.removeAll();
            // panel.setPreferredSize(null);
            if (!account.isValid()) {
              panel.setLayout(new MigLayout("ins 0,wrap 1", "[grow,fill]", "[]"));
              JLabel header =
                  new JLabel(
                      "EndCaptcha.com Solver", new AbstractIcon("endCaptcha", 18), JLabel.LEFT);
              header.setBorder(
                  BorderFactory.createMatteBorder(
                      0, 0, 1, 0, LAFOptions.getInstance().getColorForTooltipForeground()));
              SwingUtils.toBold(header);
              header.setForeground(LAFOptions.getInstance().getColorForTooltipForeground());
              panel.add(header, "gapbottom 5,spanx");
              panel.add(
                  lbl(
                      _GUI.T.ServicePanel9kwTooltip_runInEDT_error2(""),
                      NewTheme.I().getIcon(IconKey.ICON_ERROR, 18),
                      JLabel.LEFT));
              panel.add(lbl(account.getError()), "gapleft 22");
            } else {
              panel.setLayout(new MigLayout("ins 0,wrap 2", "[][grow,align right]", "[]0"));
              JLabel header =
                  new JLabel(
                      "EndCaptcha.com Solver", new AbstractIcon("endCaptcha", 18), JLabel.LEFT);
              header.setBorder(
                  BorderFactory.createMatteBorder(
                      0, 0, 1, 0, LAFOptions.getInstance().getColorForTooltipForeground()));
              SwingUtils.toBold(header);
              header.setForeground(LAFOptions.getInstance().getColorForTooltipForeground());
              panel.add(header, "spanx,gapbottom 5,pushx,growx");

              panel.add(
                  lbl(
                      _GUI.T.lit_accountid(),
                      NewTheme.I().getIcon(IconKey.ICON_PREMIUM, 18),
                      JLabel.LEFT));
              panel.add(lbl(account.getUserName() + ""));
              panel.add(
                  lbl(
                      _GUI.T.ServicePanel9kwTooltip_runInEDT_credits_(),
                      NewTheme.I().getIcon(IconKey.ICON_MONEY, 18),
                      JLabel.LEFT));
              panel.add(lbl(account.getBalance() + " USD"));

              // panel.add(lbl(_GUI.T.lit_rate(), NewTheme.I().getIcon(IconKey.ICON_PLAY, 18),
              // JLabel.LEFT));
              // panel.add(lbl(account.getRate() + " USD Cent/Captcha"));
              // panel.add(lbl(_GUI.T.ServicePanelDBCTooltip_captcha_free(),
              // NewTheme.I().getIcon(IconKey.ICON_OCR, 18),
              // JLabel.LEFT));
              // panel.add(lbl((int) (account.getBalance() / account.getRate())));
              // if (account.isBanned()) {
              // panel.add(lbl(_GUI.T.ServicePanel9kwTooltip_runInEDT_banned(),
              // NewTheme.I().getIcon(IconKey.ICON_ERROR, 18),
              // JLabel.LEFT));
              //
              // }

            }
            // panel.revalidate();
            // revalidate();
            // repaint();
            ToolTipController.getInstance().show(EndCaptchaTooltip.this);
          }
        };
      }
    }.start();
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.appwork.utils.swing.dialog.Locator#getLocationOnScreen(javax.swing
   * .JDialog)
   */
  @Override
  public Point getLocationOnScreen(final Window dialog) {

    if (dialog.getParent() == null
        || !dialog.getParent().isDisplayable()
        || !dialog.getParent().isVisible()) {
      final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

      return correct(
          new Point(
              (int) (screenSize.getWidth() - dialog.getWidth()) / 2,
              (int) (screenSize.getHeight() - dialog.getHeight()) / 2),
          dialog);

    } else if (dialog.getParent() instanceof Frame
        && ((Frame) dialog.getParent()).getExtendedState() == Frame.ICONIFIED) {
      // dock dialog at bottom right if mainframe is not visible

      final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      final GraphicsDevice[] screens = ge.getScreenDevices();

      for (final GraphicsDevice screen : screens) {
        final Rectangle bounds = screen.getDefaultConfiguration().getBounds();
        screen.getDefaultConfiguration().getDevice();

        final Insets insets =
            Toolkit.getDefaultToolkit().getScreenInsets(screen.getDefaultConfiguration());
        if (bounds.contains(MouseInfo.getPointerInfo().getLocation())) {

          return correct(
              new Point(
                  (int) (bounds.x + bounds.getWidth() - dialog.getWidth() - 20 - insets.right),
                  (int) (bounds.y + bounds.getHeight() - dialog.getHeight() - 20 - insets.bottom)),
              dialog);
        }
      }
      final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      return correct(
          new Point(
              (int) (screenSize.getWidth() - dialog.getWidth() - 20),
              (int) (screenSize.getHeight() - dialog.getHeight() - 60)),
          dialog);
    } else {
      final Point ret = SwingUtils.getCenter(dialog.getParent(), dialog);

      return correct(ret, dialog);
    }

    // if (frame.getParent() == null || !frame.getParent().isDisplayable()
    // || !frame.getParent().isVisible()) {
    // final Dimension screenSize =
    // Toolkit.getDefaultToolkit().getScreenSize();
    //
    // return (new Point((int) (screenSize.getWidth() - frame.getWidth()) /
    // 2, (int) (screenSize.getHeight() - frame.getHeight()) / 2));
    //
    // } else if (frame.getParent() instanceof Frame && ((Frame)
    // frame.getParent()).getExtendedState() == Frame.ICONIFIED) {
    // // dock dialog at bottom right if mainframe is not visible
    //
    // final GraphicsEnvironment ge =
    // GraphicsEnvironment.getLocalGraphicsEnvironment();
    // final GraphicsDevice[] screens = ge.getScreenDevices();
    //
    // for (final GraphicsDevice screen : screens) {
    // final Rectangle bounds =
    // screen.getDefaultConfiguration().getBounds();
    // screen.getDefaultConfiguration().getDevice();
    //
    // Insets insets =
    // Toolkit.getDefaultToolkit().getScreenInsets(screen.getDefaultConfiguration());
    // if (bounds.contains(MouseInfo.getPointerInfo().getLocation())) {
    // return (new Point((int) (bounds.x + bounds.getWidth() -
    // frame.getWidth() - 20 - insets.right), (int) (bounds.y +
    // bounds.getHeight() - frame.getHeight() - 20 - insets.bottom))); }
    //
    // }
    // final Dimension screenSize =
    // Toolkit.getDefaultToolkit().getScreenSize();
    // return (new Point((int) (screenSize.getWidth() - frame.getWidth() -
    // 20), (int) (screenSize.getHeight() - frame.getHeight() - 60)));
    // } else {
    // return SwingUtils.getCenter(frame.getParent(), frame);
    // }

  }