javafx.scene.control.Skin Java Examples

The following examples show how to use javafx.scene.control.Skin. 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: TreeViewWrapper.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void initialiseTreeViewReflection() {

        // we can't use wrapped.getSkin() because it may be null.
        // we don't care about the specific instance, we just want the class
        @SuppressWarnings("PMD.UselessOverridingMethod")
        Skin<?> dftSkin = new TreeView<Object>() {
            @Override
            protected Skin<?> createDefaultSkin() {
                return super.createDefaultSkin();
            }
        }.createDefaultSkin();

        Object flow = getVirtualFlow(dftSkin);

        if (flow == null) {
            return;
        }

        treeViewFirstVisibleMethod = MethodUtils.getMatchingMethod(flow.getClass(), "getFirstVisibleCell");
        treeViewLastVisibleMethod = MethodUtils.getMatchingMethod(flow.getClass(), "getLastVisibleCell");
    }
 
Example #2
Source File: FGauge.java    From Medusa with Apache License 2.0 6 votes vote down vote up
public FGauge(final Gauge GAUGE, final GaugeDesign DESIGN, final GaugeBackground BACKGROUND) {
    getStylesheets().add(getClass().getResource("framed-gauge.css").toExternalForm());
    getStyleClass().setAll("framed-gauge");
    gauge           = GAUGE;
    gaugeDesign     = DESIGN;
    gaugeBackground = BACKGROUND;

    Skin skin = gauge.getSkin();

    if (null == skin) {
        throw new RuntimeException("Please use a valid Skin.");
    }

    init();
    initGraphics();
    registerListeners();
}
 
Example #3
Source File: Clock.java    From Medusa with Apache License 2.0 6 votes vote down vote up
@Override protected Skin createDefaultSkin() {
    switch(skinType) {
        case YOTA2     : return new ClockSkin(Clock.this);
        case LCD       : return new LcdClockSkin(Clock.this);
        case PEAR      : return new PearClockSkin(Clock.this);
        case PLAIN     : return new PlainClockSkin(Clock.this);
        case DB        : return new DBClockSkin(Clock.this);
        case FAT       : return new FatClockSkin(Clock.this);
        case ROUND_LCD : return new RoundLcdClockSkin(Clock.this);
        case SLIM      : return new SlimClockSkin(Clock.this);
        case MINIMAL   : return new MinimalClockSkin(Clock.this);
        case DIGITAL   : return new DigitalClockSkin(Clock.this);
        case TEXT      : return new TextClockSkin(Clock.this);
        case DESIGN    : return new DesignClockSkin(Clock.this);
        case INDUSTRIAL: return new IndustrialClockSkin(Clock.this);
        case TILE      : return new TileClockSkin(Clock.this);
        case DIGI      : return new DigitalClockSkin(Clock.this);
        case MORPHING  : return new MorphingClockSkin(Clock.this);
        case CLOCK     :
        default        : return new ClockSkin(Clock.this);
    }
}
 
Example #4
Source File: IncDecSlider.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin()
{
    final SliderSkin skin = (SliderSkin) super.createDefaultSkin();

    // SliderSkin is accessible, but the more interesting
    // com.sun.javafx.scene.control.behavior.SliderBehavior
    // is not.
    // Work around this by locating 'track'...
    for (Node node : skin.getChildren())
        if (node.getStyleClass().contains("track"))
        {
            // Capture mouse clicks, use to inc/dec instead of jumping there
            node.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> handleTrackClick(node, event));

            // Disable mouse drag, which by default also jumps to mouse
            node.setOnMouseDragged(null);
            break;
        }

    return skin;
}
 
Example #5
Source File: FxTreeTable.java    From FxDock with Apache License 2.0 5 votes vote down vote up
protected void fixHorizontalScrollbar()
{
	Skin skin = tree.getSkin();
	if(skin == null)
	{
		return;
	}
	
	for(Node n: skin.getNode().lookupAll(".scroll-bar"))
	{
		if(n instanceof ScrollBar)
		{
			ScrollBar b = (ScrollBar)n;
			if(b.getOrientation() == Orientation.HORIZONTAL)
			{
				if(isAutoResizeMode())
				{
					b.setManaged(false);
					b.setPrefHeight(0);
					b.setPrefWidth(0);
				}
				else
				{
					b.setManaged(true);
					b.setPrefHeight(USE_COMPUTED_SIZE);
					b.setPrefWidth(USE_COMPUTED_SIZE);
				}
			}
		}
	}
}
 
