Example usage for javax.swing JComponent setName

List of usage examples for javax.swing JComponent setName

Introduction

In this page you can find the example usage for javax.swing JComponent setName.

Prototype

public void setName(String name) 

Source Link

Document

Sets the name of the component to the specified string.

Usage

From source file:com.all.login.view.NewAccountFormPanel.java

private void settingsForRightText(JComponent field, String originalName) {
    field.setToolTipText(null);
    field.setName(originalName);
}

From source file:com.all.login.view.NewAccountFormPanel.java

private void showViolationMessage(JComponent field, String propertyName,
        Set<ConstraintViolation<RegisterUserCommand>> violations) {
    field.setName("invalidTextField34" + propertyName);
    StringBuffer sb = new StringBuffer();
    HashMap<String, String> map = new HashMap<String, String>();
    for (ConstraintViolation<RegisterUserCommand> violation : violations) {
        map.put(violation.getMessage(), "");
    }//from  ww w.jav a 2  s.  c om
    Set<String> messages = map.keySet();
    for (String violation : messages) {
        sb.append(violation);
    }
    field.setToolTipText(sb.toString());
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopFieldGroup.java

@Override
public void setId(String id) {
    super.setId(id);

    if (id != null && App.getInstance().isTestMode()) {
        for (FieldConfig fc : fields.values()) {
            Component fieldComponent = fc.getComponent();
            if (fieldComponent != null) {
                JComponent jComponent = DesktopComponentsHelper.getComposition(fieldComponent);
                if (jComponent != null) {
                    jComponent.setName(fc.getId());
                }/*from w w  w  .  j av  a 2s .  c  o  m*/
            }
        }
    }
}

From source file:com.isencia.passerelle.hmi.generic.GenericHMI.java

/**
 * @param e//w  w  w.  j  a  v  a2 s  . c  om
 * @param b
 * @return true if a form was effectively rendered, i.e. when at least 1
 *         parameter was available
 */
@SuppressWarnings("unchecked")
private boolean renderCompositeModelComponent(final CompositeActor e, final JPanel b) {
    if (logger.isDebugEnabled()) {
        logger.debug("renderCompositeModelComponent() - Entity " + e.getFullName()); //$NON-NLS-1$ //$NON-NLS-2$
    }

    final IPasserelleEditorPaneFactory epf = getEditorPaneFactoryForComponent(e);
    final IPasserelleQuery pQuery = epf.createEditorPaneWithAuthorizer(e, this, this);
    final JComponent c = (JComponent) pQuery.getPasserelleComponent();

    if (pQuery != null) {
        boolean nonEmptyForm = !(pQuery instanceof PasserelleEmptyQuery);
        // remove the default message in an empty query
        if (!nonEmptyForm) {
            ((PasserelleEmptyQuery) pQuery).setText("");
        } else if (!pQuery.hasAutoSync()) {
            try {
                final Set<ParameterToWidgetBinder> queryBindings = pQuery.getParameterBindings();
                for (final ParameterToWidgetBinder parameterToWidgetBinder : queryBindings) {
                    hmiFields.put(parameterToWidgetBinder.getBoundParameter().getFullName(),
                            parameterToWidgetBinder);
                }
            } catch (final Exception exception) {
                throw new RuntimeException("Error creating bindings for passerelleQuery", exception);
            }
        }

        final String name = ModelUtils.getFullNameButWithoutModelName(getCurrentModel(), e);
        final List subActors = e.entityList();
        // TODO: && changed by || because was not displaying parameters for
        // composite
        // still a problem of display with multiactor
        if (pQuery instanceof PasserelleQuery || !subActors.isEmpty()) {
            final JPanel compositeBox = createCompositePanel(b, c, name);
            renderModelComponentAnnotations(e, compositeBox);
            for (final Iterator<NamedObj> subActorItr = subActors.iterator(); subActorItr.hasNext();) {
                final NamedObj subActor = subActorItr.next();
                nonEmptyForm |= renderModelComponent(true, subActor, compositeBox);
            }
            if (nonEmptyForm) {
                b.add(compositeBox);
                StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, name, c);
                StateMachine.getInstance().compile();
            }
            return nonEmptyForm;
        } else if (!(pQuery instanceof PasserelleEmptyQuery)) {
            // System.out.println("else name" + name);
            c.setName(name);
            c.setBorder(BorderFactory.createTitledBorder(name));
            b.add(c);
            StateMachine.getInstance().registerActionForState(StateMachine.MODEL_OPEN, name, c);
            StateMachine.getInstance().compile();
            return true;
        }
    }
    // System.out.println("renderComposite - out");
    return false;
}

