How do I add a mouseEvent to an area

does anyone know how i add a mouseEvent to an area?
i want to test the response of the user to hit a Graphic on the screen
but i dont know how to make the Graphic so that it can be hit.
Simple enough problem just im a bit dim. lol
THanks for any help that would be offered,
Brain

You could add a mouse listener to the whole panel (or whatever container you're using) and then test each mouse click to see if it's within the area you're looking for.
The getPoint() method of MouseEvent will tell you where the event occurred. If the graphic is rectangular, you can use the contains(Point p) method to see if the event occurred inside that region.

Similar Messages

  • How do i add a an editable text area along with a basic shape?

    hiee
    Thank u guys for replying to my previous query.I got the solution.
    Now ,my problem is, whenever i am drawing a new shape on the panel i want to add an editable text area along with the shape so that the shape can be given a userdefined name(something like Rational Ross).
    I am using g.drawString() but with that i can only add a static string.
    How can i add a JTextField or JTextArea along with the shape??
    Thanking u guys in advance.
    anvesha.

    It is considered standard procedure to acknowledge people's replies in the corresponding thread.
    As for your current problem, you'll have to make sure that the component you're subclassing is at least a Container. A JPanel could be a good pick. Set the layoutManager to null. Add your JTextField to your JPanel and use myTextField.setBounds(x, y, width, height) to place it whereever you want.

  • How do you add/use typekit fonts that are not edge web fonts?

    I am just trying out the new Muse CC 2014.1 (August) release and was keen to try the new font facilities.  As far as I can see that while I can now add other fonts for which I have downloaded web font files via the Self Hosted Web Fonts function, Typekit fonts that are not "Adobe Edge Web Fonts" are effectively unavailable?  Have I missed something.
    As an example I want to use the Proxima Nova web font family.  I have selected it on the type kit site, set them up to Sync via my Creative Cloud account.  So for example if I select a font in Photoshop CC or Illustrator, the Proxima Nova fonts appear. Even ok in Word for Mac.  They do not appear in Muse.
    To add them as self hosted web fonts, I would need to physically download the relevant fonts files and install them on my desktop using the OS-X font tool.  However as they are being sync'd via Creative Cloud this shouldn't be necessary should it?  Also I don't see an option for doing so on the typekit site.
    Any help or guidance would be very welcome.
    PS:  I seem to have a separate issue with the Creative Cloud app, which is not listing fonts under the Assets tab.  But I don't think that is related as they are working fine for Photoshop, etc.

    Hi David,
    I'm sorry that you ran into trouble with this. To add fonts from Typekit to your Muse website, you will want to use the web fonts path instead of desktop fonts.  (You can use a desktop font synced from Typekit in your Muse design, but it will exported as an image the same as any other system font.)
    There are a couple options for using Typekit web fonts in Muse:
    o) The Muse Insider wrote a post on how to insert the Typekit embed code from the Muse interface:
    http://museinsider.com/how-to-add-typekit-fonts-to-your-muse-site.html
    o) Or you can add the embed code to the Page Properties dialog within Muse, which will include it in the <head> of the page when you export your website. The steps are the same as this tutorial, but you will add the Typekit embed code to Muse instead of into your page directly:
    TYPEKIT | Adding fonts to your site
    Note that in either case the Typekit fonts will not be displayed in the Muse preview window. You'll need to publish your site to a server in order for the Typekit fonts to be loaded into the page.
    If those look like more coding that you are comfortable with, you might try one of the fonts which you can select from the font menu instead. Here are some that are similar to :
    https://edgewebfonts.adobe.com/fonts#/?xHeight=high&contrast=low&class=sans-serif&width=re gular
    We are also working on a more complete integration of Typekit with Muse in the future, but I can't say yet when that will be available.
    >> PS:  I seem to have a separate issue with the Creative Cloud app, which is not listing fonts under the Assets tab.  But I don't think that is related as they are working fine for Photoshop, etc.
    Do you see a "loading" icon in the tab (e.g. a blue spinner wheel)?  It sounds similar to this thread; you might try these suggestions:
    Re: Adobe Creative Cloud / Desktop App / Home Screen: Constant Spinning Wheel
    I hope that this helps; let me know if you have any other questions.  Best,
    -- liz

  • How do I add all my iPhoto pictures to iTunes

    How do I add all the photos that are in iPhoto to iTunes so all will sync on my iPad.
    I have many more photos showing up on iPhoto and they do not appear in iTunes when I sync my iPhone 4GS or my iPad? any suggestions

    You do not put photos in itunes.  itunes is not a photo management program.
    The manual explains how to sync pics to the ipad.
    Open itunes, connect ipad, go to photos tab, sleect what you want to sync, sync.

  • Add colors to the value area in a XY chart

    Hi,
    I want to present values in an XY Chart with Xcelsius Std 4.5. The chart is divided in 4 equal zones, so the values fall in one zone (red: critical, green: good, etc)
    Does somebody know how can I add different colors to the area of the chart?
    When I add colored rectangle with transparency: if it's in the "back" I dont see it, if it is in the "front" I see the symbols of the values quite bad because they are behind the transparency...
    Any idea out there?
    Thanks in advance

    You are on the right track with the use of colored rectangles. You will need to open the XY Chart, open the Appearance tab, and uncheck the Show Background box in the Chart Area and uncheck the Show Fill box in the Plot Area. This will enable the colored rectangle(s) to be seen through the XY Chart. You may need to adjust other settings or add elements to achieve the desired aesthetic.

  • How do i add the same mouselistener to many different instantiated objects?

    This is for a card game.
    The deck class instantiates 52 cards from the card class.
    The game has a deck of cards. I am dealing each player their cards, the player is to be dealt 8 cards each of which should have a mouselistener.
    How do I add the same mouselistener to each of the cards dealt.
    This is how I have it so far but it only adds a mouselistener to the last card dealt.
         public void dealPlayerACard()
              taken = availableCards.dealCard();
              taken.showCard();
              taken.addMouseListener(this);
         public void mouseClicked(MouseEvent MEvent)
              playerHand.remove(taken);
              paintHand(playerHand);
              playerHand.repaint();
    Any help would be appreciated

    Yeh I have 52 card object in the deck. Theyre not individually named, they were instantiated in the deck class.
    standardDeck.add(new Card(a, b, new ImageIcon(str), cardBack)); //creating and then adding the cards
    So i draw one card at a time, and I had a mouselistener to that particular card. But the thing is, When the cards are clicked, some checking happens and if the move is legal, the card is added back into the deck and its mouselistener should be removed. This is because that card could then be added to the computers hand, and I dont want no player using the computer players cards.
    The game deals the cards to players, players use the cards and then send them to the bottom of the deck, the deck is shuffled and then the game continues until a condition is met by either of the players.
    So i dont understand how a loop solution would work here. My mind is blank at the moment, maybe im not understanding properly. I am new to java. So if you do know the answer, please tell it to me. Please dont wait for a lightbulb to appear above my head. ;)

  • Hi I would like to know, how do I add a Hyperlink on Flash, that opens a PDF in adobe reader and not the web browser.

    Hi I would like to know, how do I add a Hyperlink on Flash, that opens a PDF in adobe reader and not the web browser.

    Yoh, what is FSCCommanr ? sorry man I am an absolute beginner in Flash. I tried the code:
    /* Click to Go to Web Page
    Clicking on the specified symbol instance loads the URL in a new browser window.
    Instructions:
    1. Replace http://www.adobe.com with the desired URL address.
       Keep the quotation marks ("").
    instance_name_here.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage);
    function fl_ClickToGoToWebPage(event:MouseEvent):void {
      navigateToURL(new URLRequest("http://www.adobe.com"), "_blank");
    this is the same code I used before and it opens a pdf file in a web browser, and it doesn't open an AutoCAD file.

  • How can i add new jcomponent to a frame?

    hi.
    how can we add new component to a frame? look at this code. Why when i click on button, nothing added to frame? event handled correctly and frame size changes but no button adds to frame.
    private void convertButtonMouseClicked(java.awt.event.MouseEvent evt) {
    // TODO add your handling code here:
    JButton newButton = new JButton("new");
    getContentPane().add(newButton , BorderLayout.CENTER);
    newButton.setVisible(true);
    setSize(500, 500);
    }

    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.
    Well typically you wouldn't add a button to the Center of a BorderLayout. If you really want to do this you should be using a [Card Layout|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html].
    In general the code for adding/removing components should be:
    panel.add(...)
    panel.revalidate();
    panel.repaint();

  • How can I add the listener to the CellRenderer

    My class named NoteColumnRenderer extends DefaultTableCellRenderer
    and thhe getTableCellRendererComponent() returns JButton .
    My question is how can I add MouseMotionListener to the JButton
    or how can I add MouseMotionListener to the NoteColumnRenderer ?
    The code below,and there is no effect
    public class NoteColumnRenderer extends DefaultTableCellRenderer {
    public NoteColumnRenderer(boolean multiSelection) {
    super();
    System.out.println("b="+this.getListeners(MouseMotionListener.class).length);
    this.addMouseMotionListener(new MouseMotionListener(){
    public void mouseDragged(MouseEvent e) {
    System.out.println("mouse+++++++");
    public void mouseMoved(MouseEvent e) {
    System.out.println("mouse-------");
    m_button.addMouseMotionListener(new MouseMotionListener(){
    public void mouseDragged(MouseEvent e) {
    // TODO Auto-generated method stub
    System.out.println("mouse=====");
    public void mouseMoved(MouseEvent e) {
    // TODO Auto-generated method stub
    System.out.println("mouse=======");
    System.out.println("a="+this.getListeners(MouseMotionListener.class).length);
    m_multiSelection = multiSelection;
    if (m_multiSelection) {
         m_check = new JCheckBox();
    m_check.setMargin(new Insets(0, 0, 0, 0));
    m_check.setHorizontalAlignment(JLabel.CENTER);
              } else
    m_button.setMargin(new Insets(0, 0, 0, 0));
    m_button.setSize(new Dimension(5, 5));
    m_combobox = new JComboBox();
         } // IDColumnRenderer
         /** Mult-Selection flag */
         private boolean m_multiSelection;
         /** The Single-Selection renderer */
         private JButton m_button=new JButton();
         /* The Multi-Selection renderer */
         private JCheckBox m_check;
         private JComboBox m_combobox;
         protected void setValue(Object value) {
              if (m_multiSelection) {
                   boolean sel = false;
                   if (value == null)
         else if (value instanceof Boolean)
              sel = ((Boolean) value).booleanValue();
                   else
              sel = value.toString().equals("Y");
                   m_check.setSelected(sel);
              else
                   if (value == null)
                   else
         if(value.toString().length()>10)
    m_button.setText(value.toString().substring(0,10)+"...");
                        else
                             m_button.setText(value.toString());
                        m_button.setBackground(Color.WHITE);
         public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
              setValue(value);
              if (m_multiSelection)
                   return m_check;
              else
                   return m_button;
    }

    Listener can be added to a cell editor, not cell renderer.
    Set relevent cess(s) to setEditable == true when you use your custom cell editor.

  • How can mc_instance listen for MouseEvent?

    hello;
    my_mc_instance.addEventListener( MouseEvent.MOUSE_DOWN ,
    a_function ) ;
    I do not understand why my_mc_instance even knows what a
    mouseevent is; for instance, I have to know what a "knock on the
    door" is before I can listen for it;
    movieclips DO NOT inherit from: Mouse or MouseEvent or even
    Event;
    movieclips inherit from:
    MovieClip --> Sprite --> DisplayObjectContainer -->
    InteractiveObject --> DisplayObject --> EventDispatcher
    --> Object
    so how do they even know what a MouseEvent is?
    it would seem to me that trying to add a mouseevent listener
    to my_mc_instance would never fire since movieclips do not inherit
    any mouse-related stuff;
    furthermore, according to MovieClip.as, MovieClip class
    already has methods that are apparently firing for the mouseevents:
    ActionScript Code:
    function onMouseDown():Void;
    function onMouseMove():Void;
    function onMouseUp():Void;
    function onPress():Void;
    function onRelease():Void;
    function onReleaseOutside():Void;
    function onRollOut():Void;
    function onRollOver():Void; ...
    which makes me wonder why it is even necessary to add
    mouse-related listeners to an mc;
    any thoughts?
    thanks
    dsdsdsdsd

    Hey,
    The reason movie clips dispatch mouse events is because movie
    clips inherit from InteractiveObject. All InteractiveObjects
    dispatch mouse events, so naturally, movie clips dispatch mouse
    events.
    For an object to be able to dispatch events, it doesn't have
    to inherit from the specific event class (MouseEvent class), just
    another class that dispatches those events (InteractiveObject).
    The script you included contains methods from AS2. You can't
    use them in AS3, so the only way to trigger anything with the mouse
    is to add event listeners.

  • How do I add URI web link with custom tooltip like "CLICK HERE TO UPDATE" instead of URI web link in tooltip.

    How do I add URI web link with custom tooltip like "CLICK HERE TO UPDATE" instead of URI web link in tooltip.

    You've probably found an answer to this by now, but I think this has been addressed in another forum -- The link below suggested using a button and adding the tooltip to the button. 
    https://forums.adobe.com/thread/304974?start=0&tstart=0
    Sounds like it would work but I haven't actually tried it. 
    Good luck~!

  • How do i add type kit fonts to muse web site

    how do I +add type kit fonts to muse website

    Hi.
    Check this video, might be helpful
    Let me know if you have any questions

  • How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    How can I add more than one same spry menu (eg. collapsible menu)  with in different styles (font size, color, background, etc) on current page?

    Hi Nancy,
    This screenshot was only for imagination. A part of the code (not all) is below.  In the code there are some background images but they are not seem in live mode.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="css/my_site.css" rel="stylesheet" type="text/css" />
    <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css"/>
    <link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
    <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
    <style>
    #CollapsiblePanel1 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-color: #003366;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel1 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel1 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/international.jpg);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel2 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel2 .CollapsiblePanelContent {
        background-color: blue;
    #CollapsiblePanel3 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel3 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel3 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel4 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel4 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        font-size: 18px;
        line-height: 52px;
        color: #FFF;
    #CollapsiblePanel5 .CollapsiblePanelTabHover .CollapsiblePanelTab {
        background-color: #003366;
        color: #FFF;
        text-shadow: 1px 1px #000;
        font-weight: bold;
        background-image: url(images/TR_Col-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    #CollapsiblePanel5 .CollapsiblePanelClosed .CollapsiblePanelTab  {
        background-color: #C3CFDF;
        border-radius: 5px 5px 0px 0px;
        color: #999
        text-shadow: 1px 1px #000;
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
        font-size: 18px;
        font-weight: bold;
        background-image: url(images/TR_Gray2-WEB.png);
        background-repeat: no-repeat;
        line-height: 52px;
    </style>

  • How do I add multiple apple id's to one account

    How do I add multiple Apple id's to one account for billing and Icloud use?

    You don't. You can't combine Apple IDs.

  • HT201342 How can I add an e-mail address to my existing icloud addresses?  I currently only use one and I would like to ad two more?

    How can I add an e-mail address to my existing icloud account?  I curently only use one of the three.

    Each iCloud account only has a single iCloud account.  If you want, you can add up to 3 alias addresses that will receive email in the same iCloud inbox, as explained here: http://support.apple.com/kb/PH2622.

Maybe you are looking for

  • Strange behaviour in alv output display for a date column!

    hi friends, my alv output list display contains a column for budat (posting date), if this field has no value, then it displays a blank cell (space) in the output in my user login...but when the same report is run in another user login, even though t

  • Setup F110 as an automatic nightly batch job

    Hello Gurus, Can anyone please tell me how do I set up the F110 payment batch job as an automatic nightly batch job. I tried doing it in sm36 but I dont think so it would work because i was not able to create the parameters

  • How do I add fold marks in inDesign?

    I have created a tri-fold brochure and am now stuck as I can't remember how to add fold lines which will be outside of the print area but that the printer will see (when the document is exported as a PDF)? I am using CS4 - if that makes any differenc

  • WLC 5508: LAG with not stacked switches

    Hello! We are planning to implement the redundant physical connection from 5508 WLC to not stacked 3750 switches. The sheme is attached. Is there any way to implement such variant of the topology?

  • Convert checked exception into unchecked exception

    Hi friends I am little confused, When deciding on checked exceptions vs. unchecked exceptions. I went through the net. they are telling that Use checked exceptions when the client code can take some useful recovery action based on information in exce