Example #6
Source File: TreeViewWrapper.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Object getVirtualFlow(Skin<?> skin) {
    try {
        // On JRE 9 and 10, the field is declared in TreeViewSkin
        // http://hg.openjdk.java.net/openjfx/9/rt/file/c734b008e3e8/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TreeViewSkin.java#l85
        // http://hg.openjdk.java.net/openjfx/10/rt/file/d14b61c6be12/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TreeViewSkin.java#l85
        // On JRE 8, the field is declared in the VirtualContainerBase superclass
        // http://hg.openjdk.java.net/openjfx/8/master/rt/file/f89b7dc932af/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualContainerBase.java#l68

        return FieldUtils.readField(skin, "flow", true);
    } catch (IllegalAccessException ignored) {

    } catch (RuntimeException re) {
        if (!reflectionImpossibleWarning && "java.lang.reflect.InaccessibleObjectException".equals(re.getClass().getName())) {
            // that exception was introduced for Jigsaw (JRE 9)
            // so we can't refer to it without breaking compat with Java 8

            // TODO find a way to report errors in the app directly, System.out is too shitty

            System.out.println();
            System.out.println("On JRE 9+, the following VM argument makes the controls smarter:");
            System.out.println("--add-opens javafx.controls/javafx.scene.control.skin=ALL-UNNAMED");
            System.out.println("Please consider adding it to your command-line or using the launch script bundled with PMD's binary distribution.");

            reflectionImpossibleWarning = true;
        } else {
            throw re;
        }
    }
    return null;
}
 
Example #7
Source File: JFXTooltip.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new TooltipSkin(this) {
        {
            Node node = getNode();
            node.setEffect(null);
        }
    };
}
 
Example #8
Source File: XPathAutocompleteProvider.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void showAutocompletePopup(int insertionIndex, String input) {

        CompletionResultSource suggestionMaker = mySuggestionProvider.get();

        List<MenuItem> suggestions =
            suggestionMaker.getSortedMatches(input, 5)
                           .map(result -> {

                               Label entryLabel = new Label();
                               entryLabel.setGraphic(result.getTextFlow());
                               entryLabel.setPrefHeight(5);
                               CustomMenuItem item = new CustomMenuItem(entryLabel, true);
                               item.setUserData(result);
                               item.setOnAction(e -> applySuggestion(insertionIndex, input, result.getStringMatch()));
                               return item;
                           })
                           .collect(Collectors.toList());

        autoCompletePopup.getItems().setAll(suggestions);


        myCodeArea.getCharacterBoundsOnScreen(insertionIndex, insertionIndex + input.length())
                  .ifPresent(bounds -> autoCompletePopup.show(myCodeArea, bounds.getMinX(), bounds.getMaxY()));

        Skin<?> skin = autoCompletePopup.getSkin();
        if (skin != null) {
            Node fstItem = skin.getNode().lookup(".menu-item");
            if (fstItem != null) {
                fstItem.requestFocus();
            }
        }
    }
 
Example #9
Source File: ControlBase.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Skin<?> createDefaultSkin() {
    S skin = createSkin();

    // initialise the skin
    skin.initialise();

    // create and initialise the behavior of the skin (if it exists)
    skin.createDefaultBehavior();

    return skin;
}
 
Example #10
Source File: CellUtils.java    From ARMStrong with Mozilla Public License 2.0 5 votes vote down vote up
private static <T> boolean listenToComboBoxSkin(final ComboBox<T> comboBox, final Cell<T> cell) {
    Skin<?> skin = comboBox.getSkin();
    if (skin != null && skin instanceof ComboBoxListViewSkin) {
        ComboBoxListViewSkin cbSkin = (ComboBoxListViewSkin) skin;
        Node popupContent = cbSkin.getPopupContent();
        if (popupContent != null && popupContent instanceof ListView) {
            popupContent.addEventHandler(MouseEvent.MOUSE_RELEASED, e -> cell.commitEdit(comboBox.getValue()));
            return true;
        }
    }
    return false;
}
 
