// Archivo: VirtualDesktop.java import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.Tooltip; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.input.MouseEvent; import javafx.scene.layout.*; import javafx.stage.Stage; import javafx.stage.StageStyle; public class VirtualDesktop extends Application { @Override public void start(Stage primaryStage) { // Fondo de Escritorio StackPane desktop = new StackPane(); desktop.setStyle("-fx-background-image: url('background.jpg'); -fx-background-size: cover;"); // Icono de Aplicación 1 VBox app1 = createAppIcon("Aplicación 1", "app1.png", () -> openAppWindow("Aplicación 1")); app1.setTranslateX(-200); app1.setTranslateY(-100); // Icono de Aplicación 2 VBox app2 = createAppIcon("Aplicación 2", "app2.png", () -> openAppWindow("Aplicación 2")); app2.setTranslateX(-200); app2.setTranslateY(-50); desktop.getChildren().addAll(app1, app2); // Barra de Tareas HBox taskbar = new HBox(); taskbar.setStyle("-fx-background-color: rgba(0,0,0,0.7);"); taskbar.setPadding(new Insets(5)); taskbar.setAlignment(Pos.CENTER_LEFT); taskbar.setPrefHeight(40); Label taskbarLabel = new Label("Escritorio Virtual"); taskbarLabel.setStyle("-fx-text-fill: white; -fx-font-size: 16px;"); taskbar.getChildren().add(taskbarLabel); // Layout Principal BorderPane root = new BorderPane(); root.setCenter(desktop); root.setBottom(taskbar); Scene scene = new Scene(root, 800, 600); primaryStage.setTitle("Escritorio Virtual"); primaryStage.setScene(scene); primaryStage.show(); } private VBox createAppIcon(String name, String iconPath, Runnable onClick) { ImageView icon = new ImageView(new Image(iconPath)); icon.setFitWidth(64); icon.setFitHeight(64); Label label = new Label(name); label.setStyle("-fx-text-fill: white; -fx-font-size: 14px;"); label.setPadding(new Insets(5, 0, 0, 0)); VBox vbox = new VBox(icon, label); vbox.setAlignment(Pos.CENTER); vbox.setSpacing(5); vbox.setCursor(javafx.scene.Cursor.HAND); Tooltip tooltip = new Tooltip(name); Tooltip.install(vbox, tooltip); vbox.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> onClick.run()); return vbox; } private void openAppWindow(String appName) { Stage appStage = new Stage(); appStage.initStyle(StageStyle.DECORATED); BorderPane pane = new BorderPane(); pane.setStyle("-fx-background-color: #ffffff; -fx-border-color: #000000;"); pane.setPadding(new Insets(10)); Label label = new Label("Contenido de " + appName); pane.setCenter(label); Scene scene = new Scene(pane, 400, 300); appStage.setScene(scene); appStage.setTitle(appName); appStage.show(); } public static void main(String[] args) { launch(args); } }