|
| 1 | +package com.example.compactjv.UI; |
| 2 | + |
| 3 | +import com.example.compactjv.Controller; |
| 4 | +import javafx.scene.Node; |
| 5 | +import javafx.scene.control.Tooltip; |
| 6 | +import javafx.util.Duration; |
| 7 | + |
| 8 | +public class TooltipUI extends Controller { |
| 9 | + public TooltipUI() { |
| 10 | + super(); |
| 11 | + setupTooltips(); |
| 12 | + } |
| 13 | + |
| 14 | + private void setupTooltips() { |
| 15 | + Tooltip closeButtonTooltip = createTooltip("Close the application"); |
| 16 | + Tooltip.install(closeButton, closeButtonTooltip); |
| 17 | + |
| 18 | + Tooltip minimizeButtonTooltip = createTooltip("Minimize the application"); |
| 19 | + Tooltip.install(minimizeButton, minimizeButtonTooltip); |
| 20 | + |
| 21 | + Tooltip compressButtonTooltip = createTooltip("Compress the file"); |
| 22 | + Tooltip.install(compressButton, compressButtonTooltip); |
| 23 | + |
| 24 | + Tooltip decompressButtonTooltip = createTooltip("Decompress the file"); |
| 25 | + Tooltip.install(decompressButton, decompressButtonTooltip); |
| 26 | + |
| 27 | + Tooltip informationButtonTooltip = createTooltip("Get information about the file"); |
| 28 | + Tooltip.install(informationButton, informationButtonTooltip); |
| 29 | + |
| 30 | + Tooltip filePathFieldTooltip = createTooltip("Enter the path of the file"); |
| 31 | + Tooltip.install(filePathField, filePathFieldTooltip); |
| 32 | + |
| 33 | + Tooltip currentSizeLabelTooltip = createTooltip("Displays the current size of the file"); |
| 34 | + Tooltip.install(currentSizeLabel, currentSizeLabelTooltip); |
| 35 | + |
| 36 | + Tooltip sizeOnDiskLabelTooltip = createTooltip("Displays the size of the file on disk"); |
| 37 | + Tooltip.install(sizeOnDiskLabel, sizeOnDiskLabelTooltip); |
| 38 | + |
| 39 | + Tooltip percentageLabelTooltip = createTooltip("Displays the percentage of compression/decompression"); |
| 40 | + Tooltip.install(percentageLabel, percentageLabelTooltip); |
| 41 | + |
| 42 | + Tooltip cpuUsageLabelTooltip = createTooltip("Displays the current CPU usage"); |
| 43 | + Tooltip.install(cpuUsageLabel, cpuUsageLabelTooltip); |
| 44 | + |
| 45 | + Tooltip memoryUsageLabelTooltip = createTooltip("Displays the current memory usage"); |
| 46 | + Tooltip.install(memoryUsageLabel, memoryUsageLabelTooltip); |
| 47 | + |
| 48 | + Tooltip totalFolderOnFileTooltip = createTooltip("Displays the total number of folders in the file"); |
| 49 | + Tooltip.install(totalFolderOnFile, totalFolderOnFileTooltip); |
| 50 | + |
| 51 | + Tooltip compressionAlgorithmChoiceBoxTooltip = createTooltip("Select the compression algorithm"); |
| 52 | + Tooltip.install(compressionAlgorithmChoiceBox, compressionAlgorithmChoiceBoxTooltip); |
| 53 | + |
| 54 | + Tooltip progressBarTooltip = createTooltip("Displays the progress of compression/decompression"); |
| 55 | + Tooltip.install(progressBar, progressBarTooltip); |
| 56 | + |
| 57 | + Tooltip infoTextTooltip = createTooltip("Displays information about the application"); |
| 58 | + Tooltip.install(infoText, infoTextTooltip); |
| 59 | + |
| 60 | + Tooltip homeTextTooltip = createTooltip("Navigate to the home screen"); |
| 61 | + Tooltip.install(homeText, homeTextTooltip); |
| 62 | + |
| 63 | + Tooltip hamburgerButtonTooltip = createTooltip("Open the navigation menu"); |
| 64 | + Tooltip.install(hamburgerButton, hamburgerButtonTooltip); |
| 65 | + |
| 66 | + Tooltip diskContainerTooltip = createTooltip("Displays information about the disk"); |
| 67 | + Tooltip.install(diskContainer, diskContainerTooltip); |
| 68 | + |
| 69 | + Tooltip debugTextAreaTooltip = createTooltip("Displays debug information"); |
| 70 | + Tooltip.install(debugTextArea, debugTextAreaTooltip); |
| 71 | + } |
| 72 | + |
| 73 | + private Tooltip createTooltip(String text) { |
| 74 | + Tooltip tooltip = new Tooltip(text); |
| 75 | + tooltip.setShowDelay(Duration.seconds(0.5)); |
| 76 | + tooltip.setStyle("-fx-font-family: 'Segoe UI'; -fx-font-size: 14; -fx-background-color: #FFFFFF; -fx-text-fill: #000000;"); |
| 77 | + |
| 78 | + Node scene = tooltip.getScene().getRoot(); |
| 79 | + scene.setOnMouseMoved(event -> { |
| 80 | + tooltip.setX(event.getScreenX()); |
| 81 | + tooltip.setY(event.getScreenY()); |
| 82 | + }); |
| 83 | + |
| 84 | + return tooltip; |
| 85 | + } |
| 86 | + |
| 87 | +} |
0 commit comments