functional/ControlsTests/src/javafx/scene/control/test/tabpane/TabPaneApp2.java

Print this page




  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.control.test.tabpane;
  27 
  28 import javafx.beans.value.ChangeListener;
  29 import javafx.beans.value.ObservableValue;
  30 import javafx.event.ActionEvent;
  31 import javafx.event.Event;
  32 import javafx.event.EventHandler;
  33 import javafx.geometry.Side;
  34 import javafx.scene.Scene;
  35 import javafx.scene.control.ButtonBuilder;
  36 import javafx.scene.control.ChoiceBox;
  37 import javafx.scene.control.ContextMenu;
  38 import javafx.scene.control.Label;
  39 import javafx.scene.control.ListView;
  40 import javafx.scene.control.MenuItem;
  41 import javafx.scene.control.Tab;
  42 import javafx.scene.control.TabPane;
  43 import javafx.scene.control.TextField;
  44 import javafx.scene.control.Tooltip;
  45 import javafx.scene.layout.HBox;
  46 import javafx.scene.layout.Pane;
  47 import javafx.scene.layout.VBox;
  48 import test.javaclient.shared.InteroperabilityApp;
  49 import test.javaclient.shared.Utils;
  50 
  51 public class TabPaneApp2 extends InteroperabilityApp {
  52 
  53     public final static String TEST_PANE_ID = "TestPane";
  54     public final static String CLEAR_BTN_ID = "Clear";
  55     public final static String RESET_BTN_ID = "Reset";


  96             testPane.setMinSize(600, 400);
  97             testPane.setPrefSize(600, 400);
  98             testPane.setMaxSize(600, 400);
  99             root.getChildren().add(testPane);
 100 
 101             tabPane = new TabPane();
 102             tabPane.setTranslateX(200);
 103             tabPane.setTranslateY(150);
 104             tabPane.setPrefSize(200, 200);
 105             testPane.getChildren().add(tabPane);
 106 
 107             HBox control_pane = new HBox();
 108             root.getChildren().add(control_pane);
 109 
 110             VBox controls = new VBox(5);
 111             control_pane.getChildren().add(controls);
 112 
 113             error = new Label();
 114             error.setId(ERROR_ID);
 115 
 116             controls.getChildren().add(
 117                     ButtonBuilder.create()
 118                     .text(CLEAR_BTN_ID).id(CLEAR_BTN_ID)
 119                     .onAction(new EventHandler<ActionEvent>() {

 120                         public void handle(ActionEvent t) {
 121                             tabPane.getTabs().clear();
 122                         }
 123                     }).build());
 124 
 125             controls.getChildren().add(
 126                     ButtonBuilder.create()
 127                     .text(RESET_BTN_ID).id(RESET_BTN_ID)
 128                     .onAction(new EventHandler<ActionEvent>() {
 129 



 130                         public void handle(ActionEvent t) {
 131                             reset();
 132                         }
 133                     }).build());
 134 
 135             controls.getChildren().add(
 136                     ButtonBuilder.create()
 137                     .text(ADD_SINGLE_BTN_ID).id(ADD_SINGLE_BTN_ID)
 138                     .onAction(new EventHandler<ActionEvent>() {
 139 



 140                         public void handle(ActionEvent t) {
 141                             tabPane.getTabs().add(new NamedTab(TAB_ITEM + tabPane.getTabs().size()));
 142                         }
 143                     }).build());

 144 
 145             HBox add_position_box = new HBox(5);
 146             controls.getChildren().add(add_position_box);
 147 
 148             final TextField add_position = new TextField("0");
 149             add_position.setId(ADD_POS_EDIT_ID);
 150 
 151             add_position_box.getChildren().add(
 152                     ButtonBuilder.create()
 153                     .text(ADD_SINGLE_AT_POS_BTN_ID).id(ADD_SINGLE_AT_POS_BTN_ID)
 154                     .onAction(new EventHandler<ActionEvent>() {
 155 
 156                         public void handle(ActionEvent t) {
 157                             tabPane.getTabs().add(new NamedTab("Tab " + tabPane.getTabs().size()));
 158                         }
 159                     }).build());

 160 
 161             final Label add_label = new Label("at");
 162             add_position_box.getChildren().add(add_label);
 163 
 164             add_position_box.getChildren().add(add_position);
 165 
 166 
 167             HBox disable_position_box = new HBox(5);
 168             controls.getChildren().add(disable_position_box);
 169 
 170             final TextField disable_position = new TextField("0");
 171             disable_position.setId(DISABLE_POS_EDIT_ID);
 172 
 173             disable_position_box.getChildren().add(
 174                     ButtonBuilder.create()
 175                     .text(DISABLE_SINGLE_AT_POS_BTN_ID).id(DISABLE_SINGLE_AT_POS_BTN_ID)
 176                     .onAction(new EventHandler<ActionEvent>() {
 177 
 178                         public void handle(ActionEvent t) {
 179                             Integer pos = Integer.valueOf(disable_position.getText());
 180                             Tab tab = tabPane.getTabs().get(pos.intValue());
 181                             tab.setDisable(!tab.isDisable());
 182                         }
 183                     }).build());

 184 
 185             final Label disable_label = new Label("at");
 186             disable_position_box.getChildren().add(disable_label);
 187 
 188             disable_position_box.getChildren().add(disable_position);
 189 
 190 
 191             HBox remove_position_box = new HBox(5);
 192             controls.getChildren().add(remove_position_box);
 193 
 194             final TextField remove_position = new TextField("0");
 195             remove_position.setId(REMOVE_POS_EDIT_ID);
 196 
 197             remove_position_box.getChildren().add(
 198                     ButtonBuilder.create()
 199                     .text(REMOVE_SINGLE_AT_POS_BTN_ID).id(REMOVE_SINGLE_AT_POS_BTN_ID)
 200                     .onAction(new EventHandler<ActionEvent>() {
 201 
 202                         public void handle(ActionEvent t) {
 203                             tabPane.getTabs().remove(Integer.valueOf(remove_position.getText()).intValue());
 204                         }
 205                     }).build());

 206 
 207             final Label remove_label = new Label("at");
 208             remove_position_box.getChildren().add(remove_label);
 209 
 210             remove_position_box.getChildren().add(remove_position);
 211 
 212             final ChoiceBox<Side> cb = new ChoiceBox<Side>();
 213             cb.setId(SIDE_CB_ID);
 214             cb.getItems().addAll(Side.values());
 215             cb.getSelectionModel().select(tabPane.getSide());
 216             cb.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
 217                 public void changed(ObservableValue ov, Object t, Object t1) {
 218                     tabPane.setSide(cb.getSelectionModel().getSelectedItem());
 219                 }
 220             });
 221 
 222             controls.getChildren().add(cb);
 223 
 224             HBox last_selected_box = new HBox(5);
 225             controls.getChildren().add(last_selected_box);




  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.control.test.tabpane;
  27 
  28 import javafx.beans.value.ChangeListener;
  29 import javafx.beans.value.ObservableValue;
  30 import javafx.event.ActionEvent;
  31 import javafx.event.Event;
  32 import javafx.event.EventHandler;
  33 import javafx.geometry.Side;
  34 import javafx.scene.Scene;
  35 import javafx.scene.control.Button;
  36 import javafx.scene.control.ChoiceBox;
  37 import javafx.scene.control.ContextMenu;
  38 import javafx.scene.control.Label;
  39 import javafx.scene.control.ListView;
  40 import javafx.scene.control.MenuItem;
  41 import javafx.scene.control.Tab;
  42 import javafx.scene.control.TabPane;
  43 import javafx.scene.control.TextField;
  44 import javafx.scene.control.Tooltip;
  45 import javafx.scene.layout.HBox;
  46 import javafx.scene.layout.Pane;
  47 import javafx.scene.layout.VBox;
  48 import test.javaclient.shared.InteroperabilityApp;
  49 import test.javaclient.shared.Utils;
  50 
  51 public class TabPaneApp2 extends InteroperabilityApp {
  52 
  53     public final static String TEST_PANE_ID = "TestPane";
  54     public final static String CLEAR_BTN_ID = "Clear";
  55     public final static String RESET_BTN_ID = "Reset";


  96             testPane.setMinSize(600, 400);
  97             testPane.setPrefSize(600, 400);
  98             testPane.setMaxSize(600, 400);
  99             root.getChildren().add(testPane);
 100 
 101             tabPane = new TabPane();
 102             tabPane.setTranslateX(200);
 103             tabPane.setTranslateY(150);
 104             tabPane.setPrefSize(200, 200);
 105             testPane.getChildren().add(tabPane);
 106 
 107             HBox control_pane = new HBox();
 108             root.getChildren().add(control_pane);
 109 
 110             VBox controls = new VBox(5);
 111             control_pane.getChildren().add(controls);
 112 
 113             error = new Label();
 114             error.setId(ERROR_ID);
 115 
 116             Button temp;
 117 
 118             temp = new Button(CLEAR_BTN_ID);
 119             temp.setId(CLEAR_BTN_ID);
 120             temp.setOnAction(new EventHandler<ActionEvent>() {
 121                 public void handle(ActionEvent t) {
 122                     tabPane.getTabs().clear();
 123                 }
 124             });
 125             controls.getChildren().add(temp);




 126 
 127             temp = new Button(RESET_BTN_ID);
 128             temp.setId(RESET_BTN_ID);
 129             temp.setOnAction(new EventHandler<ActionEvent>() {
 130                 public void handle(ActionEvent t) {
 131                     reset();
 132                 }
 133             });
 134             controls.getChildren().add(temp);




 135 
 136             temp = new Button(ADD_SINGLE_BTN_ID);
 137             temp.setId(ADD_SINGLE_BTN_ID);
 138             temp.setOnAction(new EventHandler<ActionEvent>() {
 139                 public void handle(ActionEvent t) {
 140                     tabPane.getTabs().add(new NamedTab(TAB_ITEM + tabPane.getTabs().size()));
 141                 }
 142             });
 143             controls.getChildren().add(temp);
 144 
 145             HBox add_position_box = new HBox(5);
 146             controls.getChildren().add(add_position_box);
 147 
 148             final TextField add_position = new TextField("0");
 149             add_position.setId(ADD_POS_EDIT_ID);
 150 
 151             temp = new Button(ADD_SINGLE_AT_POS_BTN_ID);
 152             temp.setId(ADD_SINGLE_AT_POS_BTN_ID);
 153             temp.setOnAction(new EventHandler<ActionEvent>() {


 154                 public void handle(ActionEvent t) {
 155                     tabPane.getTabs().add(new NamedTab("Tab " + tabPane.getTabs().size()));
 156                 }
 157             });
 158             add_position_box.getChildren().add(temp);
 159 
 160             final Label add_label = new Label("at");
 161             add_position_box.getChildren().add(add_label);
 162 
 163             add_position_box.getChildren().add(add_position);
 164 
 165 
 166             HBox disable_position_box = new HBox(5);
 167             controls.getChildren().add(disable_position_box);
 168 
 169             final TextField disable_position = new TextField("0");
 170             disable_position.setId(DISABLE_POS_EDIT_ID);
 171 
 172             temp = new Button(DISABLE_SINGLE_AT_POS_BTN_ID);
 173             temp.setId(DISABLE_SINGLE_AT_POS_BTN_ID);
 174             temp.setOnAction(new EventHandler<ActionEvent>() {


 175                 public void handle(ActionEvent t) {
 176                     Integer pos = Integer.valueOf(disable_position.getText());
 177                     Tab tab = tabPane.getTabs().get(pos.intValue());
 178                     tab.setDisable(!tab.isDisable());
 179                 }
 180             });
 181             disable_position_box.getChildren().add(temp);
 182 
 183             final Label disable_label = new Label("at");
 184             disable_position_box.getChildren().add(disable_label);
 185 
 186             disable_position_box.getChildren().add(disable_position);
 187 
 188 
 189             HBox remove_position_box = new HBox(5);
 190             controls.getChildren().add(remove_position_box);
 191 
 192             final TextField remove_position = new TextField("0");
 193             remove_position.setId(REMOVE_POS_EDIT_ID);
 194 
 195             temp = new Button(REMOVE_SINGLE_AT_POS_BTN_ID);
 196             temp.setId(REMOVE_SINGLE_AT_POS_BTN_ID);
 197             temp.setOnAction(new EventHandler<ActionEvent>() {


 198                 public void handle(ActionEvent t) {
 199                     tabPane.getTabs().remove(Integer.valueOf(remove_position.getText()).intValue());
 200                 }
 201             });
 202             remove_position_box.getChildren().add(temp);
 203 
 204             final Label remove_label = new Label("at");
 205             remove_position_box.getChildren().add(remove_label);
 206 
 207             remove_position_box.getChildren().add(remove_position);
 208 
 209             final ChoiceBox<Side> cb = new ChoiceBox<Side>();
 210             cb.setId(SIDE_CB_ID);
 211             cb.getItems().addAll(Side.values());
 212             cb.getSelectionModel().select(tabPane.getSide());
 213             cb.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
 214                 public void changed(ObservableValue ov, Object t, Object t1) {
 215                     tabPane.setSide(cb.getSelectionModel().getSelectedItem());
 216                 }
 217             });
 218 
 219             controls.getChildren().add(cb);
 220 
 221             HBox last_selected_box = new HBox(5);
 222             controls.getChildren().add(last_selected_box);