コード例 #1
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
  @Override
  public void focusGained(final FocusEvent e) {
    final JTextComponent component = getComponent();
    if (!component.isEnabled() || !component.isEditable()) {
      super.focusGained(e);
      return;
    }

    mFocused = true;
    if (!shouldSelectAllOnFocus) {
      shouldSelectAllOnFocus = true;
      super.focusGained(e);
      return;
    }

    if (isMultiLineEditor) {
      super.focusGained(e);
      return;
    }

    final int end = component.getDocument().getLength();
    final int dot = getDot();
    final int mark = getMark();
    if (dot == mark) {
      if (dot == 0) {
        component.setCaretPosition(end);
        component.moveCaretPosition(0);
      } else if (dot == end) {
        component.setCaretPosition(0);
        component.moveCaretPosition(end);
      }
    }

    super.focusGained(e);
  }
コード例 #2
0
ファイル: VCaretEntry.java プロジェクト: timburrow/OpenVnmrJ
 public void focusGained(FocusEvent e) {
   inModalMode = true;
   if (debug) System.out.println("gained focus");
   setBlinkRate(500);
   // setCaretValue(caretValue);
   super.focusGained(e);
 }
コード例 #3
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 // This fixes the problem where when on the mac you have to ctrl left click to
 // get popup triggers the caret has code that only looks at button number.
 // see radar # 3125390
 @Override
 public void mousePressed(final MouseEvent e) {
   if (!e.isPopupTrigger()) {
     super.mousePressed(e);
     shouldSelectAllOnFocus = false;
   }
 }
コード例 #4
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
  @Override
  protected void fireStateChanged() {
    // If we have focus the caret should only flash if the range length is zero
    if (mFocused) setVisible(getComponent().isEditable());

    super.fireStateChanged();
  }
コード例 #5
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 // See <rdar://problem/3833837> 1.4.2_05-141.3: JTextField performance with
 // Aqua L&F. We are getting into a circular condition with the BasicCaret
 // paint code since it doesn't know about the fact that our damage routine
 // above elminates the border. Sadly we can't easily change either one, so
 // we will add a painting flag and not damage during a repaint.
 @Override
 public void paint(final Graphics g) {
   if (isVisible()) {
     fPainting = true;
     super.paint(g);
     fPainting = false;
   }
 }
コード例 #6
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 @Override
 public void focusLost(final FocusEvent e) {
   mFocused = false;
   shouldSelectAllOnFocus = true;
   if (isMultiLineEditor) {
     setVisible(false);
     getComponent().repaint();
   } else {
     super.focusLost(e);
   }
 }
コード例 #7
0
ファイル: VCaretEntry.java プロジェクト: timburrow/OpenVnmrJ
  private void setCaretValue(int i) {

    caret.setVisible(true);

    caretValue = i;
    int min = 0;
    int max = getText().length();

    if (i < min) i = min;
    if (i > max) i = max;

    if (debug) System.out.println("setSelectionStart: " + i);
    setSelectionStart(i);
    setSelectionEnd(i);
  }
コード例 #8
0
 public LineCursorTextArea() {
   super();
   caret =
       new DefaultCaret() {
         @Override
         protected synchronized void damage(Rectangle r) {
           if (r != null) {
             JTextComponent c = getComponent();
             x = 0;
             y = r.y;
             width = c.getSize().width;
             height = r.height;
             c.repaint();
           }
         }
       };
   caret.setBlinkRate(getCaret().getBlinkRate());
   setCaret(caret);
 }
コード例 #9
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 /** Only show the flashing caret if the selection range is zero */
 @Override
 public void setVisible(boolean e) {
   if (e) e = getDot() == getMark();
   super.setVisible(e);
 }
コード例 #10
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 @Override
 public void deinstall(final JTextComponent c) {
   c.removePropertyChangeListener(this);
   super.deinstall(c);
 }
コード例 #11
0
ファイル: AquaCaret.java プロジェクト: FauxFaux/jdk9-jdk
 @Override
 public void install(final JTextComponent c) {
   super.install(c);
   isMultiLineEditor = c instanceof JTextArea || c instanceof JEditorPane;
   c.addPropertyChangeListener(this);
 }
コード例 #12
0
  /**
   * Constructs a X509 certificate panel.
   *
   * @param certificates <tt>X509Certificate</tt> objects
   */
  public X509CertificatePanel(Certificate[] certificates) {
    setLayout(new BorderLayout(5, 5));

    // Certificate chain list
    TransparentPanel topPanel = new TransparentPanel(new BorderLayout());
    topPanel.add(
        new JLabel(
            "<html><body><b>"
                + R.getI18NString("service.gui.CERT_INFO_CHAIN")
                + "</b></body></html>"),
        BorderLayout.NORTH);

    DefaultMutableTreeNode top = new DefaultMutableTreeNode();
    DefaultMutableTreeNode previous = top;
    for (int i = certificates.length - 1; i >= 0; i--) {
      Certificate cert = certificates[i];
      DefaultMutableTreeNode next = new DefaultMutableTreeNode(cert);
      previous.add(next);
      previous = next;
    }
    JTree tree = new JTree(top);
    tree.setBorder(new BevelBorder(BevelBorder.LOWERED));
    tree.setRootVisible(false);
    tree.setExpandsSelectedPaths(true);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setCellRenderer(
        new DefaultTreeCellRenderer() {

          @Override
          public Component getTreeCellRendererComponent(
              JTree tree,
              Object value,
              boolean sel,
              boolean expanded,
              boolean leaf,
              int row,
              boolean hasFocus) {
            JLabel component =
                (JLabel)
                    super.getTreeCellRendererComponent(
                        tree, value, sel, expanded, leaf, row, hasFocus);
            if (value instanceof DefaultMutableTreeNode) {
              Object o = ((DefaultMutableTreeNode) value).getUserObject();
              if (o instanceof X509Certificate) {
                component.setText(getSimplifiedName((X509Certificate) o));
              } else {
                // We don't know how to represent this certificate type,
                // let's use the first 20 characters
                String text = o.toString();
                if (text.length() > 20) {
                  text = text.substring(0, 20);
                }
                component.setText(text);
              }
            }
            return component;
          }
        });
    tree.getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {

              @Override
              public void valueChanged(TreeSelectionEvent e) {
                valueChangedPerformed(e);
              }
            });
    tree.setSelectionPath(
        new TreePath((((DefaultTreeModel) tree.getModel()).getPathToRoot(previous))));
    topPanel.add(tree, BorderLayout.CENTER);

    add(topPanel, BorderLayout.NORTH);

    // Certificate details pane
    Caret caret = infoTextPane.getCaret();
    if (caret instanceof DefaultCaret) {
      ((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    }

    /*
     * Make JEditorPane respect our default font because we will be using it
     * to just display text.
     */
    infoTextPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);

    infoTextPane.setOpaque(false);
    infoTextPane.setEditable(false);
    infoTextPane.setContentType("text/html");
    infoTextPane.setText(toString(certificates[0]));

    final JScrollPane certScroll = new JScrollPane(infoTextPane);
    certScroll.setPreferredSize(new Dimension(300, 500));
    add(certScroll, BorderLayout.CENTER);
  }