Пример #1
0
 void savePrefs() {
   if (changeCaseDialog != null) {
     prefs.put(strSelectedCase, controller.getSelectedCase());
     prefs.putDouble(strChangeCaseX, changeCaseDialog.getX());
     prefs.putDouble(strChangeCaseY, changeCaseDialog.getY());
   }
 }
Пример #2
0
  @FXML
  private void handleAction(ActionEvent event) {
    TextArea textarea = (TextArea) menuBar.getScene().lookup("#textarea");

    if (event.getSource() == chmiWordWrap) {
      wordWrapOn = chmiWordWrap.isSelected();
      textarea.setWrapText(wordWrapOn);

    } else if (event.getSource() == miChangeCase) {
      try {
        if (changeCaseDialog == null) {
          FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ChangeCaseDialog.fxml"));
          Parent root = fxmlLoader.load();
          controller = fxmlLoader.getController();
          controller.setSelectedCase(prefs.get(strSelectedCase, "UPPERCASE"));
          changeCaseDialog = new Stage();
          changeCaseDialog.setResizable(false);
          changeCaseDialog.initStyle(StageStyle.UTILITY);
          changeCaseDialog.setAlwaysOnTop(true);
          changeCaseDialog.setX(prefs.getDouble(strChangeCaseX, changeCaseDialog.getX()));
          changeCaseDialog.setY(prefs.getDouble(strChangeCaseY, changeCaseDialog.getY()));
          Scene scene = new Scene(root);
          changeCaseDialog.setScene(scene);
          changeCaseDialog.setTitle("Change Case");
        }

        changeCaseDialog.toFront();
        changeCaseDialog.show();
      } catch (Exception e) {

      }
    } else if (event.getSource() == miRemoveLineBreaks) {
      if (textarea.getSelectedText().length() == 0) {
        textarea.selectAll();

        if (textarea.getSelectedText().length() == 0) {
          return;
        }
      }

      String result = TextUtilities.removeLineBreaks(textarea.getSelectedText());

      int start = textarea.getSelection().getStart();
      textarea.replaceSelection(result);
      textarea.selectRange(start, start + result.length());
    } else if (event.getSource() == miFont) {
      Font font = textarea.getFont();
      FontSelectorDialog dialog = new FontSelectorDialog(font);
      Optional<Font> op = dialog.showAndWait();
      if (op.isPresent()) {
        textarea.setFont(op.get());
      }
    }
  }
Пример #3
0
 /** 最大化、最大化解除を行う */
 public void toogleMaximized() {
   final Screen screen = Screen.getScreensForRectangle(stage.getX(), stage.getY(), 1, 1).get(0);
   if (maximized) {
     maximized = false;
     if (backupWindowBounds != null) {
       stage.setX(backupWindowBounds.getMinX());
       stage.setY(backupWindowBounds.getMinY());
       stage.setWidth(backupWindowBounds.getWidth());
       stage.setHeight(backupWindowBounds.getHeight());
     }
   } else {
     maximized = true;
     backupWindowBounds =
         new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
     stage.setX(screen.getVisualBounds().getMinX());
     stage.setY(screen.getVisualBounds().getMinY());
     stage.setWidth(screen.getVisualBounds().getWidth());
     stage.setHeight(screen.getVisualBounds().getHeight());
   }
 }
Пример #4
0
  private void show(Stage stage) {

    final Scene scene = new Scene(vbox);
    final JFXPanel fxPanel = new JFXPanel();

    Platform.runLater(
        new Runnable() {
          @Override
          public void run() {
            fxPanel.setScene(scene);
          }
        });

    FadeTransition fadeIn = new FadeTransition(Duration.millis(1000), vbox);
    fadeIn.setFromValue(0.0);
    fadeIn.setToValue(1.0);
    fadeIn.play();

    new Timer()
        .schedule(
            new TimerTask() {
              public void run() {
                FadeTransition fadeOut = new FadeTransition(Duration.millis(1000), vbox);
                fadeOut.setFromValue(1.0);
                fadeOut.setToValue(0.0);
                fadeOut.play();
              }
            },
            2000);

    new Timer()
        .schedule(
            new TimerTask() {
              public void run() {
                System.gc();
                dispose();
              }
            },
            3000);

    add(fxPanel);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setSize(200, 100);
    setLocation((int) (stage.getX() + stage.getWidth() - 200d - 25d), (int) (stage.getY() + 75));
    setUndecorated(true);
    setOpacity(0.8f);
    setAlwaysOnTop(true);
    setVisible(true);
  }
Пример #5
0
 private void saveLocation() {
   savedX = dialogStage.getX();
   savedY = dialogStage.getY();
   savedWidth = dialogStage.getWidth();
   savedHeight = dialogStage.getHeight();
 }
Пример #6
0
 /**
  * Gets the scenes relative location. The relative location is based on how the scene's is located
  * relative to the operating system.
  *
  * @param The stage of which scene to get the relative location.
  * @return The relative location of the scene. The relative location is based on how the scene's
  *     is located relative to the operating system.
  */
 private TranslatedPoint getRelativeSceneLocation(Stage stage) {
   return new TranslatedPoint(
       stage.getX() + stage.getScene().getX(), stage.getY() + stage.getScene().getY());
 }