Java Code Examples for java.awt.Component#getClass()

The following examples show how to use java.awt.Component#getClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PumpernickelShowcaseApp.java    From pumpernickel with MIT License 6 votes vote down vote up
/**
 * Return the name of the showcase demo panel in the given component.
 */
private String getDemoName(Component c) {
	if (c instanceof LazyDemoPanel)
		c = ((LazyDemoPanel) c).showcaseDemo;
	Class z = c.getClass();
	if (z.getName().contains("pump.showcase."))
		return z.getSimpleName();
	if (c instanceof Container) {
		Container c2 = (Container) c;
		for (Component child : c2.getComponents()) {
			String n = getDemoName(child);
			if (n != null)
				return n;
		}
	}
	return null;
}
 
Example 2
Source File: Operator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates operator for component. Tries to find class with "operator
 * package"."class name"Operator name, where "operator package" is a package
 * from operator packages list, and "class name" is the name of class or one
 * of its superclasses.
 *
 * @param comp Component to create operator for.
 * @return a new operator with default environment.
 * @see #addOperatorPackage(String)
 */
public static ComponentOperator createOperator(Component comp) {
    //hack!
    try {
        Class<?> cclass = Class.forName("java.awt.Component");
        Class<?> compClass = comp.getClass();
        ComponentOperator result;
        do {
            if ((result = createOperator(comp, compClass)) != null) {
                return result;
            }
        } while (cclass.isAssignableFrom(compClass = compClass.getSuperclass()));
    } catch (ClassNotFoundException ignored) {
    }
    return null;
}
 
Example 3
Source File: GUIBrowser.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ComponentNode(Component comp) {
    super(comp.getClass());
    try {
        props = Operator.createOperator(comp).getDump();
    } catch (Exception e) {
        props = new Hashtable<>();
    }
    clss = comp.getClass().getName();
    compToString = comp.toString();
    this.comp = comp;
    x = comp.getLocationOnScreen().x;
    y = comp.getLocationOnScreen().y;
    w = comp.getWidth();
    h = comp.getHeight();
}
 
Example 4
Source File: Test6817933.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 5
Source File: Test6817933.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 6
Source File: Test6817933.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 7
Source File: Test6817933.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 8
Source File: Test6817933.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 9
Source File: Test6817933.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 10
Source File: Test6817933.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 11
Source File: Test6817933.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 12
Source File: Test6817933.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 13
Source File: OutlineViewOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean checkComponent(Component comp) {
           Class cls = comp.getClass();
           do {
               if(cls.getName().equals("org.openide.explorer.view.OutlineView")) {
                   return(subFinder.checkComponent(comp));
               }
           } while((cls = cls.getSuperclass()) != null);
    return(false);
}
 
Example 14
Source File: ParameterizedQueryDialog.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void addFocusListener(Component C) {
    C.getClass();
    super.getComponent().addFocusListener(
        new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent fe) {
                lostFocus();
            }
        });
}
 
Example 15
Source File: OutlineOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkComponent(Component comp) {
    Class cls = comp.getClass();
    do {
        if (cls.getName().equals("org.netbeans.swing.outline.Outline")) {
            return (subFinder.checkComponent(comp));
        }
    } while ((cls = cls.getSuperclass()) != null);
    return (false);
}
 
Example 16
Source File: TreeTableOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean checkComponent(Component comp) {
           Class cls = comp.getClass();
           do {
               if(cls.getName().equals("org.openide.explorer.view.TreeTable")) {
                   return(subFinder.checkComponent(comp));
               }
           } while((cls = cls.getSuperclass()) != null);
    return(false);
}
 
Example 17
Source File: Test6817933.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 18
Source File: Test6817933.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 19
Source File: Test6817933.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T get(Class<? extends T> type, Container container) {
    Component component = container.getComponent(0);
    if (!type.isAssignableFrom(component.getClass())) {
        throw new IllegalStateException("expected " + type + "; expected " + component.getClass());
    }
    return (T) component;
}
 
Example 20
Source File: RollingPanel.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
synchronized private final void updateList2() {
	final List<? extends Displayable> list = getList();
	final int count = getList().size();
	
	if (list.isEmpty()) {
		this.current.clear();
		if (this.inner.getComponentCount() > 0) {
			this.inner.removeAll();
			this.scrollBar.setMaximum(0);
			this.revalidate();
			//if (clazz == Patch.class) Utils.log2("empty list, removeAll, revalidate");
		}
		return;
	}

	final int numCanFit = (int)Math.floor(inner.getBounds().height / (float)DisplayablePanel.HEIGHT);
	
	if (!(this.scrollBar.getMaximum() == count && this.scrollBar.getVisibleAmount() == numCanFit)) {
		this.scrollBar.getModel().setRangeProperties(
				Math.max(0, this.scrollBar.getValue()),
				numCanFit,
				0, count, false);
	}

	this.current.clear();

	// Scrollbar value:
	int first = this.scrollBar.getValue();
	if (-1 == first) {
		this.scrollBar.setValue(0);
		first = 0;
	}
	// Correct for inverse list:
	first = list.size() - first -1;

	int last = first - numCanFit +1;
	if (last < 0) {
		first = Math.min(numCanFit, count) -1;
		last = 0;
	}

	// Reuse panels only if the exact same number is to be used
	final DisplayablePanel[] toReuse;
	final boolean notReusing;
	if (first - last + 1 != inner.getComponentCount() -1) {
		this.inner.removeAll();
		notReusing = true;
		toReuse = null;
	} else {
		notReusing = false;
		toReuse = new DisplayablePanel[first - last + 1];
		int i = 0;
		for (final Component c : inner.getComponents()) {
			if (DisplayablePanel.class == c.getClass()) {
				toReuse[i++] = (DisplayablePanel)c;
			}
		}
	}

	this.cInner.anchor = GridBagConstraints.NORTHWEST;
	this.cInner.fill = GridBagConstraints.HORIZONTAL;
	this.cInner.weightx = 0;
	this.cInner.weighty = 0;
	this.cInner.gridy = 0;
	for (int i=first, k=0; i >= last ; --i, ++k) {
		final Displayable d = list.get(i);
		final DisplayablePanel dp;
		if (notReusing) {
			dp = new DisplayablePanel(display, d);
			this.gbInner.setConstraints(dp, this.cInner);
			this.inner.add(dp);
			this.cInner.gridy += 1;
		} else {
			dp = toReuse[k];
			dp.set(d);
		}
		this.current.put(d, dp);
	}
	if (notReusing) {
		this.cInner.fill = GridBagConstraints.BOTH;
		this.cInner.weightx = 1;
		this.cInner.weighty = 1;
		this.gbInner.setConstraints(this.filler, this.cInner);
		this.inner.add(this.filler);
		this.inner.validate();
	}
}