Example usage for javafx.scene.input MouseEvent isPrimaryButtonDown

List of usage examples for javafx.scene.input MouseEvent isPrimaryButtonDown

Introduction

In this page you can find the example usage for javafx.scene.input MouseEvent isPrimaryButtonDown.

Prototype

public final boolean isPrimaryButtonDown() 

Source Link

Document

Returns true if primary button (button 1, usually the left) is currently pressed.

Usage

From source file:Main.java

private static int modifiers(final InputEvent event) {
    if (event instanceof MouseEvent) {
        final MouseEvent mouseEvent = (MouseEvent) event;
        int modifiers = 0;
        if (mouseEvent.isAltDown()) {
            modifiers |= java.awt.event.MouseEvent.ALT_MASK;
            modifiers |= java.awt.event.MouseEvent.ALT_DOWN_MASK;
        }/*from  www  .  ja  va2s  .co  m*/
        if (mouseEvent.isControlDown()) {
            modifiers |= java.awt.event.MouseEvent.CTRL_MASK;
            modifiers |= java.awt.event.MouseEvent.CTRL_DOWN_MASK;
        }
        if (mouseEvent.isMetaDown()) {
            modifiers |= java.awt.event.MouseEvent.META_MASK;
            modifiers |= java.awt.event.MouseEvent.META_DOWN_MASK;
        }
        if (mouseEvent.isShiftDown()) {
            modifiers |= java.awt.event.MouseEvent.SHIFT_MASK;
            modifiers |= java.awt.event.MouseEvent.SHIFT_DOWN_MASK;
        }
        if (mouseEvent.isPrimaryButtonDown()) {
            modifiers |= java.awt.event.MouseEvent.BUTTON1_MASK;
        }
        if (mouseEvent.isMiddleButtonDown()) {
            modifiers |= java.awt.event.MouseEvent.BUTTON2_MASK;
        }
        if (mouseEvent.isSecondaryButtonDown()) {
            modifiers |= java.awt.event.MouseEvent.BUTTON3_MASK;
        }
        return modifiers;
    }

    if (event instanceof KeyEvent) {
        final KeyEvent keyEvent = (KeyEvent) event;
        int modifiers = 0;
        if (keyEvent.isAltDown()) {
            modifiers |= java.awt.event.KeyEvent.ALT_MASK;
        }
        if (keyEvent.isControlDown()) {
            modifiers |= java.awt.event.KeyEvent.CTRL_MASK;
        }
        if (keyEvent.isMetaDown()) {
            modifiers |= java.awt.event.KeyEvent.META_MASK;
        }
        if (keyEvent.isShiftDown()) {
            modifiers |= java.awt.event.KeyEvent.SHIFT_MASK;
        }
        return modifiers;
    }

    return 0;
}

From source file:ijfx.ui.widgets.PluginInfoPane.java

private void onMouseClicked(MouseEvent event) {
    if (event.isPrimaryButtonDown() == false) {
        updateWebView();
    }
}

From source file:gmailclientfx.controllers.SpamController.java

