Help! - Mouse Event with multiple JTables....

Hi
My GUI has a different table on various JPanels. What is the best way of telling the mouseClicked method which table is being clicked on.
Right now, my code is:
public void mouseClicked(MouseEvent me)
Point p = me.getPoint();
int selectedRow = table.rowAtPoint(p);
int selectedColumn = table.columnAtPoint(p);
Object o = table.getValueAt(selectedRow,selectedColumn);
but this means that the method sees only the last table to be created.
How do I tell it what table it's looking at?
Thanks for any help you can provide.

Hi Jim,
yes for some reason ALV expects you to be using different tables. It seems that it does not save the contents of the tables at each call of 'append' rather it waits until 'display' to deal with the table contents at that time, which in your case is the 20 items.
What you can do is use dynamic tables. check this out:
REPORT  ZNRW_ALV_BLOCK                          .
type-pools: slis.
data : NUM1 type I,
NUM type I.
types:
begin of str,
client like mara-mandt,
mat like mara-matnr,
end of str.
data
tab type standard table of str.
data :wa2 type slis_alv_event ,
tab2 like standard table of wa2,
wa1 type slis_layout_alv,
wa type line of slis_t_fieldcat_alv,
tab1 like standard table of wa.
wa-reptext_ddic = 'Client Num'.
wa-fieldname = 'CLIENT'.
wa-tabname = 'TAB'.
wa-ref_fieldname = 'MANDT'.
wa-ref_tabname = 'MARA'.
wa-seltext_l = 'CLIENT'.
append wa to tab1.
wa-reptext_ddic = 'Mat Number'.
wa-fieldname = 'MAT'.
wa-tabname = 'TAB'.
wa-ref_fieldname = 'MATNR'.
wa-ref_tabname = 'MARA'.
wa-seltext_l = 'MATERIAL'.
append wa to tab1.
wa1-no_colhead = 'X'.
wa2-NAME = SLIS_EV_TOP_OF_PAGE.
wa2-FORM = 'WRITE_TOP_PAGE'.
APPEND wa2 TO tab2.
NUM = 0.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = sy-cprog.
DATA tabDREF TYPE REF TO DATA.
FIELD-SYMBOLS <tab> TYPE table.
do 2 times.
CREATE DATA tabdref TYPE table of str.
ASSIGN tabDREF->* TO <tab>.
NUM1 = NUM1 + 10.
refresh: tab.
select mandt matnr up to NUM1 rows from mara into table <tab>.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = wa1
IT_FIELDCAT = tab1
I_TABNAME = 'TAB'
IT_EVENTS = tab2
TABLES
T_OUTTAB = <tab>.
enddo.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
FORM WRITE_TOP_PAGE.
NUM = NUM + 1.
WRITE: / ,
/ 'TABLE NUMBER :', NUM.
ENDFORM.

