public boolean checkComponent(Component comp) { JLabel jLabel = (JLabel) comp; String text = jLabel.getText(); if (text == null || nameAndLocationLabel.equals(text)) { return false; } else if (text.indexOf(nameLabel) > -1 && (jLabel.getLabelFor() == null || jLabel.getLabelFor() instanceof JTextField)) { return true; } return false; }
private JLabel findLabelFor(JComponent component) { Optional<Component> label = Arrays.stream(component.getParent().getComponents()) .filter(c -> c instanceof JLabel && component.equals(((JLabel) c).getLabelFor())) .findFirst(); return label.map(component1 -> (JLabel) component1).orElse(null); } }
@Nonnull private <T> T labelFor(@Nonnull Component label, @Nonnull Class<T> type) { assertThat(label).isInstanceOf(JLabel.class); Component target = ((JLabel) label).getLabelFor(); assertThat(target).isInstanceOf(type); return type.cast(target); }
&& (((JLabel) opposite).getLabelFor() == tfClassToTest)) {
Component labelFor = lbl.getLabelFor(); if ((labelFor != null) && (labelFor != tfClassToTest) && (lbl.getDisplayedMnemonic() != 0)) {
/** * Checks and answers whether the given component shall be set * as component for a previously added label using * {@link JLabel#setLabelFor(Component)}. * * This default implementation checks whether the component is focusable, * and - if a JComponent - whether it is already labeled by a JLabel. * Subclasses may override. * * @param label the candidate for labeling {@code component} * @param component the component that could be labeled by {@code label} * @return true if focusable, false otherwise */ protected boolean isLabelForApplicable(JLabel label, Component component) { // 1) Is the label labeling a component? if (label.getLabelFor() != null) { return false; } // 2) Is the component focusable? if (!component.isFocusable()) { return false; } // 3) Is the component labeled by another label? if (!(component instanceof JComponent)) { return true; } JComponent c = (JComponent) component; return c.getClientProperty(LABELED_BY_PROPERTY) == null; }
return false; Component labeled = labelForComponent.getLabelFor(); return type.isInstance(labeled) && requireShowingMatches(checkNotNull(labeled));
if (c instanceof JLabel) { JLabel lb = (JLabel) c; if (lb.getLabelFor() == null) { Component tg = (Component) v.elementAt(i + 1); if (!tg.isFocusable() && (tg instanceof Container)) { int mn = lb.getDisplayedMnemonic(); if (auto && (mn <= 0) && (lb.getLabelFor() != null)) { String tx = candidateMnemonics(lb.getText()); if (tx != null) for (int j = 0; j < tx.length(); j++) {
Component c = label.getLabelFor(); JTextField tf = (JTextField) c; tf.setText(value); Component c = label.getLabelFor(); JTextField tf = (JTextField) c; prop.put(label.getText(), tf.getText());
&& (((JLabel) opposite).getLabelFor() == tfClassToTest)) {