前提・実現したいこと
学校の課題で受付システムを作っています。
SceneBuilderを使いTabPaneを利用した画面を設計したのですが、その後にController「次へ」のボタンを押すと次のタブに移るということをやりたいのですがやり方が分かりません。
発生している問題・エラーメッセージ
エラーメッセージ
該当のソースコード
java
1package reception; 2 3import java.net.URL; 4 5import javafx.application.Application; 6import javafx.stage.Stage; 7import javafx.scene.Scene; 8import javafx.scene.control.TabPane; 9import javafx.scene.layout.AnchorPane; 10import javafx.fxml.FXMLLoader; 11 12 13public class Main extends Application { 14 private static Stage stage; 15 16 @Override 17 public void start(Stage primaryStage) throws Exception { 18 try { 19 URL location=getClass().getResource("Reception.fxml"); 20 TabPane root = (TabPane)FXMLLoader.load(location); 21 Scene scene = new Scene(root,600,450); 22 scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); 23 primaryStage.setScene(scene); 24 primaryStage.setTitle("受付"); 25 primaryStage.show(); 26 } catch(Exception e) { 27 e.printStackTrace(); 28 } 29 } 30 31 public static void main(String[] args) { 32 launch(args); 33 } 34} 35
java
1package reception; 2 3import java.net.URL; 4import java.util.ResourceBundle; 5 6import javafx.collections.FXCollections; 7import javafx.collections.ObservableList; 8import javafx.event.ActionEvent; 9import javafx.fxml.FXML; 10import javafx.fxml.Initializable; 11import javafx.scene.control.Button; 12import javafx.scene.control.ComboBox; 13import javafx.scene.control.Label; 14import javafx.scene.control.Tab; 15 16public class ReceptionController implements Initializable { 17 @FXML 18 private Button button,button2,button3,button4; 19 20 @FXML 21 private Button button5,button6,button7,button8,button9; 22 23 @FXML 24 private Label label; 25 26 @FXML 27 private Tab tabpane1; 28 @FXML 29 private Label label1; 30 31 @FXML 32 private ComboBox<String> combo,combo2,combo3,combo4; 33 34 @FXML 35 private void onButtonClick_start(ActionEvent event) { 36 37 38 } 39 40 @FXML 41 private void onButtonClick_times(ActionEvent event2) { 42 if(event2.getSource().equals(button)) 43 label.setText("1時間"); 44 else if(event2.getSource().equals(button2)) 45 label.setText("1.5時間"); 46 else if(event2.getSource().equals(button3)) 47 label.setText("2時間"); 48 else if(event2.getSource().equals(button4)) 49 label.setText("フリータイム"); 50 } 51 52 @FXML 53 private void onButtonClick_drinkTimes(ActionEvent event3) { 54 if(event3.getSource().equals(button5)) 55 label1.setText("1時間"); 56 else if(event3.getSource().equals(button6)) 57 label1.setText("2時間"); 58 else if(event3.getSource().equals(button7)) 59 label1.setText("フリータイム"); 60 else if(event3.getSource().equals(button8)) 61 label1.setText("ニーニーパック"); 62 else if(event3.getSource().equals(button9)) 63 label1.setText("フリフリパック"); 64 } 65 ObservableList<String> list = FXCollections.observableArrayList("0","1","2","3","4","5","6","7","8","9"); 66 67 @Override 68 public void initialize(URL location, ResourceBundle resources) { 69 // TODO 自動生成されたメソッド・スタブ 70 combo.setItems(list); 71 combo2.setItems(list); 72 combo3.setItems(list); 73 combo4.setItems(list); 74 } 75} 76
試したこと
ボタンを押したらコンソールに文字を出力することはできました。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/04 05:39