Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package javafx.scene.control.skin;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sun.javafx.scene.control.Properties;
import com.sun.javafx.scene.control.behavior.BehaviorBase;
import javafx.beans.InvalidationListener;
import javafx.beans.property.ObjectProperty;
import javafx.collections.ListChangeListener;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.control.Control;
import javafx.scene.control.SkinBase;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
/**
* Default skin implementation for the {@link ButtonBar} control.
*
* @see ButtonBar
* @since 9
*/
public class ButtonBarSkin extends SkinBase {
/* ************************************************************************
*
* Static fields
*
**************************************************************************/
private static final double GAP_SIZE = 10;
private static final String CATEGORIZED_TYPES = "LRHEYNXBIACO"; //$NON-NLS-1$
// pick an arbitrary number
private static final double DO_NOT_CHANGE_SIZE = Double.MAX_VALUE - 100;
/* ************************************************************************
*
* fields
*
**************************************************************************/
private HBox layout;
private InvalidationListener buttonDataListener = o -> layoutButtons();
/* ************************************************************************
*
* Constructors
*
**************************************************************************/
/**
* Creates a new ButtonBarSkin instance, installing the necessary child
* nodes into the Control {@link Control#getChildren() children} list.
*
* @param control The control that this skin should be installed onto.
*/
public ButtonBarSkin(final ButtonBar control) {
super(control);
this.layout = new HBox(GAP_SIZE) {
@Override protected void layoutChildren() {
// has to be called first or layout is not correct sometimes
resizeButtons();
super.layoutChildren();
}
};
this.layout.setAlignment(Pos.CENTER);
this.layout.getStyleClass().add("container");
getChildren().add(layout);
layoutButtons();
updateButtonListeners(control.getButtons(), true);
control.getButtons().addListener((ListChangeListener) c -> {
while (c.next()) {
updateButtonListeners(c.getRemoved(), false);
updateButtonListeners(c.getAddedSubList(), true);
}
layoutButtons();
});
registerChangeListener(control.buttonOrderProperty(), e -> layoutButtons());
registerChangeListener(control.buttonMinWidthProperty(), e -> resizeButtons());
}
/* ************************************************************************
*
* Implementation
*
**************************************************************************/
private void updateButtonListeners(List extends Node> list, boolean buttonsAdded) {
if (list != null) {
for (Node n : list) {
final Map