Пример #1
0
 /**
  * Gets the <code>defaultLightWeightPopupEnabled</code> property, which by default is <code>true
  * </code>.
  *
  * @return the value of the <code>defaultLightWeightPopupEnabled</code> property
  * @see #setDefaultLightWeightPopupEnabled
  */
 public static boolean getDefaultLightWeightPopupEnabled() {
   Boolean b = (Boolean) SwingUtilities.appContextGet(defaultLWPopupEnabledKey);
   if (b == null) {
     SwingUtilities.appContextPut(defaultLWPopupEnabledKey, Boolean.TRUE);
     return true;
   }
   return b.booleanValue();
 }
Пример #2
0
 /**
  * Overrides <code>JComponent.removeNotify</code> to check if this button is currently set as the
  * default button on the <code>RootPane</code>, and if so, sets the <code>RootPane</code>'s
  * default button to <code>null</code> to ensure the <code>RootPane</code> doesn't hold onto an
  * invalid button reference.
  */
 public void removeNotify() {
   JRootPane root = SwingUtilities.getRootPane(this);
   if (root != null && root.getDefaultButton() == this) {
     root.setDefaultButton(null);
   }
   super.removeNotify();
 }
Пример #3
0
 /**
  * Gets the value of the <code>defaultButton</code> property, which if <code>true</code> means
  * that this button is the current default button for its <code>JRootPane</code>. Most look and
  * feels render the default button differently, and may potentially provide bindings to access the
  * default button.
  *
  * @return the value of the <code>defaultButton</code> property
  * @see JRootPane#setDefaultButton
  * @see #isDefaultCapable
  * @beaninfo description: Whether or not this button is the default button
  */
 public boolean isDefaultButton() {
   JRootPane root = SwingUtilities.getRootPane(this);
   if (root != null) {
     return root.getDefaultButton() == this;
   }
   return false;
 }
Пример #4
0
 private boolean checkRightMargin(int w) {
   // Make sure rightMargin has at least 2 pixels over
   if (w + 2 > rightMargin) {
     rightMargin = (w + 2);
     // Repaint from top (above any cell renderers)
     SwingUtilities.getWindowAncestor(this).repaint();
     return true;
   }
   return false;
 }
Пример #5
0
 private boolean checkLeftMargin(int x) {
   // Make sure leftMargin has at least 2 pixels over
   if (x < 2) {
     leftMargin += (2 - x);
     // Repaint from top (above any cell renderers)
     SwingUtilities.getWindowAncestor(this).repaint();
     return true;
   }
   return false;
 }
Пример #6
0
 public void actionPerformed(ActionEvent e) {
   if (owner != null && SwingUtilities.getRootPane(owner) == root) {
     ButtonModel model = owner.getModel();
     if (press) {
       model.setArmed(true);
       model.setPressed(true);
     } else {
       model.setPressed(false);
     }
   }
 }
Пример #7
0
  /**
   * {@inheritDoc}
   *
   * @since 1.7
   */
  public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
    if (!isShowing()) {
      return false;
    }

    // Check that there is a label with such image
    Enumeration elements = labelTable.elements();

    while (elements.hasMoreElements()) {
      Component component = (Component) elements.nextElement();

      if (component instanceof JLabel) {
        JLabel label = (JLabel) component;

        if (SwingUtilities.doesIconReferenceImage(label.getIcon(), img)
            || SwingUtilities.doesIconReferenceImage(label.getDisabledIcon(), img)) {
          return super.imageUpdate(img, infoflags, x, y, w, h);
        }
      }
    }

    return false;
  }
Пример #8
0
 @SuppressWarnings("unchecked")
 private static JButton getButton(JList list, Point pt, int index) {
   Container c =
       (Container)
           list.getCellRenderer().getListCellRendererComponent(list, "", index, false, false);
   Rectangle r = list.getCellBounds(index, index);
   c.setBounds(r);
   // c.doLayout(); //may be needed for mone LayoutManager
   pt.translate(-r.x, -r.y);
   Component b = SwingUtilities.getDeepestComponentAt(c, pt.x, pt.y);
   if (b instanceof JButton) {
     return (JButton) b;
   } else {
     return null;
   }
 }
Пример #9
0
 /**
  * Sets the {@code transferHandler} property, which is a mechanism to support transfer of data
  * into this component. Use {@code null} if the component does not support data transfer
  * operations.
  *
  * <p>If the system property {@code suppressSwingDropSupport} is {@code false} (the default) and
  * the current drop target on this component is either {@code null} or not a user-set drop target,
  * this method will change the drop target as follows: If {@code newHandler} is {@code null} it
  * will clear the drop target. If not {@code null} it will install a new {@code DropTarget}.
  *
  * <p>Note: When used with {@code JApplet}, {@code TransferHandler} only provides data import
  * capability, as the data export related methods are currently typed to {@code JComponent}.
  *
  * <p>Please see <a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html">How to
  * Use Drag and Drop and Data Transfer</a>, a section in <em>The Java Tutorial</em>, for more
  * information.
  *
  * @param newHandler the new {@code TransferHandler}
  * @see TransferHandler
  * @see #getTransferHandler
  * @see java.awt.Component#setDropTarget
  * @since 1.6
  * @beaninfo bound: true hidden: true description: Mechanism for transfer of data into the
  *     component
  */
 public void setTransferHandler(TransferHandler newHandler) {
   TransferHandler oldHandler = transferHandler;
   transferHandler = newHandler;
   SwingUtilities.installSwingDropTargetAsNecessary(this, transferHandler);
   firePropertyChange("transferHandler", oldHandler, newHandler);
 }
Пример #10
0
 /**
  * Sets the default value of the <code>lightWeightPopupEnabled</code> property.
  *
  * @param aFlag <code>true</code> if popups can be lightweight, otherwise <code>false</code>
  * @see #getDefaultLightWeightPopupEnabled
  * @see #setLightWeightPopupEnabled
  */
 public static void setDefaultLightWeightPopupEnabled(boolean aFlag) {
   SwingUtilities.appContextPut(defaultLWPopupEnabledKey, Boolean.valueOf(aFlag));
 }