JPanels are not reading Mouse Events

I created a basic Tic Tac Toe game, with individual "TicPanel"s inside a JPanel inside a JFrame object, however, none of the mouse events are working? Is it because the JFrame is receiving and doing nothing with the MouseEvents?
    private class TicPanel extends JPanel implements MouseListener
        private int owner; //-1 = none, 0 = O, 1 = X
        private Graphics g;
        private int num;
        ActionListener listener;
         * Constructor
        public TicPanel(int num)
            this.num = num;
            g = getGraphics();
            owner = -1;
        public void setX()
            owner = 1;
            g.drawLine(0,0,getWidth(),getHeight());
        public void setO()
            owner = 0;
            g.drawOval(0,0,getWidth(),getHeight());
        public int getOwner()
            return owner;
        public void mousePressed(MouseEvent evt){}
        public void mouseReleased(MouseEvent evt){}
        public void mouseExited(MouseEvent evt){}
        public void mouseEntered(MouseEvent evt){}
        public void mouseClicked(MouseEvent evt)
            System.out.println("works");
            listener.actionPerformed(new ActionEvent(this, num, ""));
            setX();
        public void addActionListener(ActionListener listener)
            this.listener = listener;
    }   Edited by: TheWhiteLynx on Aug 10, 2009 2:16 PM

TheWhiteLynx wrote:
I created a basic Tic Tac Toe game, with individual "TicPanel"s inside a JPanel inside a JFrame object, however, none of the mouse events are working? Is it because the JFrame is receiving and doing nothing with the MouseEvents?I don't see anywhere that you are adding a MouseListener to anything. Usually this is done with the addMouseListener(...) method.
Oh, and please read the Sun graphics tutorial as this is not the way to do graphics in Swing. You do not want to get the Graphics object via getGraphics method but instead do your painting in a paintComponent override method and get your Graphics object from the parameter passed to this method. The tutorials will explain all.
Edited by: Encephalopathic on Aug 10, 2009 2:29 PM