Example #11
Source File: DataManipulationUI.java    From SONDY with GNU General Public License v3.0 5 votes vote down vote up
public final void filterUI(){
        GridPane gridLEFT = new GridPane();
        // Labels
        Label stopwordsLabel = new Label("Stop words removal");
        UIUtils.setSize(stopwordsLabel, Main.columnWidthLEFT/2, 24);
        Label resizingLabel = new Label("Resizing");
        UIUtils.setSize(resizingLabel, Main.columnWidthLEFT/2, 24);
        gridLEFT.add(stopwordsLabel,0,0);
        gridLEFT.add(new Rectangle(0,3),0,1);
        gridLEFT.add(resizingLabel,0,2);
        
        // Values
        stopwordLists = new StopwordSets();
        stopwordListsCheckComboBox = new CheckComboBox<>(stopwordLists.availableSets);
        stopwordListsCheckComboBox.setStyle("-fx-font-size: 12px;"); 
        stopwordListsCheckComboBox.skinProperty().addListener(new ChangeListener<Skin>() {
        @Override
        public void changed(ObservableValue<? extends Skin> observable, Skin oldValue, Skin newValue) {
             if(oldValue==null && newValue!=null){
                 CheckComboBoxSkin skin = (CheckComboBoxSkin)newValue;
                 ComboBox combo = (ComboBox)skin.getChildren().get(0);
                 combo.setPrefWidth(Main.columnWidthLEFT/2);
                 combo.setMaxWidth(Double.MAX_VALUE);
             }
        }
});
//        stopwordListsCheckComboBox.setMaxWidth(Double.MAX_VALUE);
                
//        UIUtils.setSize(stopwordListsCheckComboBox,Main.columnWidthLEFT/2, 24);
        gridLEFT.add(stopwordListsCheckComboBox,1,0);
        resizeSlider = new RangeSlider();
        resizeSlider.setBlockIncrement(0.1);
        UIUtils.setSize(resizeSlider,Main.columnWidthLEFT/2, 24);
        resizeSlider.resize(Main.columnWidthLEFT/2, 24);
        gridLEFT.add(resizeSlider,1,2);

        HBox filterDatasetBOTH = new HBox(5);
        filterDatasetBOTH.getChildren().addAll(gridLEFT,createFilterButton());
        grid.add(filterDatasetBOTH,0,11);
    }
 
Example #12
Source File: AutoTooltipRadioButton.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin() {
    return new AutoTooltipRadioButtonSkin(this);
}
 
Example #13
Source File: JFXRadioButton.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXRadioButtonSkin(this);
}
 
Example #14
Source File: JFXButton.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXButtonSkin(this);
}
 
Example #15
Source File: RingProgressIndicator.java    From fx-progress-circle with Apache License 2.0 4 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin() {
    return new RingProgressIndicatorSkin(this);
}
 
Example #16
Source File: JFXProgressBar.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXProgressBarSkin(this);
}
 
Example #17
Source File: PopOver.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin() {
    return new PopOverSkin(this);
}
 
Example #18
Source File: AutoTooltipSlideToggleButton.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin() {
    return new AutoTooltipSlideToggleButton.AutoTooltipSlideToggleButtonSkin(this);
}
 
Example #19
Source File: PasswordTextField.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXTextFieldSkinBisqStyle<>(this, 0);
}
 
Example #20
Source File: JFXComboBox.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXComboBoxListViewSkin<>(this);
}
 
Example #21
Source File: JFXTextArea.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXTextAreaSkin(this);
}
 
Example #22
Source File: JFXTextField.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXTextFieldSkin<>(this);
}
 
Example #23
Source File: JFXSpinner.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXSpinnerSkin(this);
}
 
Example #24
Source File: JFXTabPane.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXTabPaneSkin(this);
}
 
Example #25
Source File: JFXToggleNode.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXToggleNodeSkin(this);
}
 
Example #26
Source File: JFXTreeTableCell.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXTreeTableCellSkin<>(this);
}
 
Example #27
Source File: JFXChipView.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXChipViewSkin<T>(this);
}
 
Example #28
Source File: JFXTimePicker.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXTimePickerSkin(this);
}
 
Example #29
Source File: JFXAutoCompletePopup.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXAutoCompletePopupSkin<T>(this);
}
 
Example #30
Source File: BisqTextField.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected Skin<?> createDefaultSkin() {
    return new JFXTextFieldSkinBisqStyle<>(this, 0);
}