oktatas:programozas:java:java_fx:operacios_rendszer
Tartalomjegyzék
JavaFX - Operációs rendszer
- Szerző: Sallai András
- Copyright © 2024, Sallai András
- Licenc: CC BY-SA 4.0
- Web: https://szit.hu
Kilépés
import javafx.application.Platform; //... Button exitButton = new Button("Kilépés"); exitButton.setOnAction(event -> { Platform.exit(); });
Button exitButton = new Button("Kilépés"); exitButton.setOnAction(event -> { System.exit(0); });
Vágólap
Másolás
- MainController.java
package com.example; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.TextArea; import javafx.scene.input.Clipboard; import javafx.scene.input.ClipboardContent; public class MainController { @FXML private TextArea editorArea; @FXML void onClickCopyButton(ActionEvent event) { startCopy(); } private void startCopy() { String editorText = editorArea.getSelectedText(); Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); content.putString(editorText); clipboard.setContent(content); } }
Beillesztés
@FXML void onClickPasteButton(ActionEvent event) { startPaste(); } private void startPaste() { Clipboard clipboard = Clipboard.getSystemClipboard(); String content = clipboard.getString(); int cursorPosition = editorArea.getCaretPosition(); editorArea.insertText(cursorPosition,content); }
Kivágás
@FXML void onClickCutButton(ActionEvent event) { startCut(); } private void startCut() { String editorText = editorArea.getSelectedText(); editorArea.deleteText(editorArea.getSelection()); Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent content = new ClipboardContent(); content.putString(editorText); clipboard.setContent(content); }
oktatas/programozas/java/java_fx/operacios_rendszer.txt · Utolsó módosítás: 2024/11/04 23:16 szerkesztette: admin