Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.awt.Component;

import javax.swing.*;

public class Main {
    public static CharSequence getNamedPathToComponent(Component c) {
        StringBuilder sb = new StringBuilder();
        if (c instanceof JScrollPane) {
            sb.append(String.format(" -> %s", ((JScrollPane) c).getViewport().getView().getName()));
        }
        while (c != null) {
            if (c.getName() != null) {
                sb.append(String.format(" -> %s", c.getName()));
            }
            c = c.getParent();
        }
        return sb;
    }
}