Similar Messages

  • Custom Event with multiple EventTypes

    Hello All, First thanks for all those who tryied to help me and apologize for my approximative english.
    I would like to create the more properly as possible a Custom Event with multiple EventTypes, like the MouseEvent typicaly. 
    With Some EventType which permit to acces to some attributes and other not. But I'm totaly lost,  The second solution if someone knows how, is to explain to me how to do to acces to the code of the MouseEvent.as 
    Thanks! 
    Ps: you will find below the basis of the code i have begin. 
    package fr.flashProject
        import flash.events.Event;
         * @author
        public class SWFAddressManagerEvent extends Event
            public static const CHANGE_PAGE:String = "change_page";
            public static const ERROR_404:String = "error_404";
            public static const HOME_PAGE:String = "home_page";
            private var _page:String;
            private var _params:Object;
            public function SWFAddressManagerEvent(type:String, pPage:String = null, pParams:Object = null, bubbles:Boolean=false, cancelable:Boolean=false)
                super(type, bubbles, cancelable);
                _page = pPage;
                _params = _params;
            public override function clone():Event
                return new SWFAddressManagerEvent(_type, _page, _params, bubbles, cancelable);
            public override function toString():String
                return formatToString("SWFAddressManagerEvent", "type", "page", "params", "bubbles", "cancelable", "eventPhase");
            public function get page():String { return _page; }
            public function get params():Object { return _params; }       

    I am not sure what you are trying to accomplish but event can have only single type. Event type is just a string that is typically a constant - exactly like your constants.
    When dispatched, each event INSTANCE has only one type. Again, these types are described in a type parameter by a string. Each dispatched MouseEvent DOES NOT have multiple types but ONLY ONE. It does have multiple constants that are used to assign type at runtime as does your event.
    If you are talking about multiple parameters, you already do that in your custom event class. You have _page and _params. Nothing stops you from adding more parameters.
    Also I am not sure why you need getters for _page and _params.

  • How to catch the mouse event from the JTable cell of  the DefaultCellEditor

    Hi, my problem is:
    I have a JTable with the cells of DefaultCellEditor(JComboBox) and added the mouse listener to JTable. I can catch the mouse event from any editor cell when this cell didn't be focused. However, when I click the editor to select one JComboBox element, all the mouse events were intercepted by the editor.
    So, how can I catch the mouse event in this case? In other word, even if I do the operation over the editor, I also need to catch the cursor position.
    Any idea will be highly appreciated!
    Thanks in advance!

    Hi, bbritta,
    Thanks very much for your help. Really, your code could run well, but my case is to catch the JComboBox event. So, when I change the JTextField as JComboBox, it still fail to catch the event. The following is my code. Could you give me any other suggestion?
    Also, any one has a good idea for my problem? I look forward to the right solution to this problem.
    Thanks.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test3
    extends JFrame {
    // JTextField jtf = new JTextField();
    Object[] as = {"aa","bb","cc","dd"};
    JComboBox box = new JComboBox(as);
    public Test3() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = getContentPane();
    String[] head = {
    "One", "Two", "Three"};
    String[][] data = {
    "R1-C1", "R1-C2", "R1-C3"}
    "R2-C1", "R2-C2", "R2-C3"}
    JTable jt = new JTable(data, head);
    box.addMouseListener(new MouseAdapter() {
    // jtf.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JComboBox mouseclick....");
    jt.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e)
    System.out.println("-------------------JTable mouseclick....");
    // jt.setDefaultEditor(Object.class, new DefaultCellEditor(jtf));
    jt.setDefaultEditor(Object.class, new DefaultCellEditor(box));
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    setSize(300, 300);
    public static void main(String[] args) {
    new Test3().setVisible(true);
    }

  • How to adjust mouse event with scaled DesktopPane

    Hi
    I am manjunatha, i am developing Data warehouse product, in this, i am showing inter-related Transforms in desktop pane, i given option to view the content of desktop pane with different scaled factor (ex 100%,50%,25%), when i will scale the content of desktop pane using Graphics class, only content will be scaled, but the events on the Internal frames will be referring 100% view only,(ie mouse event will not effected by scaled factor, so it will be point to 100% view points only, ex at first an Internal Frame will have bounds(10,10,200,200), after i will scale this to 10%, it will be drawn with (1,1,20,20) on the desktop pane, but internally its bounds will be (10,10,200,200) and mouse event will detect Internal Frame at (10,10,200,200) location , instead of scaled (1,1,20,20) location.
    My question is how can i scale the Internal Frames and adjust relevant events to it?
    (You can see screen shot of this page with (Mapplet View as screen name)
    At www.MyDataWarehousing.com)

    Did you ever find a solution to this? How did you scale all the components on resize?

  • Help on ALV with multiple header/item output

    Dear all:
    Below is the actual working code on a multiple header/item display. The alv is supposed to output the details differently in each list. But somehow it only display the last i_tab I gave in all the list(they all look the same). Please help me out here how I can change my code to work properly. Thanks...
    *& Report  ZTEST2
    REPORT  ZTEST2.
    type-pools: slis.
    data : NUM1 type I,
           NUM type I,
           begin of str,
           client like mara-mandt,
           mat like mara-matnr,
           end of str,
           tab like standard table of str.
    data :wa2 type slis_alv_event ,
          tab2 like standard table of wa2,
          wa1 type   slis_layout_alv,
          wa type line of slis_t_fieldcat_alv,
           tab1 like standard table of wa.
           wa-reptext_ddic = 'Client Num'.
           wa-fieldname = 'CLIENT'.
           wa-tabname = 'TAB'.
           wa-ref_fieldname = 'MANDT'.
           wa-ref_tabname = 'MARA'.
           wa-seltext_l = 'CLIENT'.
           append wa to tab1.
           wa-reptext_ddic = 'Mat Number'.
           wa-fieldname = 'MAT'.
           wa-tabname = 'TAB'.
           wa-ref_fieldname = 'MATNR'.
           wa-ref_tabname = 'MARA'.
           wa-seltext_l = 'MATERIAL'.
           append wa to tab1.
          wa1-no_colhead = 'X'.
           wa2-NAME = SLIS_EV_TOP_OF_PAGE.
           wa2-FORM = 'WRITE_TOP_PAGE'.
           APPEND wa2 TO tab2.
    NUM = 0.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
      EXPORTING
        I_CALLBACK_PROGRAM             = sy-cprog.
    do 2 times.
    NUM1 = NUM1 + 10.
    refresh: tab.
    select mandt matnr up to NUM1 rows from mara into table tab.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                        = wa1
        IT_FIELDCAT                      = tab1
        I_TABNAME                        = 'TAB'
        IT_EVENTS                        = tab2
      TABLES
        T_OUTTAB                         = tab.
    enddo.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    FORM WRITE_TOP_PAGE.
      NUM = NUM + 1.
      WRITE: / ,
             / 'TABLE NUMBER :', NUM.
    ENDFORM.

    Hi Jim,
    yes for some reason ALV expects you to be using different tables. It seems that it does not save the contents of the tables at each call of 'append' rather it waits until 'display' to deal with the table contents at that time, which in your case is the 20 items.
    What you can do is use dynamic tables. check this out:
    REPORT  ZNRW_ALV_BLOCK                          .
    type-pools: slis.
    data : NUM1 type I,
    NUM type I.
    types:
    begin of str,
    client like mara-mandt,
    mat like mara-matnr,
    end of str.
    data
    tab type standard table of str.
    data :wa2 type slis_alv_event ,
    tab2 like standard table of wa2,
    wa1 type slis_layout_alv,
    wa type line of slis_t_fieldcat_alv,
    tab1 like standard table of wa.
    wa-reptext_ddic = 'Client Num'.
    wa-fieldname = 'CLIENT'.
    wa-tabname = 'TAB'.
    wa-ref_fieldname = 'MANDT'.
    wa-ref_tabname = 'MARA'.
    wa-seltext_l = 'CLIENT'.
    append wa to tab1.
    wa-reptext_ddic = 'Mat Number'.
    wa-fieldname = 'MAT'.
    wa-tabname = 'TAB'.
    wa-ref_fieldname = 'MATNR'.
    wa-ref_tabname = 'MARA'.
    wa-seltext_l = 'MATERIAL'.
    append wa to tab1.
    wa1-no_colhead = 'X'.
    wa2-NAME = SLIS_EV_TOP_OF_PAGE.
    wa2-FORM = 'WRITE_TOP_PAGE'.
    APPEND wa2 TO tab2.
    NUM = 0.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
    I_CALLBACK_PROGRAM = sy-cprog.
    DATA tabDREF TYPE REF TO DATA.
    FIELD-SYMBOLS <tab> TYPE table.
    do 2 times.
    CREATE DATA tabdref TYPE table of str.
    ASSIGN tabDREF->* TO <tab>.
    NUM1 = NUM1 + 10.
    refresh: tab.
    select mandt matnr up to NUM1 rows from mara into table <tab>.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
    IS_LAYOUT = wa1
    IT_FIELDCAT = tab1
    I_TABNAME = 'TAB'
    IT_EVENTS = tab2
    TABLES
    T_OUTTAB = <tab>.
    enddo.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
    FORM WRITE_TOP_PAGE.
    NUM = NUM + 1.
    WRITE: / ,
    / 'TABLE NUMBER :', NUM.
    ENDFORM.

  • Help on events with MAS

    Hi,
    I'm working with charts and need to do some amount of coding to capture events and display the chart in the tile. I was able to display the chart in MSY. I now need to display it in a specific Business Component in Mobile Sales App using Mobile App Studio.
    I would like to know if there is any document (or) CHM (or) any other material that details the various events / methods that are associated with the existing Tiles / Tile sets that are available in MAS.

    Hi Shiva,
    There are a set of events provided by SAP(Tcode-FQEVENTS or spro menu path Financial Accounting->Contract Accounts Receivable and Payable->Program Enhancements->Define Customer-Specific Function Modules) which help in enhancing the flow of processes in the relevant places to incorporate additional checks and additional activities with in standard programs.
    Each event contains a function module which can be enhanced with user specific activities to include your own logic.
    Search for the event of your specific need by filtering using search terms, read the documentation of the respective events and by using a breakpoint in the function module check is it the right event for you to include your own logic. Copy the function module and make a Z of the same.
    You need to make an entry of the respective Z function module as installation specific function module in the table:V_TFKFBC
    regards
    Gagan

  • Mouse event with Javascript API

    Hi,
    Is it possible to register for mouseclick with the javascript API as with the normal API reference ?
    What I have done in javascript is :
    Add button and menu item to draw circle annotations.
    When you click on a button or a menu item its draws a circle annot on the current page of the doc, but the coordinates are hard coded.
    What I want to do, is click a button to say I want to draw my annot(kind of activate an event listener), then click in the doc where I want the annot to be drawn. So I need to capture the mouse position : I found mouseX and mouseY properties for the doc.
    Thanks

    No, you can only register for mouseclicks from a plugin.
    Leonard

  • Building Contextual Events with multiple parameters

    I am working in JDeveloper 11.1.1.4 and trying to build a contextual event, but ran into a issue that I find unclear. When building the Subscribers on my page definition, in the Property Inspector, how do I define multiple parameters in the customPayLoad element? In all the examples I've found, they reference putting ${payLoad} as the value and they only show one parameter. I need each value to be unique for each parameter. How do I accomplish this?

    for this you can use attributes
    say suppose if you are using table then you can pass values from producer like
                Map attributes = table.getAttributes();
                attributes.put("param1", param1);
                attributes.put("param2", param2);
                attributes.put("param3", param3);
                attributes.put("param4", param4);and consume it like
        public void handleBusinessChkListEvent(Object payload) {
            SelectionEvent selectionEvent = (SelectionEvent)payload;
            UIComponent component = (UIComponent)selectionEvent.getSource();
            String param1=
                (String)component.getAttributes().get("param1");
            String param2= (String)component.getAttributes().get("param2");
            Boolean param3=
                (Boolean)component.getAttributes().get("param3");
            String param4=
                (String)component.getAttributes().get("param4");
    }

  • Help creating DB with multiple Control/Log files

    I just installed 10.0.2.0 and tried to create a database and ran into the following issue. In my 9.2 install I have the following directory setup:
    E:\oracle\oradata\(instance name)
    F:\oracle\oradata\(instance name)
    G:\oracle\oradata\(instance name)
    I have three control files and three log files (1 in each directory). When I use the Database Creation Assistant and specify locations in the Multiplex Redo Log and Controlfiles dialog and then finish the assistant I get an error stating Oracle could not create the folder. I am using the following lines in the dialog.
    {ORACLE_BASE}\oradata\{DB_UNIQUE_NAME}\
    E:\oracle\product\10.2.0\oradata\{DB_UNIQUE_NAME}\
    F:\oracle\product\10.2.0\oradata\{DB_UNIQUE_NAME}\
    When I explore to F:\oracle\product\10.2.0\oradata\ there is a directory called {DB_UNIQUE_NAME} and not the database name I want (for example if I want an instance called RICK the control file would be in E:\oracle\product\10.2.0\oradata\RICK.
    In Oracle 9.2 I specify the locations as follows: E:\oracle\oradata\{DB_NAME}\ and it works just fine. Can someone help me through the exact steps I need to take to set up my new database with control/log files in different drives.
    Thanks
    Richard Anderson

    Hi Richard,
    normally I don't use DBCA to create DBs so I cannot tell how to solve it in DBCA.
    A workaround can be:
    At the end of configuration process in DBCA, instead to have the tool to generate Your DB, configure it to generate only the scripts (if I remeber they are created in $ORACLE_HOME/assistants/dbca dir) and generate them.
    Using a text editor, check the generated scripts and change the wrong strings.
    Hope this helps
    Max

  • IMac/Magic Mouse issue with multiple iMacs.

    I bought two new imacs last month with wireless Magic Mice.  The mice one both of them keep having communication issues.  I returned them to the genius bar and they replaced them.  I'm still having the issue.  I keep having to reset the SMC for them to work, but they only work temporarily.  I've also tried zapping the PRAMs  Any suggestions?

    Do a search of this forum, Just look down this page for two or three other posts with the same theme. Many folks report the issue. Many folks report different ways of solving it for themselves.
    I have had the MM for three weeks now without one issue. I am even experimenting with BetterTouchTool for added utility of my MM.
    Dah•veed
    PS - The Provost of St Mary's Cathedral on Great Western Road is an online friend of mine!

  • Report Template Help - Vertical report with multiple rows on the same line.

    I am tearing my hair out trying to figure a way to do this. I want a vertical report, but with the rows across the page rather than down it.
    e.g.
    ROW1    ROW2    ROW3    ROW4   ROW5
    ROW1    ROW2    ROW3    ROW4   ROW5
    ROW1    ROW2    ROW3    ROW4   ROW5
    ROW1    ROW2    ROW3    ROW4   ROW5
    ROW1    ROW2    ROW3    ROW4   ROW5
    ROW1    ROW2    ROW3    ROW4   ROW5
    ROW1    ROW2    ROW3    ROW4   ROW5
    ROW1    ROW2    ROW3    ROW4   ROW5Has anyone managed to do this?

    Use a custom named column report template. The template could generate either:
    <li> a table with one physical <tt>tr</tt> row, with your "columns" being the logical "rows" of the report rendered as the <tt>td</tt>s within the row
    <li> a list of lists using CSS to render them side-by-side via <tt>float</tt> or <tt>inline-block</tt> (Some examples of similar techniques)

  • Newbie Help - Tab Canvas with Multiple Pages, Arrow to Navigate between

    Hi All,
    I am developing my first form. It is a page that requires several pages. I have created a tab canvas and put the pages on (there are 10 pages). When i run the form, i can see the first 4 page headers, and cannot see the other headers. Is there a way to have a arrow at the top so i can click on it to move the display so i can see the other pages?
    How would this normally be done? What i am after is a similar multi page navigation to that in the assignment screen, or any oracle screen with several pages.
    many thanks
    Rupz

    Hi, thanks for your reply.
    If i press F2, a list of all of the pages appear, but i do not get any arrows.
    I have a single tab canvas with 10 pages on it. The pages fit on the canvas, but not on the display window. Do i need to modify the canvas in any way to get the navigation arrows to display?
    thanks
    Rupz

  • IOS Mouse events with buttons in Flash Professional

    I have 2 images that I have conversted to buttons and exported to actionscript.
    I have placed one object on the screen.
    When I "roll_over", I want it to change to the other image so people know they are on the button.
    When released, I have a "MOUSE_UP" event to trigger a function.
    The problem is if I just use the regular Flash Proffessional "Up, Over, Down & Hit" that I get when I double click on a button, it does not change if I touch the screen and then move over to the object while still touching the screen.
    I can do it in code and trap the evens, but I do not know how to change the pictures.
    Does anyone have any ideas?
    Here is my test file.
    Thanks, Patrick

    There is no Mouse_OVER events for Touch devices.

  • Mouse dragged event with unexpected coordinates

    I am dragging the mouse on a half circle from the middle left to the top middle. This results in mouse events with the coordinates form (10,90) ->(100,10)
    Letting the mouse go and then dragging it further to the left, the coordinates in the of the event are similar than the starting point of the first mouse drag event.
    Can anyone shed some light on this peculiar behavior?

    First of, I have to apologize for the example not being as minimalistic as it might be, but on the plus side, I know now why this happens, I just don't know how to work around it.
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    package javafxtest;
    import java.util.ArrayList;
    import javafx.application.Application;
    import javafx.beans.property.DoubleProperty;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Dimension2D;
    import javafx.geometry.Point2D;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.Label;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Circle;
    import javafx.scene.shape.Polygon;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.shape.Shape;
    import javafx.scene.transform.Rotate;
    import javafx.stage.Stage;
    * @author andi
    public class HandleRotation extends Application {
        private DoubleProperty currentRotation;
        private ArrayList<Double> angles;
        @Override
        public void start(Stage primaryStage) {
            currentRotation = new SimpleDoubleProperty(this, "currentRotation", 10);
            SteeringWheelGroup background = new SteeringWheelGroup(200);
            background.setManaged(false);
            Group g = new Group(background);
            final Point2D centerPoint = new Point2D(100, 100);
            angles = new ArrayList<>(3);
            angles.add(190.0);
            angles.add(270.0);
            angles.add(350.0);
            double step = (180.0 - 2 * currentRotation.doubleValue()) / (angles.size() - 1);
            int radius = 100;
            final int yTranslation = 15; // might be due to the labels
            Polygon handle = createHandle(centerPoint, radius, yTranslation);
            g.getChildren().add(handle);
            StackPane root = new StackPane();
            Scene scene = new Scene(g, 300, 250);
            primaryStage.setTitle("Handle Rotation!");
            primaryStage.setScene(scene);
            primaryStage.show();
         * Calculate the base point for the label. This is the point on the arc, matching the angle.
         * @param center point of the circle
         * @param radius radius of the circle
         * @param angle in degree in [0,180]
         * @return Point on the circle
        Point2D calculateBasePoint(Point2D center, double radius,
                double angle) {
            float newX = (float) (center.getX() + radius * Math.cos(Math.toRadians(angle)));
            float newY = (float) (center.getY() + radius * Math.sin(Math.toRadians(angle)));
            return new Point2D(newX, newY);
         * Create the polygon that represents the handle
         * @param centerPoint
         * @param radius
         * @return
        private Polygon createHandle(final Point2D centerPoint, int radius, final int yTranslation) {
            double baseAngle = 180;
            Point2D p1 = calculateBasePoint(centerPoint, radius, baseAngle - 5);
            Point2D p2 = calculateBasePoint(centerPoint, radius, baseAngle + 2);
            Point2D p3 = calculateBasePoint(centerPoint, radius*0.65, baseAngle + 2);
            Point2D p4 = calculateBasePoint(centerPoint, radius*0.65, baseAngle - 7);
            double[] points = {p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY(), p4.getX(), p4.getY()};
                      Polygon polygon = new Polygon(points);
    //        polygon.setOpacity(0);
            polygon.setTranslateY(-yTranslation);
            final Rotate rotationTransform = new Rotate(currentRotation.doubleValue(), centerPoint.getX(), centerPoint.getY());
            polygon.getTransforms().add(rotationTransform);
            polygon.setOnMouseDragged(new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent event) {
                    if (event.getY() < centerPoint.getY()) {
    System.out.println("Event: "+event);                   
                                                       Point2D point = new Point2D((float)event.getX(), (float)event.getY());
                        double newAngle = angleBetween2Lines(centerPoint, point);
                        if (newAngle < 0) {
                            newAngle = (90 + newAngle)+ 90;
    System.out.println("Set angle on mouse drag: "+newAngle);
                        if (newAngle < 10) {
                            newAngle = 10;
                        if (newAngle > 170) {
                            newAngle = 170;
                        currentRotation.set(newAngle);
            polygon.setOnMouseReleased(new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent event) {
                    snapToNearestAngle();
                    rotationTransform.setAngle(currentRotation.doubleValue());
            return polygon;
         * Snap to the correct angle. Correct angle is angle belonging to the nearest label.
        void snapToNearestAngle() {
            double currentAngle = currentRotation.doubleValue() + 180;
            double currentMin = 360;
            int minIndex = 0;
    System.out.println("Current rotation is "+currentAngle);
            for (int i = 0; i < angles.size(); i++) {
                double angle = angles.get(i);
                double diff = Math.abs(angle - currentAngle);
                if (diff < currentMin) {
                    currentMin = diff;
                    minIndex = i;
    System.out.println("new minDifference at "+i+": "+diff);
            Double destinationAngle = angles.get(minIndex);
    System.out.println("DestinationAngle is "+currentAngle+" -> "+(destinationAngle - 180));
            if (destinationAngle < 180 + 10 || destinationAngle > 360 - 10) {
                throw new IllegalStateException("Angle is out of range: "+currentRotation.doubleValue()+" -> "+destinationAngle);
            currentRotation.set(destinationAngle - 180);
         * Calculate the angle between the vector horizontally to the left from the center
         * and the current point.
         * @param center point
         * @param point current point
         * @return angle in degree
        double angleBetween2Lines(Point2D center, Point2D point) {
            double slope2 = calculateSlope(center, point);
            double angle = Math.atan(slope2);
            if (point.getX() > center.getX()) {
                angle += Math.PI/2;
    System.out.println("Slope: "+slope2+" angle "+Math.toDegrees(angle));
            return Math.abs(Math.toDegrees(angle));
         * Caluculate the slope of the line defined by two points.
         * The first point is the center of a circle and the second
         * point roughly lies on the circle.
         * @param center point
         * @param point on the circle
         * @return slope of the connecting line.
        double calculateSlope(Point2D center, Point2D point) {
    System.out.println("center="+center+",point="+point);       
            double absSlope = Math.abs((point.getY() - center.getY()) / (point.getX() - center.getX()));
            if (point.getY() > center.getY()) {
                if (point.getX() > center.getX()) {
                    // bottom right
                    return -absSlope;
                } else {
                    // bottom left
                    return absSlope;
            } else {
                if (point.getX() > center.getX()) {
                    // top right
                    return absSlope;
                } else {
                    // top left
                    return -absSlope;
         * The main() method is ignored in correctly deployed JavaFX application.
         * main() serves only as fallback in case the application can not be
         * launched through deployment artifacts, e.g., in IDEs with limited FX
         * support. NetBeans ignores main().
         * @param args the command line arguments
        public static void main(String[] args) {
            launch(args);
       private class SteeringWheelGroup extends Group {
            public SteeringWheelGroup(int destinationWidth) {
                int topPadding = 0;
                Rectangle rect = new Rectangle(getImageWidth(), getImageWidth(), Color.RED);
                double scale = destinationWidth / rect.getWidth();
                rect.setScaleX(scale);
                rect.setScaleY(scale);
                Circle circle = new Circle(getImageWidth()/2, getImageWidth()/2, getImageWidth()/2, Color.BLUE);
                circle.setScaleX(scale);
                circle.setScaleY(scale);
                Group rotationGroup = new Group(/*rect,*/ circle);
                rotationGroup.setManaged(false);
                int width = getImageWidth();
                Rectangle clipRectangle = new Rectangle(0, 0, width, width / 2);
                Circle clipCircle = new Circle(width / 2, width / 2, width / 2);
                Shape clip = Shape.intersect(clipRectangle, clipCircle);
                rotationGroup.setClip(clip);
                this.getChildren().add(rotationGroup);
                //double h = calculateHeigthOverHorizon(angle, destinationWidth/2);
                //setTranslateY(-h+topPadding);
            public final int getImageWidth() {
                return 479;
    Here is how you can reproduce my effect:
    Grab the black handle
    Drag the mouse top and right until you approach the angle -90 (have an eye out on the console log)
    Let the mouse go: the handle will snap to 90 degree
    Grab the handle a second time and move further right
    You will see that the angle printed out do not match what you expect.
    Let the mouse go, the Handle snaps back to it's original position
    As the rotation does not happen around the polygon's center, I have to use a Rotaion effect, which is applied. While I can drag the shape from the rotated location the dragging is always measured from its base position.
    So what can I do to work around this?
    final Rotate rotationTransform = new Rotate(currentRotation.doubleValue(), centerPoint.getX(), centerPoint.getY());
    polygon.getTransforms().add(rotationTransform);
    If worse comes to worst, I can use a circular handle covering everything, then I can rotate around its center, but I would like to avoid this.

  • Mouse events causing script to skip

    Hi all,
    The code itself is roughly 500 lines long so I'll only post snippets if needed, but here is the problem I am experiencing. I have a cocoa-applescript application for compressing files with ffmpeg and then rsycning over ssh to our servers at work. I use expect scripts as background processes (expect_command &> /tmp/output.txt &) to read and display progress
    Here is the problem I am experiencing. When the application is run (both inside and outside of Xcode, as well as on other machines) every time the mouse moves or clicks it causes the applescript to skip around. So for instance, if it is in the middle of compression and the mouse is moved it'll exit the repeat loop that is displaying progress and move to uploading. If I don't touch anything all works just fine. There is literally nothing in the code (save for GUI buttons that initiate sender routines) that has to do with mouse events, in fact I didn't even think it was possible to intercept mouse events with applescript.
    I am just looking for anything that could shed some light on this situation. Either ideas of what might be causing it (I've tried everything I can think of, i.e cleaning, rebuilding, testing on multiple platforms), or workarounds. Like I'd even be happy if I can just get it to ignore the mouse during my repeat loops for progress.
    First time poster, but long time reader so sorry if I am breaking any forum rules. I am happy to provide any info that can help diagnose this very very strange bug.

    Hard to say without seeing some code, but you might try adding some log statements around the code where it is moving on to the next step to see why the previous step is exiting. 
    In general you should avoid using any significant AppleScript repeat loops, since events will get backed up in the queue until the system is given some time to process them.  The timing of the actual problem may also be getting distorted by any backed up events, since they would be delayed while the script is in the loops.

Maybe you are looking for

  • FM not getting read in Idoc ?

    Hello All,     In WE20 --> Partner Type KU --> kunnr --> Outbound Parameters -->                    Partner function and Message Type --> Message Control --> Process Code --> Function MOdule (IDOC_OUTPUT_DESADV01). I found a user-exit in this and wan

  • How can I generate synchroniz​ed pulse trains with 6602?

    Hi, I would like to generate multiple pulse trains with different frequencies with the 6602 TIO card. Currently I am able to generate pulse trains with different frequencies. But is there any way to synchronize all the pulse trains? For example, I'd

  • [Solved]Cannot install any package with pacman

    Hi, today i tried a system update via pacman -Syu and i get these error messages Konnte Datei 'curl-7.19.6-1-i686.pkg.tar.gz' nicht von ftp.archlinux.org übertragen : File unavailable (e.g., file not found, no access) so it seems that these files are

  • BAPI LSMW

    Why is BAPI method of LSMW considered the most reliable & fast of all methods . I would think the IDOC is most reliable because of the tracing features and Direct Input would be the fastest method

  • MY MAC BOOK PRO IS NOT RECOGNIZING MY POCKET WIZARDS

    My mac book pro isnt recognizing my pocket wizards