Java Code Examples for javafx.scene.Node#getStyleClass()

The following examples show how to use javafx.scene.Node#getStyleClass() . 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: ModalDialog.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private String createTooltipText(Node node) {
    StringBuilder tooltipText = new StringBuilder();
    String id = node.getId();
    if (id != null && !"".equals(id)) {
        tooltipText.append("#" + id);
    }
    ObservableList<String> styleClass = node.getStyleClass();
    if (styleClass.size() > 0) {
        tooltipText.append("(");
        for (String string : styleClass) {
            tooltipText.append(string + ",");
        }
        tooltipText.setLength(tooltipText.length() - 1);
        tooltipText.append(")");
    }
    return tooltipText.toString();
}
 
Example 2
Source File: FX.java    From FxDock with Apache License 2.0 6 votes vote down vote up
/** adds or removes the specified style */
public static void setStyle(Node n, CssStyle st, boolean on)
{
	if(n == null)
	{
		return;
	}
	else if(st == null)
	{
		return;
	}
	
	String name = st.getName();
	ObservableList<String> ss = n.getStyleClass();
	if(on)
	{
		if(!ss.contains(name))
		{
			ss.add(st.getName());
		}
	}
	else
	{
		ss.remove(name);
	}
}
 
Example 3
Source File: FxDump.java    From FxDock with Apache License 2.0 4 votes vote down vote up
protected void dump(Node n)
{
	SB sb = new SB(4096);
	sb.nl();
	
	while(n != null)
	{
		sb.a(CKit.getSimpleName(n));
		
		String id = n.getId();
		if(CKit.isNotBlank(id))
		{
			sb.a(" #");
			sb.a(id);
		}
		
		for(String s: n.getStyleClass())
		{
			sb.a(" .").a(s);
		}
		
		for(PseudoClass c: n.getPseudoClassStates())
		{
			sb.a(" :").a(c);
		}
		
		sb.nl();
		
		if(n instanceof Text)
		{
			sb.sp(4);
			sb.a("text: ");
			sb.a(TextTools.escapeControlsForPrintout(((Text)n).getText()));
			sb.nl();
		}
		
		CList<CssMetaData<? extends Styleable,?>> md = new CList<>(n.getCssMetaData());
		sort(md);
		
		for(CssMetaData d: md)
		{
			String k = d.getProperty();
			Object v = d.getStyleableProperty(n).getValue();
			if(shouldShow(v))
			{
				Object val = describe(v);
				sb.sp(4).a(k);
				sb.sp().a(val);
				if(d.isInherits())
				{
					sb.a(" *");
				}
				sb.nl();
			}
		}
		
		n = n.getParent();
	}
	D.print(sb);
}