From source file:org.codinjutsu.tools.jenkins.view.BuildParamDialog.java

private void addParameterInputs() {
    contentPanel.setLayout(new SpringLayout());
    List<JobParameter> parameters = job.getParameters();

    for (JobParameter jobParameter : parameters) {
        JComponent inputField = createInputField(jobParameter);

        String name = jobParameter.getName();
        inputField.setName(name);

        JLabel label = new JLabel();
        label.setHorizontalAlignment(JLabel.TRAILING);
        label.setLabelFor(inputField);/*from w  ww  .  j  a va  2s.  co m*/

        if (StringUtils.isEmpty(name)) {
            name = MISSING_NAME_LABEL;
            label.setIcon(ERROR_ICON);
            hasError = true;
        }
        label.setText(name + ":");

        contentPanel.add(label);
        contentPanel.add(inputField);

        inputFieldByParameterMap.put(jobParameter, inputField);
    }

    SpringUtilities.makeCompactGrid(contentPanel, parameters.size(), 2, 6, 6, //initX, initY
            6, 6); //xPad, yPad

    if (hasError) {
        buttonOK.setEnabled(false);
    }
}

From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java

/**
 * @param clctef// w w w .  j av  a2s .com
 * @param comp
 * @param bSearchable
 * @precondition clctef != null
 * @precondition comp != null
 * @postcondition isSearchComponent() == bSearchable
 */
protected AbstractCollectableComponent(CollectableEntityField clctef, JComponent comp, boolean bSearchable) {
    if (clctef == null) {
        throw new NullArgumentException("clctef");
    }
    if (comp == null) {
        throw new NullArgumentException("comp");
    }
    this.clctef = clctef;
    this.comp = comp;

    try {
        dataTyp = getDataTyp(clctef.getJavaClass().getName(), clctef.getDefaultComponentType(),
                clctef.getMaxLength(), clctef.getPrecision(), clctef.getFormatInput(),
                clctef.getFormatOutput());
    } catch (CommonPermissionException e) {
        throw new NuclosFatalException(e);
    } catch (CommonFinderException e) {
        throw new NuclosFatalException(e);
    }

    // set the name of the JComponent so it can be identified by GUI testing tools:
    comp.setName(getFieldName());
    this.bSearchable = bSearchable;
    setModel(CollectableComponentModel.newCollectableComponentModel(clctef, bSearchable));

    if (isSearchComponent() && hasComparisonOperator()) {
        setComparisonOperator(ComparisonOperator.NONE);
    }

    setupJPopupMenuListener(newJPopupMenuListener());

    assert isSearchComponent() == bSearchable;
}

From source file:tufts.vue.ui.InspectorPane.java

private static void setTypeName(JComponent component, LWComponent c, String suffix) {
    final String type;

    if (c == null)
        type = null;/*from w w w.j  av  a2 s . co m*/
    else if (DEBUG.Enabled)
        type = c.getUniqueComponentTypeLabel();
    else
        type = c.getComponentTypeLabel();

    String title;
    if (suffix != null) {
        if (type == null)
            title = suffix;
        else
            title = type + " " + suffix;
    } else
        title = type;

    component.setName(title);
}

From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.utils.ViewComponentManager.java

