Example usage for javax.swing JComponent getName

List of usage examples for javax.swing JComponent getName

Introduction

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

Prototype

public String getName() 

Source Link

Document

Gets the name of the component.

Usage

From source file:org.springframework.richclient.layout.GridBagLayoutBuilder.java

private String getDebugString(Component component, GridBagConstraints gbc) {
    final StringBuffer buffer = new StringBuffer();

    if (component instanceof JComponent) {
        final JComponent jcomp = (JComponent) component;
        final String name = jcomp.getName();
        if (name != null && !"".equals(jcomp.getName())) {
            buffer.append(name);/*from  w w  w .j a v  a2 s  . c  o m*/
        } else {
            if (jcomp instanceof JLabel) {
                buffer.append(((JLabel) jcomp).getText());
            } else {
                buffer.append(jcomp.toString());
            }
        }
    } else {
        buffer.append(component.toString());
    }

    buffer.append(", ");
    buffer.append("GridBagConstraint[");
    buffer.append("anchor=").append(gbc.anchor).append(",");
    buffer.append("fill=").append(gbc.fill).append(",");
    buffer.append("gridheight=").append(gbc.gridheight).append(",");
    buffer.append("gridwidth=").append(gbc.gridwidth).append(",");
    buffer.append("gridx=").append(gbc.gridx).append(",");
    buffer.append("gridy=").append(gbc.gridy).append(",");
    buffer.append("weightx=").append(gbc.weightx).append(",");
    buffer.append("weighty=").append(gbc.weighty).append("]");
    return buffer.toString();
}