public void fetchSpam() {
    ObservableList<MyMessage> data = FXCollections.observableArrayList();
    stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId"));
    stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject"));
    stupacFrom.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender"));
    stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived"));

    spamTable.setItems(data);//from   www  . j  a  v  a 2 s .c  om
    spamTable.setOnMousePressed(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.isPrimaryButtonDown() && event.getClickCount() == 2) {
                MyMessage selectedMsg = spamTable.getSelectionModel().getSelectedItem();
                PregledEmailaHelper.setMsg(selectedMsg);
                try {
                    Parent root;
                    FXMLLoader loader = new FXMLLoader();
                    loader.setLocation(
                            getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml"));
                    root = loader.load();
                    Stage stage = new Stage();
                    stage.setScene(new Scene(root));
                    PregledEmailaController pgec = loader.getController();
                    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                        @Override
                        public void handle(WindowEvent event) {
                            pgec.bodyWebViewEngine.load(null);
                            System.out.println("Closing form!");
                        }

                    });
                    stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - "
                            + PregledEmailaHelper.getMsg().getSender());
                    stage.show();
                } catch (IOException ex) {
                    Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }

    });
    try {
        IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(),
                GmailClient.getAccesToken(), true);
        Folder spam = null;
        Folder[] folders = store.getDefaultFolder().list("*");
        for (Folder f : folders) {
            IMAPFolder imapFolder = (IMAPFolder) f;
            for (String att : imapFolder.getAttributes()) {
                if ("\\Junk".equals(att)) {
                    spam = f;
                }
            }
        }
        spam.open(Folder.READ_WRITE);

        MimeMessage[] seenMessages = (MimeMessage[]) spam
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true));
        for (int i = 0; i < seenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "SPAM");
            data.add(msg);
        }
        MimeMessage[] unseenMessages = (MimeMessage[]) spam
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
        for (int i = 0; i < unseenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "SPAM");
            data.add(msg);
        }
        spam.close(false);
        store.close();
    } catch (Exception ex) {
        Logger.getLogger(SpamController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:gmailclientfx.controllers.PoslaneController.java

public void fetchPoslane() {
    ObservableList<MyMessage> data = FXCollections.observableArrayList();
    stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId"));
    stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject"));
    stupacTo.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender"));
    stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived"));

    poslaneTable.setItems(data);//from  w  ww  . ja v  a2 s .c  o m
    poslaneTable.setOnMousePressed(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.isPrimaryButtonDown() && event.getClickCount() == 2) {
                MyMessage selectedMsg = poslaneTable.getSelectionModel().getSelectedItem();
                PregledEmailaHelper.setMsg(selectedMsg);
                try {
                    Parent root;
                    FXMLLoader loader = new FXMLLoader();
                    loader.setLocation(
                            getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml"));
                    root = loader.load();
                    Stage stage = new Stage();
                    stage.setScene(new Scene(root));
                    stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - "
                            + PregledEmailaHelper.getMsg().getSender());
                    stage.show();
                    PregledEmailaController pgec = loader.getController();
                    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                        @Override
                        public void handle(WindowEvent event) {
                            pgec.bodyWebViewEngine.load(null);
                            System.out.println("Closing form!");
                        }

                    });
                } catch (IOException ex) {
                    Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }

    });
    try {
        IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(),
                GmailClient.getAccesToken(), true);

        Folder poslane = null;
        Folder[] folders = store.getDefaultFolder().list("*");
        for (Folder f : folders) {
            IMAPFolder imapFolder = (IMAPFolder) f;
            for (String att : imapFolder.getAttributes()) {
                if ("\\Sent".equals(att)) {
                    poslane = f;
                }
            }
        }
        poslane.open(Folder.READ_WRITE);

        MimeMessage[] seenMessages = (MimeMessage[]) poslane
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true));
        for (int i = 0; i < seenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "SENT");
            data.add(msg);
        }

        MimeMessage[] unseenMessages = (MimeMessage[]) poslane
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
        for (int i = 0; i < unseenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "SENT");
            data.add(msg);
        }
        poslane.close(false);
        store.close();
    } catch (Exception ex) {
        Logger.getLogger(PoslaneController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:gmailclientfx.controllers.ObrisaneController.java

public void fetchObrisane() {
    ObservableList<MyMessage> data = FXCollections.observableArrayList();
    stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId"));
    stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject"));
    stupacFrom.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender"));
    stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived"));

    obrisaneTable.setItems(data);/*from w  w  w .j av  a2s . co m*/
    obrisaneTable.setOnMousePressed(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.isPrimaryButtonDown() && event.getClickCount() == 2) {
                MyMessage selectedMsg = obrisaneTable.getSelectionModel().getSelectedItem();
                PregledEmailaHelper.setMsg(selectedMsg);
                try {
                    Parent root;
                    FXMLLoader loader = new FXMLLoader();
                    loader.setLocation(
                            getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml"));
                    root = loader.load();
                    Stage stage = new Stage();
                    stage.setScene(new Scene(root));
                    stage.show();
                    PregledEmailaController pgec = loader.getController();
                    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                        @Override
                        public void handle(WindowEvent event) {
                            pgec.bodyWebViewEngine.load(null);
                            System.out.println("Closing form!");
                        }

                    });
                    stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - "
                            + PregledEmailaHelper.getMsg().getSender());
                } catch (IOException ex) {
                    Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }

    });
    try {
        IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(),
                GmailClient.getAccesToken(), true);

        Folder obrisane = null;
        Folder[] folders = store.getDefaultFolder().list("*");
        for (Folder f : folders) {
            IMAPFolder imapFolder = (IMAPFolder) f;
            for (String att : imapFolder.getAttributes()) {
                if ("\\Trash".equals(att)) {
                    obrisane = f;
                }
            }
        }
        obrisane.open(Folder.READ_WRITE);

        MimeMessage[] seenMessages = (MimeMessage[]) obrisane
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true));
        for (int i = 0; i < seenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "DELETED");
            data.add(msg);
        }

        MimeMessage[] unseenMessages = (MimeMessage[]) obrisane
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
        for (int i = 0; i < unseenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "DELETED");
            data.add(msg);
        }
        obrisane.close(false);
        store.close();
    } catch (Exception ex) {
        Logger.getLogger(ObrisaneController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:gmailclientfx.controllers.NedovrseneController.java

public void fetchNedovrsene() {
    ObservableList<MyMessage> data = FXCollections.observableArrayList();
    stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId"));
    stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject"));
    stupacTo.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender"));
    stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived"));

    nedovrseneTable.setItems(data);/*from   ww  w  .ja v a2  s .co  m*/
    nedovrseneTable.setOnMousePressed(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.isPrimaryButtonDown() && event.getClickCount() == 2) {
                MyMessage selectedMsg = nedovrseneTable.getSelectionModel().getSelectedItem();
                PregledEmailaHelper.setMsg(selectedMsg);
                try {
                    Parent root;
                    FXMLLoader loader = new FXMLLoader();
                    loader.setLocation(
                            getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml"));
                    root = loader.load();
                    Stage stage = new Stage();
                    stage.setScene(new Scene(root));
                    stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - "
                            + PregledEmailaHelper.getMsg().getSender());
                    stage.show();
                    PregledEmailaController pgec = loader.getController();
                    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                        @Override
                        public void handle(WindowEvent event) {
                            pgec.bodyWebViewEngine.load(null);
                            System.out.println("Closing form!");
                        }

                    });
                } catch (IOException ex) {
                    Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }

    });

    try {
        IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(),
                GmailClient.getAccesToken(), true);

        Folder nedovrsene = null;
        Folder[] folders = store.getDefaultFolder().list("*");
        for (Folder f : folders) {
            IMAPFolder imapFolder = (IMAPFolder) f;
            for (String att : imapFolder.getAttributes()) {
                if ("\\Drafts".equals(att)) {
                    nedovrsene = f;
                }
            }
        }
        nedovrsene.open(Folder.READ_WRITE);

        MimeMessage[] seenMessages = (MimeMessage[]) nedovrsene
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true));
        for (int i = 0; i < seenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "DRAFT");
            data.add(msg);
        }

        MimeMessage[] unseenMessages = (MimeMessage[]) nedovrsene
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
        for (int i = 0; i < unseenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "DRAFT");
            data.add(msg);
        }
        nedovrsene.close(false);
        store.close();
    } catch (Exception ex) {
        Logger.getLogger(NedovrseneController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:gmailclientfx.controllers.InboxController.java

public void fetchInbox() {
    ObservableList<MyMessage> data = FXCollections.observableArrayList();
    stupacId.setCellValueFactory(new PropertyValueFactory<MyMessage, Integer>("TblId"));
    stupacNaslov.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Subject"));
    stupacPosiljatelj.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("Sender"));
    stupacDatum.setCellValueFactory(new PropertyValueFactory<MyMessage, String>("DateReceived"));

    Platform.runLater(() -> {/*from   w w  w . j  a  v  a2  s .c  o m*/
        inboxTable.setItems(data);
    });
    inboxTable.setOnMousePressed(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent event) {
            if (event.isPrimaryButtonDown() && event.getClickCount() == 2) {
                MyMessage selectedMsg = inboxTable.getSelectionModel().getSelectedItem();
                PregledEmailaHelper.setMsg(selectedMsg);
                try {
                    Parent root;
                    FXMLLoader loader = new FXMLLoader();
                    loader.setLocation(
                            getClass().getClassLoader().getResource("gmailclientfx/views/pregledEmaila.fxml"));
                    root = loader.load();
                    Stage stage = new Stage();
                    stage.setScene(new Scene(root));
                    stage.setTitle(PregledEmailaHelper.getMsg().getSubject() + " - "
                            + PregledEmailaHelper.getMsg().getSender());
                    stage.show();
                    PregledEmailaController pgec = loader.getController();
                    stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                        @Override
                        public void handle(WindowEvent event) {
                            pgec.bodyWebViewEngine.load(null);
                            System.out.println("Closing form!");
                        }

                    });
                } catch (IOException ex) {
                    Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }

    });

    try {
        IMAPStore store = OAuth2Authenticator.connectToImap("imap.gmail.com", 993, GmailClient.getEmail(),
                GmailClient.getAccesToken(), true);
        Folder inbox = store.getFolder("INBOX");
        inbox.open(Folder.READ_WRITE);
        int getSeenCount = inbox.getMessageCount();
        FetchProfile fp = new FetchProfile();
        fp.add(FetchProfile.Item.ENVELOPE);
        fp.add(FetchProfileItem.FLAGS);
        fp.add(FetchProfileItem.CONTENT_INFO);
        fp.add("X-mailer");

        MimeMessage[] seenMessages = (MimeMessage[]) inbox
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), true));
        for (int i = 0; i < seenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(seenMessages[i], i + 1, "INBOX");
            data.add(msg);
        }

        MimeMessage[] unseenMessages = (MimeMessage[]) inbox
                .search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
        for (int i = 0; i < unseenMessages.length; i++) {
            MyMessage msg = GmailClient.fetchMessage(unseenMessages[i], i + 1, "INBOX");
            data.add(msg);
        }

        inbox.close(false);
        store.close();
    } catch (Exception ex) {
        Logger.getLogger(InboxController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Main.java

public static java.awt.event.MouseEvent toAwt(final MouseEvent event) {
    final EventType type = event.getEventType();
    if (null == type) {
        return null;
    }/*w ww .  j  a  va 2s .  co  m*/

    final int id;
    if (MouseEvent.MOUSE_MOVED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_MOVED;
    } else if (MouseEvent.MOUSE_DRAGGED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_DRAGGED;
    } else if (MouseEvent.MOUSE_CLICKED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_CLICKED;
    } else if (MouseEvent.MOUSE_PRESSED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_PRESSED;
    } else if (MouseEvent.MOUSE_RELEASED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_RELEASED;
    } else if (MouseEvent.MOUSE_ENTERED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_ENTERED;
    } else if (MouseEvent.MOUSE_EXITED.equals(type)) {
        id = java.awt.event.MouseEvent.MOUSE_EXITED;
    } else {
        return null;
    }

    final int button;
    if (event.isPrimaryButtonDown()) {
        button = java.awt.event.MouseEvent.BUTTON1;
    } else if (event.isMiddleButtonDown()) {
        button = java.awt.event.MouseEvent.BUTTON2;
    } else if (event.isSecondaryButtonDown()) {
        button = java.awt.event.MouseEvent.BUTTON3;
    } else {
        button = java.awt.event.MouseEvent.NOBUTTON;
    }

    final long when = -1;
    final int modifiers = modifiers(event);
    final int x = (int) event.getX();
    final int y = (int) event.getY();
    final int xAbs = Integer.MAX_VALUE;
    final int yAbs = Integer.MAX_VALUE;
    final int count = event.getClickCount();
    boolean popup = event.isPopupTrigger();
    if (MouseEvent.MOUSE_CLICKED.equals(type) && event.isMetaDown()) {
        // mack books use meta flag for right-clicks
        popup = true;
    }
    return new java.awt.event.MouseEvent(empty, id, when, modifiers, x, y, xAbs, yAbs, count, popup, button);
}

From source file:nars.rl.util.ThreeDView.java

private void handleMouse(Scene scene, final Node root) {
    scene.setOnMousePressed(new EventHandler<MouseEvent>() {
        @Override//from  ww w  .j a  v a  2  s .  com
        public void handle(MouseEvent me) {
            mousePosX = me.getSceneX();
            mousePosY = me.getSceneY();
            mouseOldX = me.getSceneX();
            mouseOldY = me.getSceneY();
        }
    });
    scene.setOnMouseDragged(new EventHandler<MouseEvent>() {
        @Override
        public void handle(MouseEvent me) {
            mouseOldX = mousePosX;
            mouseOldY = mousePosY;
            mousePosX = me.getSceneX();
            mousePosY = me.getSceneY();
            mouseDeltaX = (mousePosX - mouseOldX);
            mouseDeltaY = (mousePosY - mouseOldY);

            double modifier = 1.0;
            double modifierFactor = 0.1;

            if (me.isControlDown()) {
                modifier = 0.1;
            }
            if (me.isShiftDown()) {
                modifier = 10.0;
            }
            if (me.isPrimaryButtonDown()) {
                cameraXform.ry
                        .setAngle(cameraXform.ry.getAngle() - mouseDeltaX * modifierFactor * modifier * 2.0); // +
                cameraXform.rx
                        .setAngle(cameraXform.rx.getAngle() + mouseDeltaY * modifierFactor * modifier * 2.0); // -
            } else if (me.isSecondaryButtonDown()) {
                double z = camera.getTranslateZ();
                double newZ = z + mouseDeltaX * modifierFactor * modifier;
                camera.setTranslateZ(newZ);
            } else if (me.isMiddleButtonDown()) {
                cameraXform2.t.setX(cameraXform2.t.getX() + mouseDeltaX * modifierFactor * modifier * 0.3); // -
                cameraXform2.t.setY(cameraXform2.t.getY() + mouseDeltaY * modifierFactor * modifier * 0.3); // -
            }
        }
    });
}

From source file:Main.java

@Override
public void start(final Stage stage) {
    stage.setTitle("Xylophone");

    camOffset.getChildren().add(cam);/* ww w  .j  av  a 2s .c om*/
    resetCam();

    final Scene scene = new Scene(camOffset, 800, 600, true);
    scene.setFill(new RadialGradient(225, 0.85, 300, 300, 500, false, CycleMethod.NO_CYCLE,
            new Stop[] { new Stop(0f, Color.BLUE), new Stop(1f, Color.LIGHTBLUE) }));
    scene.setCamera(new PerspectiveCamera());

    final AudioClip bar1Note = new AudioClip(Main.class.getResource("audio/Note1.wav").toString());
    final AudioClip bar2Note = new AudioClip(Main.class.getResource("audio/Note2.wav").toString());
    final AudioClip bar3Note = new AudioClip(Main.class.getResource("audio/Note3.wav").toString());
    final AudioClip bar4Note = new AudioClip(Main.class.getResource("audio/Note4.wav").toString());
    final AudioClip bar5Note = new AudioClip(Main.class.getResource("audio/Note5.wav").toString());
    final AudioClip bar6Note = new AudioClip(Main.class.getResource("audio/Note6.wav").toString());
    final AudioClip bar7Note = new AudioClip(Main.class.getResource("audio/Note7.wav").toString());
    final AudioClip bar8Note = new AudioClip(Main.class.getResource("audio/Note8.wav").toString());

    Group rectangleGroup = new Group();
    rectangleGroup.getTransforms().add(shear);
    rectangleGroup.setDepthTest(DepthTest.ENABLE);

    double xStart = 260.0;
    double xOffset = 30.0;
    double yPos = 300.0;
    double zPos = 0.0;
    double barWidth = 22.0;
    double barDepth = 7.0;

    // Base1
    Cube base1Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0);
    base1Cube.setTranslateX(xStart + 135);
    base1Cube.setTranslateZ(yPos + 20.0);
    base1Cube.setTranslateY(11.0);
    base1Cube.setScaleX(barWidth * 11.5);
    base1Cube.setScaleZ(10.0);
    base1Cube.setScaleY(barDepth * 2.0);

    // Base2
    Cube base2Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0);
    base2Cube.setTranslateX(xStart + 135);
    base2Cube.setTranslateZ(yPos - 20.0);
    base2Cube.setTranslateY(11.0);
    base2Cube.setScaleX(barWidth * 11.5);
    base2Cube.setScaleZ(10.0);
    base2Cube.setScaleY(barDepth * 2.0);

    // Bar1
    Cube bar1Cube = new Cube(1.0, Color.PURPLE, 1.0);
    bar1Cube.setTranslateX(xStart + 1 * xOffset);
    bar1Cube.setTranslateZ(yPos);
    bar1Cube.setScaleX(barWidth);
    bar1Cube.setScaleZ(100.0);
    bar1Cube.setScaleY(barDepth);

    // Bar2
    Cube bar2Cube = new Cube(1.0, Color.BLUEVIOLET, 1.0);
    bar2Cube.setTranslateX(xStart + 2 * xOffset);
    bar2Cube.setTranslateZ(yPos);
    bar2Cube.setScaleX(barWidth);
    bar2Cube.setScaleZ(95.0);
    bar2Cube.setScaleY(barDepth);

    // Bar3
    Cube bar3Cube = new Cube(1.0, Color.BLUE, 1.0);
    bar3Cube.setTranslateX(xStart + 3 * xOffset);
    bar3Cube.setTranslateZ(yPos);
    bar3Cube.setScaleX(barWidth);
    bar3Cube.setScaleZ(90.0);
    bar3Cube.setScaleY(barDepth);

    // Bar4
    Cube bar4Cube = new Cube(1.0, Color.GREEN, 1.0);
    bar4Cube.setTranslateX(xStart + 4 * xOffset);
    bar4Cube.setTranslateZ(yPos);
    bar4Cube.setScaleX(barWidth);
    bar4Cube.setScaleZ(85.0);
    bar4Cube.setScaleY(barDepth);

    // Bar5
    Cube bar5Cube = new Cube(1.0, Color.GREENYELLOW, 1.0);
    bar5Cube.setTranslateX(xStart + 5 * xOffset);
    bar5Cube.setTranslateZ(yPos);
    bar5Cube.setScaleX(barWidth);
    bar5Cube.setScaleZ(80.0);
    bar5Cube.setScaleY(barDepth);

    // Bar6
    Cube bar6Cube = new Cube(1.0, Color.YELLOW, 1.0);
    bar6Cube.setTranslateX(xStart + 6 * xOffset);
    bar6Cube.setTranslateZ(yPos);
    bar6Cube.setScaleX(barWidth);
    bar6Cube.setScaleZ(75.0);
    bar6Cube.setScaleY(barDepth);

    // Bar7
    Cube bar7Cube = new Cube(1.0, Color.ORANGE, 1.0);
    bar7Cube.setTranslateX(xStart + 7 * xOffset);
    bar7Cube.setTranslateZ(yPos);
    bar7Cube.setScaleX(barWidth);
    bar7Cube.setScaleZ(70.0);
    bar7Cube.setScaleY(barDepth);

    // Bar8
    Cube bar8Cube = new Cube(1.0, Color.RED, 1.0);
    bar8Cube.setTranslateX(xStart + 8 * xOffset);
    bar8Cube.setTranslateZ(yPos);
    bar8Cube.setScaleX(barWidth);
    bar8Cube.setScaleZ(65.0);
    bar8Cube.setScaleY(barDepth);

    bar1Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar1Note.play();
        }
    });
    bar2Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar2Note.play();
        }
    });
    bar3Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar3Note.play();
        }
    });
    bar4Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar4Note.play();
        }
    });
    bar5Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar5Note.play();
        }
    });
    bar6Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar6Note.play();
        }
    });
    bar7Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar7Note.play();
        }
    });
    bar8Cube.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            bar8Note.play();
        }
    });

    rectangleGroup.getChildren().addAll(base1Cube, base2Cube, bar1Cube, bar2Cube, bar3Cube, bar4Cube, bar5Cube,
            bar6Cube, bar7Cube, bar8Cube);
    rectangleGroup.setScaleX(2.5);
    rectangleGroup.setScaleY(2.5);
    rectangleGroup.setScaleZ(2.5);
    cam.getChildren().add(rectangleGroup);

    double halfSceneWidth = 375; // scene.getWidth()/2.0;
    double halfSceneHeight = 275; // scene.getHeight()/2.0;
    cam.p.setX(halfSceneWidth);
    cam.ip.setX(-halfSceneWidth);
    cam.p.setY(halfSceneHeight);
    cam.ip.setY(-halfSceneHeight);

    frameCam(stage, scene);

    scene.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            mousePosX = me.getX();
            mousePosY = me.getY();
            mouseOldX = me.getX();
            mouseOldY = me.getY();
            //System.out.println("scene.setOnMousePressed " + me);
        }
    });
    scene.setOnMouseDragged(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            mouseOldX = mousePosX;
            mouseOldY = mousePosY;
            mousePosX = me.getX();
            mousePosY = me.getY();
            mouseDeltaX = mousePosX - mouseOldX;
            mouseDeltaY = mousePosY - mouseOldY;
            if (me.isAltDown() && me.isShiftDown() && me.isPrimaryButtonDown()) {
                double rzAngle = cam.rz.getAngle();
                cam.rz.setAngle(rzAngle - mouseDeltaX);
            } else if (me.isAltDown() && me.isPrimaryButtonDown()) {
                double ryAngle = cam.ry.getAngle();
                cam.ry.setAngle(ryAngle - mouseDeltaX);
                double rxAngle = cam.rx.getAngle();
                cam.rx.setAngle(rxAngle + mouseDeltaY);
            } else if (me.isShiftDown() && me.isPrimaryButtonDown()) {
                double yShear = shear.getY();
                shear.setY(yShear + mouseDeltaY / 1000.0);
                double xShear = shear.getX();
                shear.setX(xShear + mouseDeltaX / 1000.0);
            } else if (me.isAltDown() && me.isSecondaryButtonDown()) {
                double scale = cam.s.getX();
                double newScale = scale + mouseDeltaX * 0.01;
                cam.s.setX(newScale);
                cam.s.setY(newScale);
                cam.s.setZ(newScale);
            } else if (me.isAltDown() && me.isMiddleButtonDown()) {
                double tx = cam.t.getX();
                double ty = cam.t.getY();
                cam.t.setX(tx + mouseDeltaX);
                cam.t.setY(ty + mouseDeltaY);
            }
        }
    });
    scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            if (KeyCode.A.equals(ke.getCode())) {
                resetCam();
                shear.setX(0.0);
                shear.setY(0.0);
            }
            if (KeyCode.F.equals(ke.getCode())) {
                frameCam(stage, scene);
                shear.setX(0.0);
                shear.setY(0.0);
            }
            if (KeyCode.SPACE.equals(ke.getCode())) {
                if (stage.isFullScreen()) {
                    stage.setFullScreen(false);
                    frameCam(stage, scene);
                } else {
                    stage.setFullScreen(true);
                    frameCam(stage, scene);
                }
            }
        }
    });

    stage.setScene(scene);
    stage.show();
}