org.fxmisc.wellbehaved.skin.ComplexVisualBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of richtextfx Show documentation
Show all versions of richtextfx Show documentation
FX-Text-Area for formatted text and other special effects.
package org.fxmisc.wellbehaved.skin;
import java.lang.reflect.Method;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.control.Control;
/**
* Base class for Visuals that need to manipulate control's child list directly.
* An implementation of this class is responsible for attaching any nodes to
* control's child list as well as removing them on {@link #dispose()}.
* @param type of the control.
*
* @deprecated Since 0.3. We have come to believe that skins, as designed in
* JavaFX, are not very useful and not worth the trouble. Package
* {@link org.fxmisc.wellbehaved.skin} will be removed in a future version.
*/
@Deprecated
public abstract class ComplexVisualBase extends VisualBase {
private final ObservableList children;
@SuppressWarnings("unchecked")
public ComplexVisualBase(C control) {
super(control);
// Use reflection because control.getControlChildren is package private.
// This would be unnecessary if this class was in javafx.scene control.
try {
Method m = Control.class.getDeclaredMethod("getControlChildren");
m.setAccessible(true);
children = (ObservableList) m.invoke(control);
} catch(Exception e) {
throw new RuntimeException(e);
}
}
/**
* {@inheritDoc}
*
* In addition, it should remove any nodes it had previously attached to
* the control.
*/
@Override
public abstract void dispose();
/**
* Provides direct access to control's child list.
*/
protected ObservableList getChildren() {
return children;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy