javax.swing.JComponent.getClientProperty()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(227)

本文整理了Java中javax.swing.JComponent.getClientProperty()方法的一些代码示例,展示了JComponent.getClientProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.getClientProperty()方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:getClientProperty

JComponent.getClientProperty介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

String hid = (String) jc.getClientProperty("HelpID"); // NOI18N

代码示例来源:origin: org.codehaus.groovy/groovy

public void actionPerformed(ActionEvent ae) {
  Token token = (Token) ((JComponent) ae.getSource()).getClientProperty("token");
  if (token.getType() == Token.EOF_TYPE) {
    scriptPane.select(0, 0);
    return;
  }
  try {
    int start = scriptPane.getLineStartOffset(token.getLine() - 1) + token.getColumn() - 1;
    scriptPane.select(start, start + token.getText().length());
    scriptPane.requestFocus();
  } catch (BadLocationException ex) {
    // IGNORE
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

/** Tryes to get dimension of wizard panel's left pane from getProperty()
 * if doesn't succeed then tryes at
 * supplied <CODE>JComponent</CODE>s client property.
 * @return <CODE>Dimension</CODE> dimension of wizard panel's left pane
 */
private Dimension getLeftDimension(JComponent c) {
  Dimension leftDimension;
  Object property = c.getClientProperty(PROP_LEFT_DIMENSION);
  if (property instanceof Dimension) {
    leftDimension = (Dimension) property;
  } else {
    leftDimension = new Dimension(198, 233);
  }
  return leftDimension;
}

代码示例来源:origin: apache/pdfbox

@Override
  public void actionPerformed(ActionEvent actionEvent)
  {
    String filePath = (String) ((JComponent) actionEvent.getSource()).getClientProperty("path");
    try
    {
      readPDFFile(filePath, "");
    }
    catch (Exception e)
    {
      throw new RuntimeException(e);
    }
  }
};

代码示例来源:origin: org.netbeans.api/org-openide-awt

static void prepareMenuBridgeItemsInContainer(Container c) {
  Component[] comps = c.getComponents();
  for (int i = 0; i < comps.length; i++) {
    if (comps[i] instanceof JComponent) {
      JComponent cop = (JComponent) comps[i];
      MenuBridge bridge = (MenuBridge) cop.getClientProperty("menubridgeresizehack");
      if (bridge != null) {
        bridge.updateState(null);
      }
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

/** Tryes to get property from getProperty() if doesn't succeed then tryes at
 * supplied <CODE>JComponent</CODE>s client property.
 * @param c origin of property
 * @param s name of property
 * @return boolean property
 */
private boolean getBooleanProperty(JComponent c, String s) {
  Object property = getProperty(s);
  if (property instanceof Boolean) {
    return ((Boolean) property).booleanValue();
  }
  property = c.getClientProperty(s);
  if (property instanceof Boolean) {
    return ((Boolean) property).booleanValue();
  }
  return false;
}

代码示例来源:origin: ron190/jsql-injection

/**
 * Paints the border for the specified component with the specified
 * position and size.
 */
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  // Fix #7497, Fix #8247, Fix #8332: BufImgSurfaceData cannot be cast to XRSurfaceData on drawImage()
  try {
    // fake drop shadow effect in case of heavy weight popups
    JComponent popup = (JComponent) c;
    Image hShadowBg = (Image) popup.getClientProperty(ShadowPopupFactory.PROP_HORIZONTAL_BACKGROUND);
    if (hShadowBg != null) {
      g.drawImage(hShadowBg, x, y + height - 5, c);
    }
    Image vShadowBg = (Image) popup.getClientProperty(ShadowPopupFactory.PROP_VERTICAL_BACKGROUND);
    if (vShadowBg != null) {
      g.drawImage(vShadowBg, x + width - 5, y, c);
    }

    // draw drop shadow
    g.drawImage(shadow, x +  5, y + height - 5, x + 10, y + height, 0, 6, 5, 11, null, c);
    g.drawImage(shadow, x + 10, y + height - 5, x + width - 5, y + height, 5, 6, 6, 11, null, c);
    g.drawImage(shadow, x + width - 5, y + 5, x + width, y + 10, 6, 0, 11, 5, null, c);
    g.drawImage(shadow, x + width - 5, y + 10, x + width, y + height - 5, 6, 5, 11, 6, null, c);
    g.drawImage(shadow, x + width - 5, y + height - 5, x + width, y + height, 6, 6, 11, 11, null, c);
  } catch (ClassCastException e) {
    LOGGER.error(e.getMessage(), e);
  }
}

代码示例来源:origin: jbox2d/jbox2d

public void stateChanged(ChangeEvent e) {
 JComponent component = (JComponent) e.getSource();
 TestbedSetting setting = (TestbedSetting) component.getClientProperty(SETTING_TAG);
 switch (setting.constraintType) {
  case BOOLEAN:
   JCheckBox box = (JCheckBox) e.getSource();
   setting.enabled = box.isSelected();
   break;
  case RANGE:
   JSlider slider = (JSlider) e.getSource();
   setting.value = slider.getValue();
   JLabel label = (JLabel) slider.getClientProperty(LABEL_TAG);
   label.setText(setting.name + ": " + setting.value);
   break;
 }
 model.getPanel().grabFocus();
}

代码示例来源:origin: org.netbeans.api/org-openide-awt

Object qso = component.getClientProperty(CLIENT_PROPERTY_KEY);
if (qso instanceof QuickSearch) {
  throw new IllegalStateException("A quick search is attached to this component already, detach it first."); // NOI18N

代码示例来源:origin: org.netbeans.api/org-openide-util-ui

String hid = (String) jc.getClientProperty("HelpID"); // NOI18N

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

contentSelectedIndex = ((Integer) property).intValue();
} else {
  property = c.getClientProperty(PROP_CONTENT_SELECTED_INDEX);
  contentData = (String[]) property;
} else {
  property = c.getClientProperty(PROP_CONTENT_DATA);
  image = (Image) property;
} else if ((properties == null) || (!properties.containsKey(PROP_IMAGE))) {
  property = c.getClientProperty(PROP_IMAGE);
  imageAlignment = (String) property;
} else {
  property = c.getClientProperty(PROP_IMAGE_ALIGNMENT);
  contentBackColor = (Color) property;
} else {
  property = c.getClientProperty(PROP_CONTENT_BACK_COLOR);
  contentForegroundColor = (Color) property;
} else {
  property = c.getClientProperty(PROP_CONTENT_FOREGROUND_COLOR);
property = c.getClientProperty(PROP_HELP_URL);

代码示例来源:origin: org.netbeans.api/org-openide-awt

&& Boolean.TRUE.equals(((JComponent) comps[0]).getClientProperty(PROP_DRAGGER))) {
visibleButtons = 1; // always include the dragger if present

代码示例来源:origin: freeplane/freeplane

private ExternalResource getModel(final MouseEvent e) {
  final JComponent component = (JComponent) e.getComponent();
  final ExternalResource model = (ExternalResource) component.getClientProperty(ExternalResource.class);
  return model;
}

代码示例来源:origin: com.jidesoft/jide-oss

protected static boolean isActive(JComponent jcomponent) {
  if (jcomponent == null)
    return true;
  Object obj = jcomponent.getClientProperty("Frame.active");
  return !Boolean.FALSE.equals(obj);
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

/**
 * Find the currently in use tabbed container, if any
 */
private JComponent findTabbedContainer() {
  Component[] c = getComponents();
  for (int i = 0; i < c.length; i++) {
    if (c[i] instanceof JComponent && Boolean.TRUE.equals(((JComponent) c[i]).getClientProperty("tc"))) {
      return (JComponent) c[i];
    }
  }
  return null;
}

代码示例来源:origin: freeplane/freeplane

public void actionPerformed(ActionEvent e) {
  final JComponent mapViewComponent = getMapViewComponent();
  if(mapViewComponent != null) {
    final Boolean value = Boolean.TRUE.equals(mapViewComponent.getClientProperty(propertyName));
    boolean newValue = ! value.booleanValue();
    mapViewComponent.putClientProperty(propertyName, newValue);
    setSelected(newValue);
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

/**
 * Register a child of a JScrollPane (only JList or JTree supported 
 * for now) which should show helper tooltips.  Should be called
 * from the component's addNotify() method.
 */
synchronized static void register (JComponent comp) {
  ViewTooltips vtt = (ViewTooltips) comp.getClientProperty(KEY);
  assert vtt == null : "There already is " + vtt + " for " + comp;
  comp.putClientProperty(KEY, vtt = new ViewTooltips());
  vtt.attachTo (comp);
}

代码示例来源:origin: dcaoyuan/nbscala

public void readSettings(Object settings) {
  wizardDescriptor = (WizardDescriptor)settings;        
  component.read (wizardDescriptor);
  
  // XXX hack, TemplateWizard in final setTemplateImpl() forces new wizard's title
  // this name is used in NewProjectWizard to modify the title
  Object substitute = ((JComponent)component).getClientProperty ("NewProjectWizard_Title"); // NOI18N
  if (substitute != null) {
    wizardDescriptor.putProperty ("NewProjectWizard_Title", substitute); // NOI18N
  }
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@Override
protected void applyForeground(Component renderer, ComponentAdapter adapter) {
  if (!adapter.isSelected()) {
    Object colorMemory = ((JComponent) renderer).getClientProperty("rendererColorMemory.foreground");
    if (colorMemory instanceof ColorMemory) {
      renderer.setForeground(((ColorMemory) colorMemory).color);
    } else {
      ((JComponent) renderer).putClientProperty("rendererColorMemory.foreground", new ColorMemory(renderer.getForeground()));
    }
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

@Override
public Dimension getMaximumSize(JComponent c) {
  Dimension d = getPreferredSize(c);
  View v = (View) c.getClientProperty(BasicHTML.propertyKey);
  if (v != null) {
    d.width += v.getMaximumSpan(View.X_AXIS) - v.getPreferredSpan(View.X_AXIS);
  }
  return d;
}

相关文章

JComponent类方法