private void inicialitzarDialog() { // Definició d'un diàleg usant la classe Dialog dialog = new Dialog(); dialog.setTitle("Diàleg"); dialog.setHeaderText("This is a custom dialog"); dialog.setResizable(true); ButtonType buttonTypeOk = new ButtonType("Okay", ButtonBar.ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().add(buttonTypeOk); // Definició d'un diàleg usant la classe Dialog mitjas = new Dialog(); mitjas.setTitle("Diàleg"); mitjas.setResizable(true); mitjas.getDialogPane().getButtonTypes().add(buttonTypeOk); }
void showWarning(Frame frame, String warning) { warningDialog = new Dialog(frame, "警告", true); warningDialog.setSize(200, 100); warningDialog.setLayout(new FlowLayout()); warningDialog.setResizable(false); warningDialog.setLocationRelativeTo(frame); warningText = new Label(warning); warningButton = new Button("确认"); warningDialog.add(warningText); warningDialog.add(warningButton); warningDialog.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { warningDialog.setVisible(false); warningDialog.dispose(); } }); warningButton.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_ENTER) { warningDialog.setVisible(false); warningDialog.dispose(); } } }); warningButton.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { warningDialog.setVisible(false); warningDialog.dispose(); } }); warningDialog.setVisible(true); }
private void initDialog() { dialog.initOwner(mainApp.getPrimaryStage()); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initStyle(StageStyle.DECORATED); dialog.setResizable(true); dialog.setTitle("Recordings Already Exist"); dialog.setHeaderText("Replace or rename recordings?"); dialog.getDialogPane().setPadding(new Insets(10)); VBox vbox = new VBox(); vbox.setSpacing(10); dialog.getDialogPane().setContent(vbox); Label label = new Label( "Archiving the following recordings will replace files on your computer unless you rename them:"); vbox.getChildren().add(label); VBox recordingBox = new VBox(); recordingBox.setSpacing(20); for (Recording recording : recordingsToDisplay) { recording.setFileExistsAction(Recording.FileExistsAction.REPLACE); recordingBox.getChildren().add(buildRecordingGrid(recording)); } ScrollPane scrollPane = new ScrollPane(); scrollPane.getStyleClass().add("recording-exists-list"); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); scrollPane.setContent(recordingBox); scrollPane.setPadding(new Insets(10)); vbox.getChildren().add(scrollPane); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); }