|
1 | 1 | package JavaFXGUI;
|
2 | 2 | import java.util.ArrayList;
|
| 3 | +import java.util.Collection; |
3 | 4 | import java.util.List;
|
4 | 5 |
|
| 6 | +import javax.swing.ButtonGroup; |
| 7 | +import javax.swing.JComboBox; |
| 8 | +import javax.swing.JRadioButton; |
5 | 9 | import javax.swing.JSplitPane;
|
6 | 10 |
|
7 | 11 | import org.omg.CORBA.SystemException;
|
8 | 12 |
|
9 | 13 | import backend.Student;
|
10 | 14 | import javafx.scene.layout.*;
|
| 15 | +import javafx.scene.Node; |
11 | 16 | import javafx.scene.Scene;
|
12 | 17 | import javafx.scene.control.*;
|
13 | 18 | import javafx.util.Duration;
|
14 | 19 | import javafx.animation.FadeTransition;
|
| 20 | +import javafx.beans.value.ChangeListener; |
| 21 | +import javafx.beans.value.ObservableValue; |
| 22 | +import javafx.collections.FXCollections; |
15 | 23 | import javafx.event.*;
|
16 | 24 | import javafx.scene.input.KeyCode;
|
17 | 25 | import javafx.scene.input.KeyEvent;
|
@@ -39,11 +47,12 @@ public class OptionSelect extends VBox{
|
39 | 47 | private Button submitButton;
|
40 | 48 | private EnterInfoTab tabToBeClosed;
|
41 | 49 | private Student student;
|
42 |
| - private Button pageButtonLeft; |
43 |
| - private Button pageButtonRight; |
| 50 | +// private Button pageButtonLeft; |
| 51 | +// private Button pageButtonRight; |
44 | 52 | private FadeTransition ftIn;
|
45 | 53 | private FadeTransition ftOut;
|
46 | 54 | private ArrayList<OptionHBox> optionHBoxArray = new ArrayList<OptionHBox>();
|
| 55 | + private ChoiceBox c; |
47 | 56 | /**
|
48 | 57 | * Constructor. The data of the optionSelect is represented by an ArrayList of Strings that indicates what options where selected.
|
49 | 58 | * @param w Width of the optionSelect
|
@@ -96,19 +105,19 @@ public void init(){
|
96 | 105 | getStyleClass().add("optionSelect");
|
97 | 106 | HBox contentHBox = new HBox();
|
98 | 107 |
|
99 |
| - pageButtonLeft = new Button(); |
100 |
| - pageButtonLeft.getStyleClass().add("pageButton-left"); |
101 |
| - pageButtonLeft.setOnAction(new NextHandler(false)); |
| 108 | +// pageButtonLeft = new Button(); |
| 109 | +// pageButtonLeft.getStyleClass().add("pageButton-left"); |
| 110 | +// pageButtonLeft.setOnAction(new NextHandler(false)); |
102 | 111 |
|
103 |
| - pageButtonRight = new Button(); |
104 |
| - pageButtonRight.getStyleClass().add("pageButton-right"); |
105 |
| - pageButtonRight.setOnAction(new NextHandler(true)); |
| 112 | +// pageButtonRight = new Button(); |
| 113 | +// pageButtonRight.getStyleClass().add("pageButton-right"); |
| 114 | +// pageButtonRight.setOnAction(new NextHandler(true)); |
106 | 115 |
|
107 |
| - contentHBox.getChildren().add(pageButtonLeft); |
| 116 | +// contentHBox.getChildren().add(pageButtonLeft); |
108 | 117 | buttonVBox = new VBox();
|
109 | 118 | buttonVBox.getStyleClass().add("buttonVBox");
|
110 | 119 |
|
111 |
| - contentHBox.getChildren().addAll(buttonVBox, pageButtonRight); |
| 120 | + contentHBox.getChildren().addAll(buttonVBox);//, pageButtonRight); |
112 | 121 | getChildren().add(contentHBox);
|
113 | 122 |
|
114 | 123 | bottomHBox = new HBox();
|
@@ -150,32 +159,32 @@ public void addPage(String t){
|
150 | 159 | * @param pg The page to be displayed
|
151 | 160 | */
|
152 | 161 | private void updateState(int pg){
|
153 |
| - if(pg == 0 && pg == buttonList.size()-1){ |
154 |
| - pageButtonLeft.setDisable(true); |
155 |
| - pageButtonRight.setDisable(true); |
156 |
| - } |
157 |
| - else if(pg == 0 && pg == buttonList.size()-2){ |
158 |
| - pageButtonLeft.setDisable(true); |
159 |
| - pageButtonRight.setDisable(true); |
160 |
| - } |
161 |
| - else if (pg == 0){ |
162 |
| - pageButtonLeft.setDisable(true); |
163 |
| - pageButtonRight.setDisable(false); |
164 |
| - } |
165 |
| - else if (pg == buttonList.size()-1){ |
166 |
| - pageButtonLeft.setDisable(false); |
167 |
| - pageButtonRight.setDisable(true); |
168 |
| - } |
169 |
| - else{ |
170 |
| - pageButtonLeft.setDisable(false); |
171 |
| - pageButtonRight.setDisable(false); |
172 |
| - } |
| 162 | +// if(pg == 0 && pg == buttonList.size()-1){ |
| 163 | +// pageButtonLeft.setDisable(true); |
| 164 | +// pageButtonRight.setDisable(true); |
| 165 | +// } |
| 166 | +// else if(pg == 0 && pg == buttonList.size()-2){ |
| 167 | +// pageButtonLeft.setDisable(true); |
| 168 | +// pageButtonRight.setDisable(true); |
| 169 | +// } |
| 170 | +// else if (pg == 0){ |
| 171 | +// pageButtonLeft.setDisable(true); |
| 172 | +// pageButtonRight.setDisable(false); |
| 173 | +// } |
| 174 | +// else if (pg == buttonList.size()-1){ |
| 175 | +// pageButtonLeft.setDisable(false); |
| 176 | +// pageButtonRight.setDisable(true); |
| 177 | +// } |
| 178 | +// else{ |
| 179 | +// pageButtonLeft.setDisable(false); |
| 180 | +// pageButtonRight.setDisable(false); |
| 181 | +// } |
173 | 182 | titleLabel.setText(title.get(pg));
|
174 | 183 | page = pg;
|
175 | 184 |
|
176 | 185 | buttonVBox.getChildren().clear();
|
177 | 186 | double buttonHeight = (double)(height-80)/ (buttonList.get(page).size()+1);
|
178 |
| - double buttonWidth = (double)(width-100); |
| 187 | + double buttonWidth = (double)(width); |
179 | 188 |
|
180 | 189 | if (buttonList.get(page).size() >=3){
|
181 | 190 | buttonList.get(page).get(0).setPosStyle("top");
|
@@ -245,35 +254,40 @@ public void splitScreen(int page, String title1, String title2, ArrayList<String
|
245 | 254 | }
|
246 | 255 | bV.getChildren().add(right.get(page));
|
247 | 256 | bV.getChildren().add(left.get(page));
|
248 |
| - |
249 |
| - SplitPane splitPane = new SplitPane(new TableView(), |
250 |
| - new VBox(new Label("some other content"))); |
251 |
| - |
252 |
| -splitPane.setOrientation(Orientation.HORIZONTAL); |
253 |
| - |
254 |
| -// place splitPane as center |
255 |
| -BorderPane borderPane = new BorderPane(splitPane); |
256 |
| - |
257 |
| -borderPane.setTop(new MenuBar(new Menu())); |
258 |
| - |
259 |
| -Scene scene = new Scene(borderPane, 600, 400); |
260 |
| -//getChildren().show(); |
261 |
| - |
262 |
| -// Component leftt = new List<OptionButton>(); |
263 |
| -// sp.setLeftComponent(leftt); |
264 | 257 |
|
265 | 258 |
|
266 | 259 | buttonList.get(page).addAll(left) ;
|
267 |
| - buttonList.get(page).addAll(right); |
268 | 260 | option.add("");
|
269 |
| - |
270 | 261 | OptionHBox textFieldOtherHBox = new OptionHBox(width, this, buttonList.size()-1);
|
271 | 262 | textFieldOtherHBox.getStyleClass().add("optionTextFieldOther");
|
272 | 263 | optionHBoxArray.add(textFieldOtherHBox);
|
273 | 264 |
|
274 |
| - updateState(0); |
275 |
| - } |
| 265 | + updateState(0); |
276 | 266 |
|
| 267 | + |
| 268 | + } |
| 269 | + public void addChoiceBox(){ |
| 270 | + c = new ChoiceBox(FXCollections.observableArrayList("Health Room", "Parent", "Other")); |
| 271 | + c.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { |
| 272 | + public void changed(ObservableValue ov, Number value, Number new_value) { |
| 273 | +// new ChoiceHandler(c.getSelectionModel().getSelectedItem().toString(),this); |
| 274 | + addInfo(c.getSelectionModel().getSelectedItem().toString()); |
| 275 | + } |
| 276 | + }); |
| 277 | + c.setMaxSize(100,100); |
| 278 | + buttonVBox.getChildren().add(c); |
| 279 | + JRadioButton h = new JRadioButton("Health Room"); |
| 280 | + JRadioButton p = new JRadioButton("Parent"); |
| 281 | + ButtonGroup bg = new ButtonGroup(); |
| 282 | + bg.add(p); bg.add(h); |
| 283 | + |
| 284 | + submitButton.requestFocus(); |
| 285 | + } |
| 286 | + public void removeChoiceBox(){ |
| 287 | +// if(buttonVBox.getChildren().contains(c)){ |
| 288 | + buttonVBox.getChildren().remove(c); |
| 289 | +// } |
| 290 | + } |
277 | 291 | /**
|
278 | 292 | * This is called by the ButtonHandler to add information to the Data.
|
279 | 293 | * @param mes The value of the button clicked to be added.
|
@@ -310,8 +324,8 @@ private void transitionPage(int pg){
|
310 | 324 | ftOut.play();
|
311 | 325 | page = page + 1;
|
312 | 326 | ftIn.play();
|
313 |
| - pageButtonRight.setDisable(true); |
314 |
| - pageButtonLeft.setDisable(false); |
| 327 | +// pageButtonRight.setDisable(true); |
| 328 | +// pageButtonLeft.setDisable(false); |
315 | 329 | }
|
316 | 330 | else{
|
317 | 331 | for(ArrayList<OptionButton> e: buttonList){
|
@@ -348,11 +362,10 @@ public void handle(ActionEvent event) {
|
348 | 362 | * @author Ishana
|
349 | 363 | *
|
350 | 364 | */
|
351 |
| - |
352 |
| - public void handle() { |
353 |
| - submitButton.defaultButtonProperty().bind(submitButton.focusedProperty()); |
354 |
| - tabToBeClosed.addData(option); |
355 |
| - } |
| 365 | + public void handle() { |
| 366 | + submitButton.defaultButtonProperty().bind(submitButton.focusedProperty()); |
| 367 | + tabToBeClosed.addData(option); |
| 368 | + } |
356 | 369 |
|
357 | 370 |
|
358 | 371 | public ArrayList<String> getOption(){
|
|
0 commit comments