Similar Messages

  • I want to identify those photos which are not included in events so I can process them

    I want to identify those photos which are not included in the Events folder so I can begin to process these photo which remain

    Sorry but your post makes no sense
    Please identify the versions of iPhoto and of the OS that yu have and exactly what yoru problem is
    There are no photos in iPhoto that are not in an event - iPhoto works on a library basis and every photo in the iPhoto library is visible in an event and in photos view - there are no photos that are not in both
    If you are seing something different then either you are looking in the incorrect place or you have a corrupted database - but to help you you need to provide details and symptons
    Your example is simply not possible
    Lets say I have 100 pictures in my iPhoto program but only two Events.  In one Event, I have 20 pictures.  In the other Event, I have 30 pictures.
    All 100 photos are in an event and all 100 photos will show in photos view
    LN

  • Cookies are not read

    Dear sirs,
    I develop a web-site which uses cookies. A captcha and log-in state of the site depend on cookies. For unknown reasons the cookies are not read programmatically now by the site. Using an add-on, I see that cookies are being written, but not read. Everything worked just before I updated FF to 35.0
    I tested my site in major browser, everything works fine in IE, Safari, Opera, Opera Mobile and MS Page Inspector. But in FF and Chrome cookies are not read.
    If you want me to email you my cookies.sqlite, I can do it, it is just around 1MB. Thanks.

    Does document.cookie show these cookies if you paste this command in the command line in the Web Console (Firefox/Tools > Web Developer)?
    You can enable the Storage tab in the Web Console by clicking the toolbar settings (gear) icon and use the storage inspector to check what cookies are created.
    *https://developer.mozilla.org/Tools/Tools_Toolbox#Settings
    You can check in the Web Console if there are (JavaScript) error messages about this issue.
    You can remove all data stored in Firefox from a specific domain via "Forget About This Site" in the right-click context menu of an history entry ("History > Show All History" or "View > Sidebar > History") or via the about:permissions page.
    Using "Forget About This Site" will remove all data stored in Firefox from that domain like bookmarks, cookies, passwords, cache, history, and exceptions, so be cautious and if you have a password or other data from that domain that you do not want to lose then make sure to backup this data or make a note.
    You can't recover from this 'forget' unless you have a backup of the involved files.
    It doesn't have any lasting effect, so if you revisit such a 'forgotten' website then data from that website will be saved once again.

  • RichEditableText with embedded images does not handle mouse events reliably

    I'm using Flash Builder "Burrito".  downloaded a couple of weeks ago.  Flash Player 10.1.85.3 debug version.
    I have the following MXML object:
    <s:Scroller
    width="100%" height="100%"
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx"
    skinClass="components.skins.SxScrollerSkin"
    >
    <s:Group id="myGroup" width="100%" height="100%">
    <s:RichEditableText id="myRichText" >
    </s:RichEditableText>
    <!--- Do not set the height of the RichEditableText - since it seems to prevent the appearance of the vertical scroll bars -->
    </s:Group>
    </s:Scroller>
    With the following Actionscript to initialize, etc.
                textContainer = new SxBorderContainer(name);
                textContainer.dx = dxAvailable;
                textContainer.dy = dyAvailable;
    scroller = new SxScroller();
    scroller.move(dxPadding,dyPadding);
    scroller.dx = dxAvailable
    scroller.dy = dyAvailable;
    textContainer.addElement(scroller);
    var richText:RichEditableText;
    richText = scroller.richText;
    richText.toolTip = toolTip;
    richText.enabled = true; // required for mouse click capture
    richText.selectable = true; // required for mouse click capture
    richText.width = dxAvailable
         var textFlow:TextFlow = TextFlowUtil.importFromString(textFlowString, WhiteSpaceCollapse.PRESERVE);
          richText.textFlow = textFlow;
    And the following code to catch events:
                    richText.addEventListener(FlowElementMouseEvent.MOUSE_DOWN,userMouseEvent);
                    richText.addEventListener(FlowElementMouseEvent.MOUSE_UP,userMouseEvent);
                    richText.addEventListener(FlowElementMouseEvent.CLICK,userMouseEvent);
    Here's the problem.   If I have embedded images in the TextFlow that is imported into the richText, I only catch "some" mouse clicks.  It's hard to know, but it seems that only mouse clicks into white space (between paragraphs) are caught.  Mouse up and down are caught, but not "click".  Very puzzling.
    TextFlow like this:
        <TextFlow>
          <div color="#442222" fontFamily="Times New Roman" fontSize="20" paragraphSpaceAfter="15" textIndent="15">
            <p>
              <span>
                Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do:  once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, `and what is the use of a book,' thought Alice `without pictures or conversation?'
              </span>
            </p>
            <p>
                  <span>So she was considering in her own mind</span>
                  <img source="assets/library/alice/images/White Rabbit.png" height="auto" width="auto" float="left" />
                   <span> (as well as she could, for the hot day made her feel very sleepy and stupid), whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a White Rabbit with pink eyes ran close by her.</span>
            </p>
    If there are no embedded imags, I get all clicks exactly.
    Is it a bug?  Am I missing something? 
    Thanks,
    Oz

    Thanks for the answer. First I need clicks anywhere in the RichEditableText (no links or images). I use the selection manager to find the exact word that was clicked.
    The next step would be to capture clicks on links and images.
    I have tried using MouseEvent and had the same result (or worse) as FlowElementMouseEvent.  I will go back and retest with your suggestion.
    Oz
    Result of retest:
    I catch clicks only over images embedded in the TextFlow.  I catch only mouse up/down over text - both MouseEvent and FlowElementMouseEvent.
    Puzzling.  Where are the clicks going?

  • Not receiving mouse events

    In my ActionScript code I am adding mouse event handlers for a Canvas object (actually a subclass I wrote).  When I move the mouse over a child DisplayObject that was added to the Canvas, I receive all of the appropriate event handlers.  However, when I move the mouse over an area where there are no children, the events stop getting dispatched to my code.  I am verifying this using traces.  I do receive a mouse out and mouse over events, and I also receive a single mouse move event immediately prior to receiving the mouse over/out events, but nothing further.
    Does anybody know why the mouse events would stop when the mouse is directly on top of the Canvas object and not over any children?

    In my ActionScript code I am adding mouse event handlers for a Canvas object (actually a subclass I wrote).  When I move the mouse over a child DisplayObject that was added to the Canvas, I receive all of the appropriate event handlers.  However, when I move the mouse over an area where there are no children, the events stop getting dispatched to my code.  I am verifying this using traces.  I do receive a mouse out and mouse over events, and I also receive a single mouse move event immediately prior to receiving the mouse over/out events, but nothing further.
    Does anybody know why the mouse events would stop when the mouse is directly on top of the Canvas object and not over any children?

  • JLayeredPane not recieving mouse Events.

    When I try to add a MouseListener to a JLayeredPane, it does not pick up the mouse events at all. Or when I even try to add it to the only JPanel I added to the LayeredPane, still no mouse events. I never set the glassPane to visible, so I have no idea why the mouse events aren't going through.

    Your code won't compile. For one the layered constructor is within your MouseAdapter anonymous class. You are far better off posting compilable code here.
    edit: also, you are not overriding MouseAdapter methods. That would help get your code to work.
    Try compiling with an @Override annotation to see what I mean:
      private MouseAdapter exitListener = new MouseAdapter()
        @Override
        public void MousePressed(MouseEvent e) // does this compile?  MousePressed != mousePressed
          System.out.print("yrs");
      }capitalization matters:
    MousePressed != mousePressed
    Edited by: Encephalopathic on May 9, 2009 3:02 PM

  • How can I find photos that are not in any event?

    Help!  I have finally, after a decade or so, organized my events and emptied out the trash and gotten rid of duplicates. Round of applause, please.  How can I find out if there are sneaky pictures that are NOT in any particular event (please dont say by showing all photos and just going through each one!)

    You can't because every photo is in an Event already. That's how iPhoto works. Every photo is in the LIbrary. The Library is built upon events. SO if it's in iPhoto, it's in the Library and in an Event.
    Albums are different, as they refernce photos in the LIbrary. It;s perfectly possilbe to have a photo in the Library but not in an album.

  • LR4 metadata changes are not read in Bridge CS5

    I am saving the metadata in LR4 (as I normally do with LR3) and not all the adjustments are registering in Bridge CS5 or Adobe Camera RAW. 
    The develop panels (i.e. tone, presence) in LR4 have obviously changed and don't exactly match the current Adobe Camera RAW adjustment panel and so I am noticing that all the topmost develop tools such as Tone (Exposure, Contrast, Highlights, Shadows, Whites, Blacks) and Presence (clarity, vibrance, saturation) are not registering/landing in Bridge.
    Anyone else having this problem?

    I found this answer helpful: http://forums.adobe.com/message/4248629#4248629

  • Enhanced purchased cd's are not read.

    I have noticed that whenever I buy a cd that is enhanced it will never play. For example, the new Cursive cd is "enhanced with MP3 files from various saddle creek recording artists" and it cannot be read. Every time I insert the disc into my .mac, it is not read and it will not eject. Is anyone sure of what is going on and how I could possibly fix it so I can import it?

    Mac OS: Cannot Eject Copy Protected Audio Disc, Computer Starts Up to Gray Screen
    The above article explains what's going on here. Unfortunately, enhanced CDs behave in much the same way as many copy controlled discs.

  • Some of my photos are not displayed in events. The event is there and still named but photos won't display. Suggestions?

    Some of my photos are suddenly not showing inside the event. The event is still present as well as the title and number of photos in the event, but the photo is not showing. I get a black thumbnail with a dashed white box inside it. Any suggestions? It has not happened in all events, only a handful.
    Thanks

    That's an indication that the link/file path to the original file has been broken.  Make a temporary, backup copy (if you don't already have a backup copy) of the library and apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Select the options identified in the screenshot. 
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.

  • Problem with TextLine not getting mouse events when expected

    Hi All,
    I am cross-posting the discussion I put on the TLF forum here (sample code is in that post)
    http://forums.adobe.com/message/3768763#3768763
    The issue is to do with non/slow response when clicking to edit multiple TLF text elements on a base group. Thanks to some extra work by Jin-Huang the problem is apparently that when the edit functionality is set (by setting the interactionManager), the TLF class cannot receive any more events until the mouse leaves and re-enters the TextLine you are supposed to be editing. This sounds like a Flex bug.
    I guess my questions are (1) is this actually a Flex bug? and (2) does anyone know a workaround so the thing can start accepting input immediately without further mouse actions?
    Thanks,
    Darryl.

    What happens if you use two RichEditableText controls or two TextAreas
    instead?  By trying to install your own editing controls, you might have to
    fully conform to the IFocusManagerComponent interface for focusable
    components otherwise you might run into issues like this.

  • Jar files are not read from HDD

    Hi,
    we are facing a problem while trying to read jar files from Hard disk using CVM. we could able to read the file and the number of bytes read exactely matches with the file size. but while trying to use JNI (*env)->FindClass it is returns 0. Some times it returns an error "inflateFully: ZIP_Read". however we could able to read a small jar file which is of 2 kb and display some graphics. is it the problem with size?? our application is 80kb.Can some one help us in fixing this.
    Profile: PBP/CDC
    Note:
    Sam

    Step 6 makes your third party jars available during runtime on your server since you put the dependency to runtime. I don't think you need/can reference your j2ee server dc in the portalapp.xml.
    Summary of the link I sent you:
    1. Create an External Library DC
    2. Copy all of the Jars I needed to the libraries folder of this DC
    3. Create two Public Parts (right click on the jar files in Package Explorer)
          i) compilePart (with purpose compilation)
          ii) assemblyPart (with purpose assembly)
    4 Create a new DC of type J2EE Server Component / Library
    5. Add a Used DC to the J2EE Library, reference the compilePart from previous step, and set Dependency type to Build
    6. Add another Used DC, reference the assemblePart, this time select both Build and Runtime Dependency Types
    7. Build and deploy.
    Br
    Göran

  • Photos are not displayed in events/faces/photos but do when magnified

    I just reinstalled my OS from 10.6 back to 10.5 (software compatibility). When I imported my iphoto library which I had backed up, everything imported, but I cannot see any of the pictures unless I double-click to magnify. I can see the white dashed outline of where the pictures are supposed to be in the events and photos folders, all of the names appear in faces, etc. but I just can't actually view a photo unless I magnify it. Any ideas?

    I just talked to apple support on the phone. They suggested rebuilding the thumbnails, like TD suggested. When I told the support guy that that method did not work, he said that the only other option was to build a new library and import the originals.
    I was told to find the iPhoto library in the Users...>Pictures folder, right click on it and select Show Package Contents, then move the Originals and Modified (edited pictures) folders to the desktop. The iPhoto library can then be moved to the trash. When launching iPhoto, it asks what library to use. Select Create New... and the default name and location are iPhoto Library in the Pictures folder. Click save, then go to File>Import to library and select the Originals and Modified folders from the desktop. Any pictures that have been modified are still in their original form in the Originals folder. Both versions (original and modified) of a picture will be imported if both folders are selected for import.
    Unfortunately, slideshows, books, folders, etc. could not be saved in my case, but the most important thing is that the pictures are still there.
    Hope this helps anybody else with the same problem!
    Barrett

  • Pdfs are not reading correctly

    I use indesign and illustrator CS6 and when I write a pdf my client says its showing up as funky black and white and not color. Is there something wrong with my software?

    Also, how are you creating the PDF. I am assuming it is from ID that has included graphics from Illustrator, but did you use the Illustrator tools or print to the Adobe PDF printer (the Acrobat tool)? What options did you select on the creation tool?

  • Referenced files in Aperture 3 are not reading from new hard drive.

    I just merged one libary into another library on my machine in Aperture 3. Everything seemed to work fine with that. Many of the images in the new large library are referenced images. I had many of them initially referenced onto external drives. I'm not consolidating into one larger drive (with a back up too of course). I copied the files onto the larger drive from the individual external drives. I plugged in the new external drive with all of the photos on it and when I went to locate referenced images in Aperture, I found them, however many times the "reconnect" or "reconnect all" buttons are greyed out when I choose the photo. It's not letting me reconnect the images and they do have the same file names.
    I have no idea what to think or do. I don't want to have to plug in all of the old drives to get to the pictures. I want everything on one drive to access my large aperture library that is now all in one place as well.
    Please help!
    Thanks!

    aperture 3
    I meant the full version number:
    With permissions I meant the following:
    You need to have read & write permissions to the files to be able to reconnect the files. To check the permissions, select an original image filein the Finder and press the key combination ⌘I to launch the "Info" panel. In the Info panel disclose the "Sharing&Permissions" brick.
    Check if you have Read&Write access to all your image files, also to the folders containing them. If there is a permissions problem, change the permissions to "Read&Write". It would help to set the "Ignore Ownership on this Volume" flag. You'll find this flag in the "Info" panel for your external drive.
    But the safest way really to solve this would be to let Aperture relocate the files to your new drive and not to move them manually. Connect the original drives with your original master image files and move the masters by using Aperture's command "Relocate original file". Then their would be no need to reconnect.

Maybe you are looking for