Double value of mouse click

hi, I am making a program in which I need to get the Double value of the point where I clicked on my JPanel. Is it possible to get the Double or float value of the point at which mouse click event occur.

The mouse pointer is always exactly on one physical pixel, hence the integer coordinates are most accurate. You could pretend that the user means some other point (like the center of the pixel instead of the upper left corner) than the one s/he is pointing, that's your own business.
You may actually lose accuracy when you cast the ints to doubles or floats.

Similar Messages

  • Updating control values without mouse clicking elsewhere on screen

    I have an application where I want to update the values in text and numeric controls without clicking elsewhere on the screen to the accept values. I haven't run accross this issue in the past because I have always had a stop button, which acts to accept the values. But with this application, I am using an Event Structure to monitor the front panel close (red X) to close the VI. I was thinking I could add another event to monitor if the mouse moves, if so then I could use a property node to accept values in the text and numeric controls. But what property node? Any other ideas?
    Doug Ferguson
    www.southerndaqsolutions.com

    use the event for the specific control---> value change.  It will tell you when the user clicks out of the control. If you want to know AS they are changing it, then you can set the control to synchronous display from the context advanced menu.
    Paul <--Always Learning!!!
    sense and simplicity.
    Browse my sample VIs?

  • Double image on mouse click

    Hi captivators
    I am editing a couple of demo slides. I have moved the
    background images up about 10 pixels as the action takes place
    right at the bottom of the screen. I have raised the mouse pointer
    in line with the buttons and all works fine until the mouse shows a
    click. When it clicks the old lower image appears on top of the new
    one creating a double image. How do I avoid this happening?

    Hi ntompkins
    What sounds like is happening is that maybe you took what was
    originally the background image, modified and reinserted as a
    standard image? If so, you may wish to try right-clicking and
    choosing "merge into background".
    Assuming you either already tried that and it isn't working
    or for some other reason it isn't working, you might try inserting
    a blank slide, configuring the background with the image, then
    select and copy all objects from the errant slide to the new.
    Finally, delete the new slide and maybe adjust the mouse position.
    Cheers... Rick

  • The Jtree is not refreshing with new values when mouse click on the node

    hi ,
    I am creating a tree from a vector .The values in the vector is coming from the JTable data after satisfing the some condition. But the data in the Jtable is changing time to time so the data in the vector is also changing .
    But the problem is that when first I create a tree with that data the tree is created but for the next time I click on the tree node the tree is not changing i.e. it is not created with the new values that is stored in the vector at that time .what to do .Please help
    I am using DefaultMutableTreeNode for creating the tree .In starting I have created one root and the one it's child .Now the next subtree of the root child have to be created by this vector data. this subtree should be updated according to the values in the vecter.
    public void valueChanged(TreeSelectionEvent e) {
    //code here
    subtreecreat();
    //some function that create tree after cheching the some condition here
    subtreecreat() {
    Enumeration en=vector.elements();
    while(en.hasMoreElements())
    DefaultMutableTreeNode servername = new DefaultMutableTreeNode(en.nextElement());
    node.add(servername);
    Please help it is very urgent
    Thanks in Advance,
    anum

    Well, you can either use a custom TreeModel that tracks your Vector, or you can use a DefaultTreeModel and call model.reload(node) to refresh the tree below the specified node.

  • Set default value with mouse click?

    Hi guys,
    I'm new enough to LabVIEW, and indeed this forum, so I hope you can help. I'm guessing it's a simple problem, but I can't figure out how to do it.
    I've got a cRIO taking in 4 analog voltages. Each voltage is from a linear potentiometer which is measuring suspension displacment on a Formula Student race car.
    I have a simple formula set up to convert input voltage to displacment. I've set up a table of inputs which allows me to set maximum, minimum,(from previous sensor calibration) and "stationary" value of each sensor.
    The "stationary" value is what the sensor should be reading when the car is stopped. This is then used as a baseline for either positive or negative displacments.
    My problem is that each time a different driver gets in the car, the susspension is adjusted, or fuel is added, the "stationary" value will be different. I then have to manually set the stationary value back to whatever the current value is when the car is stopped, press "make current value default", and save the VI before continuing.
    What I would like, is a "calibrate" button which I can press that sets the "stationary" value to whatever the current input voltage is. This way, I wouldn't have to reset 4 values each time the car is modified.
    If you have any ideas on how to do this, please let me know.
    I'll attach my VI once I get back to the laptop where it is saved!
    Thanks,
    Kevin Irving
    Solved!
    Go to Solution.

    Kevin,
    As you have discovered you cannot change the default values on a running VI.
    The best way to do what you want is to use a configuration file.  There is a set of VIs specifically designed for that purpose on the File I/O palette.  When the user presses the "calibrate" button, the values are saved to the file. When the program starts it reads the file and sets the controls to the values in the file.  You can even keep different sets for each driver, if the data is consistent enough.
    Read the detailed help files for the configuration VIs and look at the examples.  These will show you how to get started.
    Lynn

  • :system.cursor_block value does not change when mouse click

    Form created with Forms version 6.0.8.8.0. Consists of a control block that has the toolbar buttons, a filter control block that contains item, and a data block. The filter control block and data block are on a tabbed canvas. There are 3 tabs with corresponding filter control block and data block on each.After the data block is queried, code sets the navigation to the control block with the go_item built-in. The user would use a mouse click on the filter control block on one of the tabs to activate an LOV, code is in a generic when-mouse-click trigger that will determine the item focus with the value in the system variable :system.cursor_block. Works for the first tab. Does not work for 2nd or 3rd tab. On-error trigger does not capture any error. Values for :system.cursor_block for tab 1 show that value before mouse click is 'control.detail' and after mouse click is 'filter.a'. For tabs 2 and 3 the value before mouse lick is 'control.detail' and after mouse click is 'control.detail' instead of 'fiter.b' or 'filter.c'. Verified that the 3 filter blocks are identical. Can anyone shed some light on this anomoly? I have been looking for this solution (many different iterations and changes to trap it) for too long.

    :System.Cursor_Block reports the name of a block, NOT a BlockName.ItemName.
    Use :System.Trigger_Item with your mouse click, or :System.Cursor_Item.

  • Looking up the values in a waveform graph with a mouse click

    Hi,
    Does anyone know how to look up the values in a waveform graph with a mouse
    click but... without the cursor legend on, if i press in the waveform graph
    nothing happens, i must search my cursors and only then i can see the values
    of my signal data?! Isn't there any other way?
    Best regards,
    Thijs Boerée

    Dear Chad,
    I know of the function "bring cursor to center". I also figured out that
    when i use a property node of the cursor array of clusters, that i can see
    that some values change when i move the cursor (i can see the X and Y scale
    value change of the graph and also the values of the mouse pointer (in
    points due to screen resolution)) But in this cluster i can't set the mouse
    position. I allready made a VI where i can see the bounds of my
    waveformgraph and I have the Xscale (min and max) and the Yscale (min and
    max), with a linear fit i can translate my mouse position to X an Y scale
    values and when i click on my waveform graph the cursor go's to that
    position (property node of the cursor position), only disadvantage is that i
    only have the bounds of my plot area and not the position, i do have the
    position of my waveform graph but the plot area isn't allways in the center,
    if i could extract the position of the plot area i may find a solution to
    solve this problem.
    And to file a product question:
    I would like to see the function that with a mouse click a little menu
    appears and that there are options to for example set a marker on that data
    and when you right click on it, that there are options to remove it or to
    add comment, a 2D array could make a list of the different channels with
    it's markers (time stamps and comments).
    Best regards,
    And thank you for your help.
    Thijs Boer�e
    "Chad AE" schreef in bericht
    news:[email protected]...
    > Dear Thijs,
    >
    > Thank you for contacting National Instruments.
    >
    > To address your question, there is no direct VI, command, or property
    > node that will allow the cursor snap-to-mouse functionality.
    >
    > I notice a problem you may be occuring is trying to find where the
    > cursor is on the graph. If this is an issue, you can select Bring to
    > Center from the Formatting Ring on the Cursor Legend to move the
    > cursor to the center of the graph.
    >
    > Let me know if you have any further questions or if this does not
    > resolve your issue, as I would be happy to file a product suggestion
    > so that LabVIEW is improved in future versions.
    >
    > Thanks again and have a great day!
    >
    > Chad AE
    > Applications Engineer - National Instruments

  • Distinguishing b/t two single mouse-click and mouse-double-click

    Hi,
    I am curious to find out how Forms will distinguish between two single when-mouse-click events and a single when-mouse-doubleclick event. Is it simply a timing issue or is there more involved i.e. the 'co-ordinates' of the mouse. Thanks in advance for any opinions given,
    regards,
    Kevin.

    The difference is same as the difference of Apple and Orange.
    Its depends on O/S and event management within OS kernel.
    You can change the timing in Control panel of mouse double click.

  • Disable a double mouse click...

    Can anyone show me how to disable a double left mouse click.

    just add a mouselistener to the component you want to stop it, and this will trap the mouse clicks for you.
    the api docs describe the listener more fully http://java.sun.com/j2se/1.4/docs/api/java/awt/event/MouseListener.html

  • Double Mouse Click

    Good afternoon, I'm an Adobe Captivate's user and I need some
    informations about the object "Click Box". When we use the option
    "Duble Mouse Click", here in my job, it's not working. Does it need
    another configuration to function? I need some aid. Thanks,
    Caroline Reis.

    I'm seeing the same issue.  I've put in a bug report for it.  Someone suggested that it happens with AS3, and that may be the case, since it only happens sometimes for me, but always in Captivate 5, which only has AS3.
    To clarify - it expects a double click (a single click doesn't work), but when you double click, the slide moves ahead, but the second click registers as an error on the next slide, and brings up the failure caption.
    This link suggests the source of the problem.
    http://www.charglerode.com/blog/?p=54

  • How do I Get the value from a mouse click - on a waveform graph?

    If I have made a plot into a Waveform Graph and later want to do a zoom of my data
    (Not zoom into the Waveform Graph, but regenerate the data). How do I read the mouse
    coordinate if I click on the graph window. I know how to put up the horiz and vert
    cursors but don't know how to just read the mouse click. I would really like to
    follow the windows standard that identifys a rectangle by clicking and draging and then
    be able to read the corners of the rectangle. Thanks, Rick
    PS: Using Labview 6i

    I would recommend to 'translate' your graph in a picture and dislay it in a picture control (see picture examples in LV6).
    Once you did it, pictures have an extremely useful property called Mouse that returns the mouse coordinates and click events when you place the cursor on the picture.
    By this you can re-arrange the graph on picture appearance.
    There are also other methods such as using a Window's API that returns the mouse position referred to the whole screen window, but I believe this would be much more difficult to implement.
    Let me know if this was clear and if you need an example vi.
    Good luck,
    Alberto

  • A script that captures the coordinates of the mouse clicks and saves them into a file

    Hello,
    I'm trying to create a cartoon taking a movie (I've chosen blade runner) as base. I've got the real movie and I've exported all the pictures using VirtualDUB. Now I have a lot of images to modify. I would like to modify the actors faces with the faces generated by Facegen modeller. I'm thinking how to make the whole process automatic because I have a lot of images to manage. I've chosen to use Automate BPA,because it seems the best for this matter. I'm a newbie,so this is my first attempt using Adobe Photoshop and Automate BPA. I wrote a little script. It takes a face generated with Facegen modeller and tries to put it above the original actors faces. But it doesn't work very good and I'm not really satisfied,because the process is not fully automated. To save some time I need to write a script that captures the coordinates of the mouse when I click over the faces and that saves them into a file,so that Automate BPA can read these coordinates from that file and can put the face generated with Facegen Modeller above the original face. I think that Automate BPA is not good for this matter. I think that two coordinates are enough,X and Y. They can be the coordinates of the nose,because it is always in the middle of every face. It is relevant to knows how big should be the layer of the new face,too. This is the Automate BPA code that I wrote :
    <AMVARIABLE NAME="nome_foto" TYPE="TEXT"></AMVARIABLE>
    <AMVARIABLE NAME="estensione_foto" TYPE="TEXT"></AMVARIABLE>
    <AMSET VARIABLENAME="nome_foto">br</AMSET>
    <AMSET VARIABLENAME="estensione_foto">.jpeg</AMSET>
    <AMVARIABLE NAME="numero_foto" TYPE="NUMBER"></AMVARIABLE>
    <AMVARIABLE NAME="coord_x" TYPE="NUMBER"></AMVARIABLE>
    <AMVARIABLE NAME="coord_y" TYPE="NUMBER"></AMVARIABLE>
    <AMWINDOWMINIMIZE WINDOWTITLE="Aggiungere_layer - AutoMate BPA Agent
    Task Builder" />
    <AMWINDOWMINIMIZE WINDOWTITLE="AutoMate BPA Server Management Console
    - localhost (Administrator)" AM_ONERROR="CONTINUE" />
    <AMENDPROCESS PROCESS="E:\Programmi_\Adobe Photoshop
    CS5\Photoshop.exe" AM_ONERROR="CONTINUE" />
    <AMRUN FILE="%&quot;E:\Programmi_\Adobe Photoshop CS5\Photoshop.exe&quot;%" />
    <AMPAUSE ACTION="waitfor" SCALAR="15" />
    <AMSENDKEY>{CTRL}o</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="1" />
    <AMINPUTBOX RESULTVARIABLE="numero_foto">Inserire numero FOTO di
    partenza -1</AMINPUTBOX>
    <AMINCREMENTVARIABLE RESULTVARIABLE="numero_foto" />
    <AMPAUSE ACTION="waitfor" SCALAR="1" />
    <AMMOUSEMOVEOBJECT WINDOWTITLE="Apri" OBJECTNAME="%nome_foto &amp;
    numero_foto &amp; estensione_foto%" OBJECTCLASS="SysListView32"
    OBJECTTYPE="ListItem" CHECKOBJECTNAME="YES" CHECKOBJECTCLASS="YES"
    CHECKOBJECTTYPE="YES" />
    <AMMOUSECLICK CLICK="double" />
    <AMPAUSE ACTION="waitfor" SCALAR="10" />
    <AMSENDKEY>{CTRL}+</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="20" />
    <AMSENDKEY>l</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="429" MOVEY="281" RELATIVETO="screen" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="659" MOVEY="281" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="659" MOVEY="546" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="429" MOVEY="546" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="429" MOVEY="281" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMSENDKEY>v</AMSENDKEY>
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK CLICK="hold_down" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="131" MOVEY="99" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSEMOVE MOVEX="99" MOVEY="162" RELATIVETO="screen" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMMOUSECLICK CLICK="release" />
    <AMPAUSE ACTION="waitfor" SCALAR="2" />
    <AMINPUTBOX RESULTVARIABLE="coord_x">Inserire coordinata X</AMINPUTBOX>
    <AMINPUTBOX RESULTVARIABLE="coord_y">Inserire coordinata Y</AMINPUTBOX>
    <AMMOUSEMOVE MOVEX="200" MOVEY="200" RELATIVETO="screen" />
    <AMMOUSECLICK CLICK="hold_down" />
    <AMMOUSEMOVE MOVEX="%coord_x%" MOVEY="%coord_y%" RELATIVETO="position" />
    <AMMOUSECLICK />
    and this is a short video to explain better what I want to do :
    http://www.flickr.com/photos/26687972@N03/5331705934/
    In the last scene of the video you will see the script asking to input the X and the Y coordinates of the nose. This request is time consuming. For this reason I want to write a script that captures automatically the coordinates of the mouse clicks. The only thing to do should be click over the nose and the script should make the rest. As "c.pfaffenbichler" suggested here : http://forums.adobe.com/thread/775219, I could explore 3 ways :
    1) use the Color Sampler Tool’s input with a conventional Photoshop Script.
    2) use After Effects would provide a better solution.
    3) Photoshop’s Animation Panel might also offer some easier way as it might be possible to load two movies (or one movie and one image) and animate the one with the rendered head in relation to the other.
    Since I'm a totally newbie in graphic and animation,could you help me to explore these ways ? Thanks for your cooperation.

    These are the coordinates of the contours of the face that you see on the picture. Can you explain to me how they are calculated ? The coordinates of the first colums are intuitive,but I'm not able to understand how are calculated the coordinates of the second one.
    Thanks.
    1 COL     2 COL (how are calculated these values ?)
    307.5000 182.0000 m
    312.5000 192.0000 l
    321.5000 194.0000 l
    330.5000 193.0000 l
    335.0000 187.0000 l
    337.0000 180.5000 l
    340.0000 174.0000 l
    338.5000 165.5000 l
    336.0000 159.0000 l
    331.5000 153.0000 l
    324.5000 150.0000 l
    317.0000 154.0000 l
    312.5000 161.0000 l
    309.0000 173.0000 l
    307.5000 182.0000 l
    Message was edited by: LaoMar

  • Mouse clicking amd Dragging

    Hi, I have the following code so far, and when run in conjunction with other classes it creates a carousel feature.
    When you click and hold on the carousel and drag up or down, the carousel moves in the relevant direction.
    I am trying to change this click and drag, so instead when you click one of the polygons (which represent up and down arrows), the carousel moves up or down depending on which you click.
    Can anyone help with this?!
    Thanks very much!
    class ScheduleBarCanvas extends Canvas implements MouseListener,
    MouseMotionListener, ActionListener
    * CONSTANTS *
    /** Width of a slot, in pixels. */
    static final int SLOT_WIDTH = 2;
    /** Width of an entire day schedule bar, in pixels. */
    static final int BAR_WIDTH = Slot.SLOTS_PER_DAY * SLOT_WIDTH;
    /** Half of the height of a day schedule bar, in pixels. */
    static final int BAR_HALF_HEIGHT = 20;
    /** The width of an hour within a day schedule bar, in pixels. */
    static final double HOUR_WIDTH = BAR_WIDTH / 24;
    * The schedule day bars are represented as a rotatable 'wheel'. This value
    * defines the 'angle' allocated to a single day bar.
    private static final float DEGREES_PER_DAY_BAR = 10;
    * For convenience, this value represents the number of day bars that occupy
    * a 90-degree 'slice' of the schedule wheel.
    private static final int DAY_BARS_PER_90_DEGREES = (int) 9;
    * The maximum number of day bars that can be represented in the wheel.
    private static final int MAX_BARS = 9*2-1;
    * FIELDS *
    * Popup menu to use for right click menu. The right click menu allows users
    * to perform actions such as changing the climate for a selected period of
    * time.
    private final JPopupMenu rightClickMenu = new JPopupMenu();
    * Determines whether 'paste day schedule' is an available option in the
    * right click menu. 'Paste day schedule' should remain unavailable until
    * the user has copied a day schedule bar.
    private boolean allowPaste = false;
    * When the user has chosen to copy a day schedule, it will be stored here.
    private DaySchedule copiedDaySchedule;
    * A day schedule with the default period allocations.
    private final DaySchedule defaultDaySchedule;
    /** X coordinate of the left end of the schedule bars. */
    private int barLeftX;
    /** Y coordinate of centre of schedule bar display. */
    private int centreY;
    /** Width of canvas, pixels. */
    private int width;
    /** Height of canvas, pixels. */
    private int height;
    /** X coordinate of last mouse click. */
    private int lastMouseClickPositionX = 0;
    /** Y coordinate of last mouse click. */
    private int lastMouseClickPositionY = 0;
    /** X coordinate of last right mouse button click. */
    private int lastRightClickPositionX = 0;
    /** Y coordinate of last right mouse button click. */
    private int lastRightClickPositionY = 0;
    /** Start time of last selected period. */
    private Slot periodStartTime = new Slot(0);
    /** End time of last selected period. */
    private Slot periodEndTime = new Slot(0);
    /** Last-pressed mouse button. */
    private int pressedButton;
    * While clicking and dragging to modify the end time of a period, this
    * field stores the 'old' end time of the period.
    private int currentPeriodEnd;
    * While clicking and dragging to modify the end time of a period, this
    * field stores the width of the current period. At other times, this field
    * has the value 0.
    private int currentPeriodWidth = 0;
    * Rather than directly manipulating the window's canvas, a buffer is used.
    * All updates to the display are computed 'out of sight', by writing to
    * this buffer's Graphics object (see 'graphicsBuffer') and then copied to
    * the canvas in one go.
    private Image imageBuffer;
    private Image imageBuffer2;
    /** Graphics object buffer to use when updating the display. */
    private Graphics graphicsBuffer;
    private double animationSpeed = 0;
    private double simTimeInc;
    private double simTime = 0; // simulated time, HOURS from start
    /** Collection of days */
    private Schedule schedule;
    * The set of day schedule bars visible on screen at present. As the user
    * scrolls through different days, schedule bars will come in and out of
    * sight, and hence will enter and leave this array.
    private DayBar[] visibleScheduleBars;
    /** Stores the available schedulables */
    private List<Schedulable> palette;
    private int barZeroDay;
    /** Currently highlighted period - not currently used */
    private Period selection;
    /** Previously highlighted selection - not currently used */
    private Period oldSelection; // button 3 selections
    private Period dayDrag; // button 1 drag region
    private DaySchedule daySched; // schedule affected by drag
    * When clicking and dragging to change the duration of a Period, this value
    * is used to store the number of the slot being dragged.
    * If this is a new Period, and hence no prior boundary existed, this value
    * will be -1.
    private int draggedSlotBoundary;
    * When you right click on a Period, the system fills this value with the
    * number of the first slot in that Period. For instance, if 13:00 to 16:00
    * is set to 'away', and you right click at 14:40 (or any other slot inside
    * the 'away' Period), then this value will be set to the index of the slot
    * 13:00.
    private int firstSlotNumber;
    * When you right click on a Period, the system fills this value with the
    * number of the last slot in that Period. For instance, if 13:00 to 16:00
    * is set to 'away', and you right click at 14:40 (or any other slot inside
    * the 'away' Period), then this value will be set to the index of the slot
    * 16:00.
    private int lastSlotNumber;
    private DaySchedule selectedDaySchedule;
    private boolean createPeriods = true;
    * CONSTRUCTORS *
    * Setting various schedules that can be displayed
    * Initialises the display of the scheduler
    * Setting right click menu
    ScheduleBarCanvas()
    int delay = 0; // milliseconds
    int period = 40; // milliseconds
    final double updateFreq = 1000.0 / period; // H
    visibleScheduleBars = new DayBar[20];
    palette = new ArrayList<Schedulable>();
    palette.add(new Schedulable(new Color(50, 50, 220))); // away
    palette.add(new Schedulable(new Color(100, 180, 160))); // sleep
    palette.add(new Schedulable(new Color(150, 150, 120))); // busy
    palette.add(new Schedulable(new Color(200, 100, 20))); // relax
    defaultDaySchedule = new DaySchedule(palette);
    schedule = new Schedule(palette);
    Timer timer = new Timer();
    // Inner class construction for a java.util.Timer object with a
    // defined TimerTask to run processes. See the java.util library
    // in the Java API for details. Also refer to other java utility
    // assistance classes which may be useful to you in the future.
    timer.schedule(new TimerTask()
    public void run()
    simTimeInc = getAnimationSpeed() / (updateFreq * 200.0);
    if (simTimeInc > 0.0)
    { // Advance simulation time at
    simTime += simTimeInc; // current rate
    repaint(); // then update the display ASAP.
    }, delay, period); // schedule's init delay & repeat-call period
    JMenuItem menuItem1 = new JMenuItem(
    "Set climate to 'Away'", new ImageIcon("away.png")),
    menuItem2 = new JMenuItem(
    "Set climate to 'Sleeping'", new ImageIcon("sleep.png")),
    menuItem3 = new JMenuItem(
    "Set climate to 'Relaxing'", new ImageIcon("relax.png")),
    menuItem4 = new JMenuItem(
    "Set climate to 'Busy'", new ImageIcon("busy.png")),
    menuItem5 = new JMenuItem(
    "Reset day schedule", new ImageIcon("refresh.png")),
    menuItem6 = new JMenuItem(
    "Copy day schedule", new ImageIcon("copy.png"));
    menuItem1.addActionListener(this);
    menuItem2.addActionListener(this);
    menuItem3.addActionListener(this);
    menuItem4.addActionListener(this);
    menuItem5.addActionListener(this);
    menuItem6.addActionListener(this);
    rightClickMenu.add(menuItem2);
    rightClickMenu.add(menuItem4);
    rightClickMenu.add(menuItem1);
    rightClickMenu.add(menuItem3);
    rightClickMenu.add(menuItem5);
    rightClickMenu.add(menuItem6);
    addMouseListener(this);
    addMouseMotionListener(this);
    * GRAPHICS METHODS *
    * Updates the GUI.
    * @param g graphics object to draw to.
    public void update(Graphics g)
    // NB: repaint() above automatically calls update(Graphics g) ASAP.
    paint(g);
    * Updates the display.
    * @param g canvas to draw on.
    public void paint(Graphics g)
    float carouselRadius = 100; // Carousel radius in pixels
    float degreesPerPixel = (float) (57.29 / carouselRadius);
    if (currentPeriodWidth != 0)
    simTime += currentPeriodWidth * (degreesPerPixel / DEGREES_PER_DAY_BAR) * 24;
    currentPeriodEnd += currentPeriodWidth;
    currentPeriodWidth = 0;
    barZeroDay = (int) simTime / 24; // treat 1 sim sec as 1 hour
    int maxDayNo = barZeroDay + MAX_BARS;
    if (barZeroDay < 0 || maxDayNo >= Schedule.N_SCHEDULES)
    return; // invalid day number; do nothing
    Dimension dim = getSize();
    int maxX = dim.width - 1, maxY = dim.height - 1;
    barLeftX = maxX / 7;
    centreY = maxY / 2;
    if (width != dim.width || height != dim.height)
    width = dim.width;
    height = dim.height;
    imageBuffer = createImage(width, height);
    graphicsBuffer = imageBuffer.getGraphics();
    graphicsBuffer.clearRect(0, 0, width, height);
    graphicsBuffer.setColor(new Color(0, 0, 0));
    int hour = (int) simTime - barZeroDay * 24;
    float dayZeroOffsetAngle = (float) (((hour - 12) / 24.0) * DEGREES_PER_DAY_BAR);
    for (int barNo = 0; barNo <= MAX_BARS; barNo++)
    int dayNo = barZeroDay + barNo;
    int daysEarlier = DAY_BARS_PER_90_DEGREES - barNo;
    float dayAngle = daysEarlier * DEGREES_PER_DAY_BAR
    + dayZeroOffsetAngle;
    float z = carouselRadius * (float) Math.cos(0);
    float y = carouselRadius * (float) Math.sin(dayAngle / 57.3);
    float x = z / 20;
    DayBar dayBar = new DayBar(dayNo, schedule.getDaySchedule(dayNo),
    graphicsBuffer, barLeftX, centreY, x, y);
    visibleScheduleBars[barNo] = dayBar;
    for (int barNo = 0; barNo <= MAX_BARS; barNo++)
    visibleScheduleBars[barNo].paintBar(oldSelection, selection);
    g.drawImage(imageBuffer, 20, 0, null);
    g.setColor(Color.WHITE);
    g.drawRect(40,25,375,50);
    g.fillRect(40,25,375,50);
    g.drawRect(40,205,375,65);
    g.fillRect(40,205,375,65);
    Point bigArrowPoint1 = new Point(0,0);
    Point bigArrowPoint2 = new Point(0,0);
    Point bigArrowPoint3 = new Point(0,0);
    Point smallArrowPoint1 = new Point(0,0);
    Point smallArrowPoint2 = new Point(0,0);
    Point smallArrowPoint3 = new Point(0,0);
    bigArrowPoint1 = new Point(100,100); //top left
    bigArrowPoint2 = new Point(100,100); //middle right
    bigArrowPoint3 = new Point(100,100); //bottom left
    smallArrowPoint1 = new Point(100,100); //top left
    smallArrowPoint2 = new Point(100,100); //middle right
    smallArrowPoint3 = new Point(100,100); //bottom left
    Polygon bigArrow = new Polygon();
    bigArrow.addPoint(bigArrowPoint1.x+310,bigArrowPoint1.y-25);
    bigArrow.addPoint(bigArrowPoint2.x+320,bigArrowPoint2.y-25);
    bigArrow.addPoint(bigArrowPoint3.x+315,bigArrowPoint3.y-30);
    Polygon smallArrow = new Polygon();
    smallArrow.addPoint(smallArrowPoint1.x+310,smallArrowPoint1.y+105);
    smallArrow.addPoint(smallArrowPoint2.x+320,smallArrowPoint2.y+105);
    smallArrow.addPoint(smallArrowPoint3.x+315,smallArrowPoint3.y+110);
    g.setColor(Color.black);
    g.fillPolygon(bigArrow);
    g.drawPolygon(bigArrow);
    g.setColor(Color.black);
    g.fillPolygon(smallArrow);
    g.drawPolygon(smallArrow);
    addMouseListener(this);
    addMouseMotionListener(this);
    * Sets a new percentage value for the animation speed of the application.
    * @param animationSpeed desired animation speed.
    void setAnimationSpeed(double animationSpeed)
    this.animationSpeed = animationSpeed;
    * Returns the current speed of the animation, as a percentage.
    * @return the current speed of the animation, as a percentage.
    private double getAnimationSpeed()
    return animationSpeed;
    * Finds and returns a slot based upon the specified mouse position
    * coordinates.
    * @param x x coordinate of selection, relative to centre-left of schedule
    * bar display.
    * @param y y coordinate of selection, relative to centre-left of schedule
    * bar display.
    * @return a Slot value corresponding to the selected slot if available. If
    * no slot was selected, null is returned.
    private Slot findSlot(int x, int y)
    int barNumber = findDayBarNumber(x, y);
    if (barNumber == -1)
    return null;
    int foo = (x - (int) visibleScheduleBars[barNumber].getLeftAngleX());
    int bar = (barNumber * Slot.SLOTS_PER_DAY + foo / SLOT_WIDTH);
    return new Slot(bar + barZeroDay * Slot.SLOTS_PER_DAY);
    * Finds the day bar specified by the provided mouse coordinates, and then
    * returns its number.
    * @param x x coordinate of mouse position.
    * @param y y coordinate of mouse position.
    * @return the number of the day bar, or -1 if no day bar was found at the
    * specified mouse coordinates.
    private int findDayBarNumber(int x, int y)
    for (int barNo = MAX_BARS - 1; barNo >= 0; barNo--)
    DayBar dayBar = visibleScheduleBars[barNo];
    if (x >= dayBar.getLeftAngleX() && x <= dayBar.getBarRightAngleX()
    && y >= dayBar.getBarBottomAngleY()
    && y <= dayBar.getBarTopAngleY())
    return barNo;
    return -1;
    * EVENT HANDLER METHODS *
    * This event handler is unused.
    * @param evt ignored.
    public void mouseClicked(MouseEvent evt)
    * This event handler is unused.
    * @param evt ignored.
    public void mouseExited(MouseEvent evt)
    * This event handler is unused.
    * @param evt ignored.
    public void mouseEntered(MouseEvent evt)
    * This event handler is unused.
    * @param evt ignored.
    public void mouseMoved(MouseEvent evt)
    * Called when the mouse button is released.
    * 1. Displays the right click menu if the right mouse button was clicked 2.
    * Updates 'last click position' fields 3. Modifies end time of current
    * selection
    * @param evt mouse event information.
    public void mouseReleased(MouseEvent evt)
    if (evt.isPopupTrigger()) // was the menu requested?
    displayRightClickMenu(evt);
    // Update 'last click position' fields
    lastMouseClickPositionX = evt.getX();
    lastMouseClickPositionY = evt.getY();
    if (pressedButton == MouseEvent.BUTTON3)
    { // selecting
    int barPositionX = lastMouseClickPositionX - barLeftX;
    int barPositionY = centreY - lastMouseClickPositionY;
    periodEndTime = findSlot(barPositionX, barPositionY);
    selection.setEnd(periodEndTime);
    * Called when mouse button is pressed. Updates slot with schedulable.
    * @param evt mouse event information.
    public void mousePressed(MouseEvent evt)
    if (evt.isPopupTrigger()) // was the menu requested?
    displayRightClickMenu(evt);
    lastMouseClickPositionX = evt.getX();
    int barPositionX = lastMouseClickPositionX - barLeftX;
    lastMouseClickPositionY = evt.getY();
    int barPositionY = centreY - lastMouseClickPositionY;
    periodStartTime = findSlot(barPositionX, barPositionY);
    if (periodStartTime == null)
    return;
    if (periodStartTime.getDayNumber() < 0
    || periodStartTime.getDayNumber() >= Schedule.N_SCHEDULES)
    return; // boundary case.
    pressedButton = evt.getButton(); // 1=left, 2=mid or wheel 3= right
    if (pressedButton == MouseEvent.BUTTON1)
    { // dragging
    // but maybe creating new selection too so...
    oldSelection = selection;
    currentPeriodEnd = barPositionY;
    currentPeriodWidth = 0;
    dayDrag = new Period(periodStartTime, periodStartTime);
    int s = periodStartTime.getSlotNumber();
    if (!createPeriods)
    return;
    daySched = schedule.getDaySchedule(periodStartTime.getDayNumber());
    draggedSlotBoundary = daySched.findNearBoundary(s, 3);
    if (draggedSlotBoundary < 0)
    if (s < 0 || s >= Slot.SLOTS_PER_DAY)
    return; // boundary case
    // Not near a boundary, so create seed slot for new
    // period
    if (daySched.getSlot(s) == palette.get(0))
    daySched.setSlot(s, palette.get(1));
    else
    daySched.setSlot(s, palette.get(0));
    draggedSlotBoundary = s;
    } else
    Schedulable SS = daySched.getSlot(draggedSlotBoundary);
    if (draggedSlotBoundary < s)
    daySched.insert(SS, draggedSlotBoundary, s);
    else
    daySched.insert(SS, s, draggedSlotBoundary);
    else if (pressedButton == MouseEvent.BUTTON3)
    { // selecting
    oldSelection = selection;
    periodStartTime = findSlot(barPositionX, barPositionY);
    selection = new Period(periodStartTime, periodStartTime);
    * Called when the mouse is moved while a button on it is held down.
    * Changes the end time of the selected Period.
    * @param evt information about the current mouse cursor state, e.g.
    * position.
    public void mouseDragged(MouseEvent evt)
    lastMouseClickPositionX = evt.getX();
    int barPositionX = lastMouseClickPositionX - barLeftX;
    lastMouseClickPositionY = evt.getY();
    int barPositionY = centreY - lastMouseClickPositionY;
    if (pressedButton == MouseEvent.BUTTON1)
    { // dragging
    Slot selectedSlot = findSlot(barPositionX, barPositionY);
    currentPeriodWidth = barPositionY - currentPeriodEnd;
    if (draggedSlotBoundary < 0 || selectedSlot == null)
    return; // out of bounds
    if (!createPeriods)
    return;
    for (int s = draggedSlotBoundary + 1; s < selectedSlot.getSlotNumber(); s++)
    daySched.setSlot(s, daySched.getSlot(draggedSlotBoundary));
    dayDrag.setEnd(selectedSlot); // or could use Selection instead
    if (pressedButton == MouseEvent.BUTTON3)
    { // selecting
    Slot selectedSlot = findSlot(barPositionX, barPositionY);
    selection.setEnd(selectedSlot);
    * Displays the right click menu.
    * @param evt information about the current mouse cursor state, e.g.
    * position.
    private void displayRightClickMenu(MouseEvent evt)
    // Calculate positions of mouse click relative to centre-left of
    // schedule bars display.
    lastRightClickPositionX = evt.getX() - barLeftX;
    lastRightClickPositionY = centreY - evt.getY();
    // identify bar to modify
    DayBar db = null;
    for (int barNo = MAX_BARS - 1; barNo >= 0; barNo--)
    DayBar currentBar = visibleScheduleBars[barNo];
    if (lastRightClickPositionX >= currentBar.getLeftAngleX()
    && lastRightClickPositionX <= currentBar.getBarRightAngleX()
    && lastRightClickPositionY >= currentBar.getBarBottomAngleY()
    && lastRightClickPositionY <= currentBar.getBarTopAngleY())
    db = currentBar;
    break;
    if (db == null)
    return;
    // identify 'selected' section/setting
    Slot t = findSlot(lastRightClickPositionX, lastRightClickPositionY);
    int slot = t.getSlotNumber();
    if (slot < 0)
    return; // out of bounds
    // find out colour of selected section
    selectedDaySchedule = db.getDaySchedule();
    Color colour = selectedDaySchedule.getSlot(slot).colour;
    // go left/back; find earliest section with this colour
    firstSlotNumber = slot;
    while (true)
    Color currentSlotColour = selectedDaySchedule
    .getSlot(firstSlotNumber).colour;
    if (!currentSlotColour.equals(colour))
    firstSlotNumber++;
    break;
    if (firstSlotNumber > 0) // lower boundary case
    firstSlotNumber--;
    else
    break;
    // go right/forwards; find latest section with this colour
    lastSlotNumber = slot;
    while (true)
    Color currentSlotColour = selectedDaySchedule
    .getSlot(lastSlotNumber).colour;
    if (!currentSlotColour.equals(colour))
    break;
    if (lastSlotNumber < Slot.SLOTS_PER_DAY - 1) // upper bound case
    lastSlotNumber++;
    else
    break;
    rightClickMenu.show(evt.getComponent(), evt.getX(), evt.getY());
    * Called when the user selects an item from the right click menu. Changes
    * the Schedulable for the selected Period to the requested value.
    * @param evt an ActionEvent, providing information about the command that
    * was selected from the menu.
    public void actionPerformed(ActionEvent evt)
    String command = evt.getActionCommand();
    if (command.equals("Copy day schedule"))
    if (!allowPaste) {
    * If the user copies a day schedule, we must enable
    * the paste option in the menu.
    JMenuItem menuItem7 = new JMenuItem("Paste day schedule",
    new ImageIcon("paste.png"));
    menuItem7.addActionListener(this);
    rightClickMenu.add(menuItem7);
    allowPaste = true; // only do this once
    int barNo = findDayBarNumber(
    lastRightClickPositionX, lastRightClickPositionY);
    DayBar db = visibleScheduleBars[barNo];
    /* It's important that we copy the day schedule by value, not by
    * reference. If we just copy a reference, then if we 'copy' a bar,
    * changing the source bar after the copy operation will change what
    * is ultimately 'pasted'.
    copiedDaySchedule = db.getDaySchedule().clone();
    else if (command.equals("Paste day schedule"))
    int barNo = findDayBarNumber(
    lastRightClickPositionX, lastRightClickPositionY);
    DayBar db = visibleScheduleBars[barNo];
    db.getDaySchedule().insert(
    copiedDaySchedule, 0, Slot.SLOTS_PER_DAY-1);
    else if (command.equals("Reset day schedule"))
    int barNo = findDayBarNumber(
    lastRightClickPositionX, lastRightClickPositionY);
    DayBar db = visibleScheduleBars[barNo];
    db.getDaySchedule().insert(
    defaultDaySchedule, 0, Slot.SLOTS_PER_DAY-1);
    else
    * Identifies which new Schedulable was requested. This Schedulable
    * will replace the selected Period's Schedulable value.
    * For instance, if "Away" was selected from the menu, then we must
    * fetch the "Away" Schedulable.
    Schedulable schedulable;
    if (evt.getActionCommand().equals("Set climate to 'Away'"))
    schedulable = palette.get(2); // the 'away' Schedulable
    else if (evt.getActionCommand().equals("Set climate to 'Sleeping'"))
    schedulable = palette.get(0); // the 'sleeping' Schedulable
    else if (evt.getActionCommand().equals("Set climate to 'Busy'"))
    schedulable = palette.get(1);
    else if (evt.getActionCommand().equals("Set climate to 'Relaxing'"))
    schedulable = palette.get(3);
    else
    // Should never occur
    throw new Error("Unrecognised command.");
    // Now fill the selected Period with the requested Schedulable.
    selectedDaySchedule.insert(
    schedulable, firstSlotNumber, lastSlotNumber);
    * User is able to edit schedule when boolean is set to true
    * @param createPeriods sets state of interaction with day schedules
    void setCreatePeriods(boolean createPeriods) {
    this.createPeriods = createPeriods;
    }

    Here is the Apple document covering Magic Mouse faults.  Symptom number 6 seems the one to check out.  Is this a longstanding or a recently developed fault?
    And, of course, is it still under the 12 month warranty.
    One thing to pay particular attention to is the proximity of electronic items such as cradles for phones and the like which if active, can interfere with the signal.
    Troubleshooting wireless mouse and keyboard issues

  • Is there a way to simulate a mouse click anywhere on a screen in Dictate ?

    I'm using Dictate because of hand problems. Unfortunately, it does not seem to have the ability as supplied to simulate mouse clicks anywhere on the screen as Dragon Naturally Speaking does on the Windows side.( I do not mean by this the ability to select an item in the menu, which It does have the built in ability to do.) It can, however, so I read, be scripted to do a lot of things. Is there an Applescript out there that would allow for the simulation of mouse clicks anywhere on the screen (as opposed to just on a UI item)?

    Platform: 2.2 gHz iMac using Mac OS X 10.5.5; Dictate v. 1.2.1 Build
    Okay, so, here, after a great deal of research, is a procedure for implementing a single mouse click anywhere on the screen. Since it’s a procedure, I’m detailing each step.
    !. Download the scripting addition (sometimes known as an OSAX) xTool.sax from: http://lestang.org/osax/XTool/XTool-2.0.dmg.tgz. You will have to decompress the file (StuffIt) and double-click it to get it to unfold into a .dmg (disk image) file. In this file you will find the file Xtool.osax. Drag it into your MacHD (or whatever the name of your topmost volume is)/library/ScriptingAdditions (no spaces in the name) folder. The purpose of this is to place it into a folder where Applescript is expecting to find scripting additions. In other words, it’s hard-coded and you can’t just drop it anywhere because Applescript may not find it. Also, there may be more than one Library folder in other directories. Under 10.5.5. which I’m running, I can tell you it works where I placed it.
    The effect all of this has is that when you create your script in Dictate’s New Commands window (Script Editor), Dictate will know what the commands “click mouse’ and “position of the mouse” mean. These are not standard Applsecript commands but are additions, hence the name Scripting Additions.
    2. Start Dictate and in the File drop-down select New Command. This will take you to a window with a pane on the left with names such as Applications, Global, and several others. Click on Global (so that the command will be recognized no matter what application your are in). To the right of the pane you will see a number of commands listed by name and, underneath, a (very small) “+” (and a minus sign and a small icon). Ignore everything but the “+”. Click on the “+”.
    Below several boxes will appear: Command, Description, Context, Type.
    In Command Name type in the name you want Dictate to recognize to do the click. (I call mine Mouse click.) In Description you can type something like Single-clciks the mouse. In the Context drop-down make sure to select Global. In the Type drop-down, select Applescript.
    Paste the following into Text Edit (orTexEdit Plus,if you have that):
    click mouse {(position of the mouse), [1]}
    For reasons unknown to me, you can’t just select that text, copy, and paste it into Dictate’s Script Editor winodw. You will have to select it in Text Edit and drag it into the Source text box.
    Click on the Compile button at the left bottom. After it finishes compiling (a matter of seconds if everything is normal), click on the Run button with your mouse. If all has gone well, you will very likely see the Run button get pressed repeatedly. Take your mouse off the button so it stops blinking like mad. (The Mouse click Appplescript is repeatedly looking at the position it find itself and clicking again, and again.)
    While your mileage may vary, I have been able to simulate single mouse-click using this workaround.
    So far, I have not been able to simulate a double-click reliably. There is, I believe, an issue with the amount of time between the two clicks (a parameter of the click mouse command above which I did not go into here). For anyone out there who wants to work on that, I would be glad to hear your results. I’ve tried values up to 2000 in the DELAY parameter after the TIMES parm. Here is what the dictionary shows for this command.
    click mouse?v
    click mouse [point] : where to do the mouse click
    [times integer] : how many times you want to clik the mouse
    [delay integer] : delay between two mouse clicks
    [using primary button/secondary button/middle button] : which mouse button
    If I get this to work I will let my fellow sufferers know.
    Thanks to Hiroto and Andrew99 in particular for their help.

  • Detecting mouse clicks in editable cell of JTable

    Hi everyone :)
    I thought that this question might have been asked before, but I have searched the forums extensively and have not been able to find the solution.
    What I want to achieve is to detect single and double mouse clicks on JTable cells (that are editable).
    For example, I have a JTable and there exists within it an editable cell. If the user clicks on it once then that cell goes into edit mode, and the user can type directly into the cell. I have already successfully implemented this.
    However, what I also want to do is detect a double-click so that I can pop up a dilaog that shows a list of default values that the user can select.
    So here is what I want;
    1. User clicks on the cell once.
    2. Cell moves into edit mode.
    3. If the user clicks again within a certain time interval then cancel edit mode and pop up a dialog containing values that the user can select from.
    I think that to do this I need to be able to detect mouse clicks on the cell that is currently being edited. So far I have been unable to discover how this is done. I have even tried extending JTextField to get what I want, but with no luck.
    Any help would be greatly appreciated.
    Kind regards,
    Ben Deany

    Thanks for the reply.
    Unfortunately, it is not possible to call 'AddMouseListener()' on a cell editor. You are only able to call 'addCellEditorListener()' and that only allows two events to the broadcast (edit cancel, and edit stop).
    Ben

Maybe you are looking for

  • Profit Centr Issue

    hi all we are working on project based scenarion, planning strtegy 21 (MTO with Project). we have following cysle. Master data creation. Prject builder creation sale order creation. linking wbs element with sale order. MRP run on Project using tcode

  • "Display driver stopped responding and has recovered" error

    Hi, I recently upgraded my laptop to Windows 8.1 and now from time to time, I am receiving the error above on the right side of the screen and my photoshop files won't open. Instead it just freezes and becomes unresponsive so I have to close Photosho

  • Nokia e 63 not working properly

    Hello team, I am facing a weried problem with my nokia e 63 .I have been using this mobile from last 4 yreas its working really fine with out causing any trouble  but suddenly 2 days back its mic stopped working and after some time it automatically s

  • KB2903939 Fails

    The KB2903939 Windows update is failing to install on our SCVMM server.  If fails with the error code: 0x80070057.  Some general searches have suggested trying: DISM.exe /Online /Cleanup-image /Scanhealth DISM.exe /Online /Cleanup-image /Restorehealt

  • Error 609, "Get Album artwork" - doesn't happen

    I haven't had problems with getting album artwork until now. I always make sure the artist and album are properly labeled and nothing else in iTunes is running. I now get error 609, where artwork won't download.