Example usage for javax.swing JComponent getClass

List of usage examples for javax.swing JComponent getClass

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:de.unentscheidbar.validation.swing.trigger.ChangeTriggerTest.java

@Override
protected Trigger<? super JComponent> getTriggerUnderTest(JComponent c) {

    if (rnd.nextBoolean()) {
        return Triggers.onChange(c);
    } else {// w ww  . j  a  v  a 2s .  c o  m
        return Triggers.onChange(c.getClass());
    }
}

From source file:de.unentscheidbar.validation.swing.trigger.SelectionChangeTrigger.java

private void doUnregister(JComponent c, SelectionChangeListener l) {

    if (c instanceof JTable) {
        ((JTable) c).getSelectionModel().removeListSelectionListener(l);
    } else if (c instanceof JList<?>) {
        ((JList<?>) c).getSelectionModel().removeListSelectionListener(l);
    } else if (c instanceof JTree) {
        ((JTree) c).addTreeSelectionListener(l);
    } else {/*from  w w w  . j  a v a2s  . co m*/
        MethodChain removeListenerMethod = getRemoveMethod(c.getClass());
        if (removeListenerMethod == null)
            throw new UnsupportedClassException(c);
        removeListenerMethod.invokeQuietly(c, l);
    }
}

From source file:de.unentscheidbar.validation.swing.trigger.SelectionChangeTrigger.java

private SelectionChangeListener doRegister(JComponent c) {

    SelectionChangeListener l = new SelectionChangeListener(this, c);
    if (c instanceof JTable) {
        ((JTable) c).getSelectionModel().addListSelectionListener(l);
    } else if (c instanceof JList<?>) {
        ((JList<?>) c).getSelectionModel().addListSelectionListener(l);
    } else if (c instanceof JTree) {
        ((JTree) c).addTreeSelectionListener(l);
    } else {/*from w  w  w. java 2  s  .c o  m*/
        MethodChain addListenerMethod = getAddMethod(c.getClass());
        if (addListenerMethod == null)
            throw new UnsupportedClassException(c);
        addListenerMethod.invokeQuietly(c, l);
    }
    return l;
}

From source file:com.lottery.gui.MainLotteryForm.java

private void setPanelEnabled(JPanel panel, Boolean isEnabled) {
    panel.setEnabled(isEnabled);/*from  ww w .j av a 2 s. co  m*/

    for (int i = 0; i < panel.getComponents().length; i++) {
        JComponent component = (JComponent) panel.getComponents()[i];
        if (component.getClass().getName() == "javax.swing.JPanel") {
            setPanelEnabled((JPanel) component, isEnabled);
        }

        component.setEnabled(isEnabled);
    }
}

From source file:de.unentscheidbar.validation.swing.trigger.ChangeTrigger.java

private void doUnregister(JComponent c, Object l) {

    if (c instanceof JComboBox<?>) {
        ((JComboBox<?>) c).removeItemListener((ItemListener) l);
    } else if (c instanceof JColorChooser) {
        ((JColorChooser) c).getSelectionModel().removeChangeListener((ChangeListener) l);
    } else if (c instanceof JSlider) {
        ((JSlider) c).addChangeListener((ChangeListener) l);
    } else if (c instanceof JSpinner) {
        ((JSpinner) c).addChangeListener((ChangeListener) l);
    } else if (c instanceof JTable) {
        ((JTable) c).getModel().addTableModelListener((TableModelListener) l);
    } else {//  www.j  av a  2s.c  o  m
        MethodChain removeChangeListenerMethod = getRemoveMethod(c.getClass());
        if (removeChangeListenerMethod == null)
            throw new UnsupportedClassException(c);
        removeChangeListenerMethod.invokeQuietly(c, (ChangeListener) l);
    }
}

From source file:de.unentscheidbar.validation.swing.trigger.ChangeTrigger.java

private Object doRegister(JComponent c) {

    ComponentChangeListener l = new ComponentChangeListener(this, c);
    Object result = l;//from w w w  .  j  av a2s.  c o m
    if (c instanceof JComboBox<?>) {
        ItemListener il = new ItemChangeListener(this, c);
        result = il;
        ((JComboBox<?>) c).addItemListener(il);
    } else if (c instanceof JRadioButton) {
        ItemListener il = new ItemChangeListener(this, c);
        result = il;
        ((JRadioButton) c).addItemListener(il);
    } else if (c instanceof JCheckBox) {
        ItemListener il = new ItemChangeListener(this, c);
        result = il;
        ((JCheckBox) c).addItemListener(il);
    } else if (c instanceof JColorChooser) {
        ((JColorChooser) c).getSelectionModel().addChangeListener(l);
    } else if (c instanceof JSlider) {
        ((JSlider) c).addChangeListener(l);
    } else if (c instanceof JSpinner) {
        ((JSpinner) c).addChangeListener(l);
    } else if (c instanceof JTable) {
        TableChangeListener tl = new TableChangeListener(this, c);
        result = tl;
        ((JTable) c).getModel().addTableModelListener(tl);
    } else {
        MethodChain addChangeListenerMethod = getAddMethod(c.getClass());
        if (addChangeListenerMethod == null)
            throw new UnsupportedClassException(c);
        addChangeListenerMethod.invokeQuietly(c, l);
    }
    return result;
}

From source file:net.sourceforge.squirrel_sql.fw.gui.debug.DebugEventListener.java

private void setToolTipText(JComponent source, AWTEvent event) {

    Container parent = source.getParent();
    String sourceName = source.getName();
    String sourceClassName = source.getClass().toString();
    String parentClassName = parent == null ? null : parent.getClass().toString();

    StringBuilder toolTipText = new StringBuilder(getEventMessagePrefix(event));

    if (source instanceof AbstractButton) {
        toolTipText.append("Button with parentClass=");
        toolTipText.append(parentClassName);
    } else {//from w ww. j  a  v  a  2  s .com
        if (!StringUtils.isEmpty(sourceName)) {
            toolTipText.append(sourceName);
        } else if (!StringUtils.isEmpty(sourceClassName)) {
            toolTipText.append(sourceClassName);
        }
    }
    source.setToolTipText(toolTipText.toString());
}

From source file:net.sourceforge.squirrel_sql.fw.gui.debug.DebugEventListener.java

private void printDebugInfo(JComponent source, AWTEvent event) {
    Container parent = source.getParent();
    String sourceName = source.getName();
    String sourceClassName = source.getClass().toString();
    String parentName = parent == null ? null : parent.getName();
    String parentClassName = parent == null ? null : parent.getClass().toString();

    StringBuilder msg = new StringBuilder(getEventMessagePrefix(event));
    msg.append("\n");
    msg.append("\t sourceName:").append(sourceName).append("\n");
    msg.append("\t sourceClassName:").append(sourceClassName).append("\n");
    msg.append("\t parentName:").append(parentName).append("\n");
    msg.append("\t parentClassName:").append(parentClassName);
    System.out.println(msg.toString());
}