private void addComponentToPosition(ViewComponent component) {

    // set LNF first to avoid component UI errors
    LookAndFeelUtils.setDefaultLNF();/*w w  w  . j a v a2s.  c  o  m*/
    String name = component.getName();
    String title = component.getTitle();
    Icon icon = component.getIcon();
    ViewComponent.Alignment alignment = component.getAlignment();
    JComponent innerComponent = component.getComponent();
    SwingUtilities.updateComponentTreeUI(innerComponent);
    innerComponent.setName(name);

    /*
    Replace all previous implementations with a simple placement. In the newer, simpler model,
    the following alignments are added as tool windows : LEFT, RIGHT, BOTTOM
    the following alignments are added as tabbed windows : TOP, CENTRE
    */

    if (ViewComponent.Alignment.CENTRE == alignment && !componentNames.contains(name)) {
        // get component and add as tabbed panel
        contentManager.addContent(title, title, icon, innerComponent, null,
                new MultiSplitConstraint(AggregationPosition.BOTTOM));
        logger.info("Added view component : " + name + " to centre window");
        // add to component names
        componentNames.add(component.getName());
    } else if (ViewComponent.Alignment.TOP == alignment && !componentNames.contains(name)) {
        // get component and add as tabbed panel
        contentManager.addContent(title, title, icon, innerComponent, null,
                new MultiSplitConstraint(AggregationPosition.TOP));
        logger.info("Added view component : " + name + " to top window");
        // add to component names
        componentNames.add(component.getName());
    } else if (ViewComponent.Alignment.LEFT == alignment && !componentNames.contains(name)) {
        // create tool window and make it available
        toolWindowManager.registerToolWindow(title, title, icon, innerComponent, ToolWindowAnchor.LEFT);
        toolWindowManager.getToolWindow(title).setAvailable(true);
        // set active if set to show on active
        if (component.isActiveOnInitialise()) {
            toolWindowManager.getToolWindow(title).setActive(true);
        }
        logger.info("Added view component : " + name + " as tool in LEFT position.");
        // add to component names
        componentNames.add(component.getName());
    } else if (ViewComponent.Alignment.RIGHT == alignment && !componentNames.contains(name)) {
        // create tool window and make it available
        toolWindowManager.registerToolWindow(title, title, icon, innerComponent, ToolWindowAnchor.RIGHT);
        toolWindowManager.getToolWindow(title).setAvailable(true);
        // set active if set to show on active
        if (component.isActiveOnInitialise()) {
            toolWindowManager.getToolWindow(title).setActive(true);
        }
        logger.info("Added view component : " + name + " as tool in RIGHT position.");
        // add to component names
        componentNames.add(component.getName());
    } else if (ViewComponent.Alignment.BOTTOM == alignment && !componentNames.contains(name)) {
        // create tool window and make it available
        toolWindowManager.registerToolWindow(title, title, icon, innerComponent, ToolWindowAnchor.BOTTOM);
        toolWindowManager.getToolWindow(title).setAvailable(true);
        // set active if set to show on active
        if (component.isActiveOnInitialise()) {
            toolWindowManager.getToolWindow(title).setActive(true);
        }
        logger.info("Added view component : " + name + " as tool in BOTTOM position.");
        // add to component names
        componentNames.add(component.getName());
    } else if (alignment == null && !componentNames.contains(name)) {
        // warn user that unknown alignment found
        logger.warn("Unknown alignment found. Alignment = " + alignment);
        // add to bottom tool window
        applicationView.getToolWindowManager().registerToolWindow(title, title, icon, innerComponent,
                ToolWindowAnchor.BOTTOM);
        toolWindowManager.getToolWindow(title).setAvailable(true);
        // set active if set to show on active
        if (component.isActiveOnInitialise()) {
            toolWindowManager.getToolWindow(title).setActive(true);
        }
        logger.info("Added view component : " + name + " as bottom tool window");
        // add to component names
        componentNames.add(component.getName());
    } else if (componentNames.contains(name)) {
        logger.warn("Component has already been added to application.");
        throw new IllegalArgumentException("Component has already been added to application.");
    }
}