Presentation is loading. Please wait.

Presentation is loading. Please wait.

ㅡ.

Similar presentations


Presentation on theme: "ㅡ."— Presentation transcript:

1

2 Menu MenuBar MenuItem ContextMenu – Menu – CheckMenuItem
– RadioMenuItem – CustomMenuItem SeparatorMenuItem ContextMenu

3 Menu bar 생성하기 stage.setTitle("Menu Sample"); Scene scene = new Scene(new VBox(), 400, 350); MenuBar menuBar = new MenuBar(); // --- Menu File Menu menuFile = new Menu("File"); // --- Menu Edit Menu menuEdit = new Menu("Edit"); // --- Menu View Menu menuView = new Menu("View"); menuBar.getMenus().addAll(menuFile, menuEdit, menuView); ((VBox) scene.getRoot()).getChildren().addAll(menuBar); stage.setScene(scene); stage.show();

4 Menu Item 설정 stage.setTitle("Menu Sample"); Scene scene = new Scene(new VBox(), 400, 350); MenuBar menuBar = new MenuBar(); // --- Menu File Menu menuFile = new Menu("File"); MenuItem add = new MenuItem("new File"); MenuItem exit = new MenuItem("Exit"); exit.setOnAction((ActionEvent t) -> { System.exit(0); }); menuFile.getItems().addAll(add, exit); ……

5 Date Picker JDK 8 Date-Time API, JavaFX SDK introduced the DatePicker control

6 Date Picker 생성하기 import javafx.scene.control.DatePicker;
public static void main(String[] args) { Locale.setDefault(Locale.KOREA); launch(args); }

7 Date Picker 선언하기 public class Dateppickertest extends Application { private Stage stage; private DatePicker public void start(Stage stage) { this.stage = stage; stage.setTitle("DatePickerSample "); initUI(); stage.show(); }

8 Date Picker 화면구성 만들기 private void initUI() { VBox vbox = new VBox(20); vbox.setStyle("-fx-padding: 10;"); Scene scene = new Scene(vbox, 400, 400); stage.setScene(scene); checkInDatePicker = new DatePicker(); GridPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10);

9 Date Picker 화면구성 만들기(계속)
Label checkInlabel = new Label("Check-In Date:"); gridPane.add(checkInlabel, 0, 0); GridPane.setHalignment(checkInlabel, HPos.LEFT); gridPane.add(checkInDatePicker, 0, 1); vbox.getChildren().add(gridPane); }

10 File 불러오기 FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open Resource File"); fileChooser.showOpenDialog(stage);

11 버튼형식 파일 불러오기 public static void main(String[] args) { Application.launch(args); }

12 파일 불러오기 생성 public class FileChoosertest extends Application { private final Desktop desktop = public void start(Stage stage) { stage.setTitle("File Chooser Sample"); final FileChooser fileChooser = new FileChooser(); final Button openButton = new Button("Open a Picture..."); final Button openMultipleButton = new Button("Open Pictures..."); openButton.setOnAction((final ActionEvent e) -> { File file = fileChooser.showOpenDialog(stage); if (file != null) { openFile(file); } });

13 openMultipleButton.setOnAction((final ActionEvent e) -> { List<File> list =fileChooser.showOpenMultipleDialog(stage); if (list != null) { list.stream().forEach((file) -> { openFile(file); }); } final GridPane inputGridPane = new GridPane(); GridPane.setConstraints(openButton, 0, 0); GridPane.setConstraints(openMultipleButton, 1, 0); inputGridPane.setHgap(6); inputGridPane.setVgap(6); inputGridPane.getChildren().addAll(openButton, openMultipleButton); final Pane rootGroup = new VBox(12); rootGroup.getChildren().addAll(inputGridPane); rootGroup.setPadding(new Insets(12, 12, 12, 12)); stage.setScene(new Scene(rootGroup)); stage.show();

14 파일 오픈 예외처리 private void openFile(File file) { EventQueue.invokeLater(() -> { try { desktop.open(file); } catch (IOException ex) { Logger.getLogger(FileChoosertest.class.getName()).log(Level.SEVERE, null, ex); } });


Download ppt "ㅡ."

Similar presentations


Ads by Google