Why sould the line be under my button?

Hi.... I'm new to java...and I'm trying to implement a TicTacToe game.
I have the following problem...I've created a JFrame and I distributed on it 9 buttons.
I'm trying to draw the winning line on to the three winning buttons after they have been disabled...
I'm testing the first case of wining that is on the first row of this "strange" matrix...but nothing to do. When I draw the line...a piece of it is under the final button :(
I post here bellow my code. If anyone could help me out I would be greatful.
Thanks in advance
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TrisFrame1 extends JFrame implements ActionListener
          JButton a = new JButton();
          JButton b = new JButton();
          JButton c = new JButton();
          JButton d = new JButton();
          JButton e = new JButton();
          JButton f = new JButton();
          JButton g = new JButton();
          JButton h = new JButton();
          JButton i = new JButton();
          static int player=1;
          String sign;
          static switchPlayer Sign = new switchPlayer();
          static TurnofPlayer Player = new TurnofPlayer();
          static winingrules r;
     public TrisFrame1 ()
          super("TrisFrame1");
          setSize(400, 400);
          ExitWindow exit = new ExitWindow();
          JPanel surface = new JPanel();
          GridLayout square = new GridLayout(3,3,20,20);
          surface.setLayout(square);
          getContentPane().add(surface);
          surface.setBackground(Color.blue);
          surface.add(a);
          surface.add(b);
          surface.add(c);
          surface.add(d);
          surface.add(e);
          surface.add(f);
          surface.add(g);
          surface.add(h);
          surface.add(i);
          a.addActionListener(this);
          b.addActionListener(this);
          c.addActionListener(this);
          d.addActionListener(this);
          e.addActionListener(this);
          f.addActionListener(this);
          g.addActionListener(this);
          h.addActionListener(this);
          i.addActionListener(this);
          setContentPane(surface);
          addWindowListener(exit);
          public static void main (String[] arguments)
          TrisFrame1 frame = new TrisFrame1();
          frame.show();
          frame.setVisible(true);
          public void actionPerformed (ActionEvent evt)
               Object clicked = evt.getSource();
               JButton genericbutton = new JButton();
               if (clicked == a)genericbutton=a;
               else if (clicked == b)genericbutton=b;
               else if (clicked == c)genericbutton=c;
               else if (clicked == d)genericbutton=d;
               else if (clicked == e)genericbutton=e;
               else if (clicked == f)genericbutton=f;
               else if (clicked == g)genericbutton=g;
               else if (clicked == h)genericbutton=h;
               else if (clicked == i)genericbutton=i;
               sign=Sign.PlayerSign(player);
               player=Player.turn(player);
               genericbutton.setText(sign);
               genericbutton.setEnabled(false);
               genericbutton.setBackground(Color.gray);
               genericbutton.setFont(new Font ("arial", Font.BOLD,40));
               wins();
     public void wins()
     if (((!a.isEnabled())&&(!b.isEnabled())&&(!c.isEnabled())) && ((a.getText()==b.getText())&&(a.getText()==c.getText())))
          System.out.println ("here I'am");
Designline();
               if (((!d.isEnabled())&&(!d.isEnabled())&&(!f.isEnabled())) && ((d.getText()==e.getText())&&(d.getText()==f.getText())))
          System.out.println ("eccomi qui");
               //Designline();
          // TBC with the controls for the wining cases
     public void Designline()
                    Graphics2D line = (Graphics2D) getGraphics();
                    line.drawLine(50,50,380,100);
          line.dispose();
class ExitWindow extends WindowAdapter {
     public void windowClosing(WindowEvent e)
          System.exit(0);
class TurnofPlayer
     int Player1;
     public TurnofPlayer()
     public int turn(int player1)
          if (player1==1)
               Player1=2;
          else Player1=1;
          return Player1;
class switchPlayer
     String playingsign;
     public switchPlayer()
     public String PlayerSign(int player1)
          if (player1==1)
               playingsign="X";
          else playingsign="O";
          return playingsign;

maybe you should disable the button as soon as the person clicks it.. I think its just a matter of the timing between when you clicked on the button, and it still having focus when you draw the line.

Similar Messages

  • Why is the add database connection plus button grayed and disabled?

    Hi,
    I'm using Dreamweaver CS5.5 with PHP on Windows 7. I can't click on the add new connection "plus" button; it's grayed out and disabled. Also, even though the first three self-checks (create a site for this file, choose a document type, and set up the site's testing server) are OK, the fourth self-check isn't there. I looked on-line and found forums saying that if you're using ASP both of those problems could occur, but I'm using PHP, not ASP. Does anyone have any clue as to how to fix this?

    Have you set the server model?
    Gramps

  • Why did the back, forward and refresh buttons stop working

    When I started the computer for first time today I opened firefox I no longer can use the back, forward or refresh buttons when visiting sites. Alaso even though I have selected firefox to open with home page it opens with a bland until I hit home button. It is acting very strange,

    See http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox

  • Why does the new "share this page" button not stay deleted?

    Two issues with the latest two releases (35.0 and the one before)...
    1. The new "share this page" button (with the paper airplane icon) reappears everytime FF is started -- even though I have removed it from the toolbar. How can I make stay gone?
    2. The new info bar at the screen bottom "FF automatically sends some data..." is always present when FF starts -- even though I have completed the "choose what I share" Option. How do I permanently remove this?

    Separate Issue;
    Your System Details shows;
    Installed Plug-ins
    Shockwave Flash 16.0 r0
    Shockwave Flash 14.0 r0
    Adobe Shockwave for Director Netscape plug-in, version 12.1.5.155
    Adobe Shockwave for Director Netscape plug-in, version 12.1.4.154
    Having more than one version of a program may cause issues.
    Grab the uninstaller from here:
    '''[http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-windows.html Uninstall Flash Player | Windows]'''
    '''[http://helpx.adobe.com/flash-player/kb/uninstall-flash-player-mac-os.html Uninstall Flash Player | Mac]'''
    Then reinstall the latest version.
    Flash Player '''v16.0.0.235 https://www.adobe.com/products/flashplayer/distribution3.html'''
    Shockwave Director '''v12.1.5.155 http://get.adobe.com/shockwave/'''
    '''https://support.mozilla.org/en-US/kb/how-to-fix-preferences-wont-save'''

  • Why is the chat option under support gone?

    Hey guys,
    I can't find the chat option under service anymore. When I go through the process describing my problem I get choices of either
    Send in for service,
    Or take in for service,
    Or contact carrier,
    Or contact Apple Support (call when you are ready)
    Do anyone know how I can use the chat option again? I think that's a very convinient way for me to communicate since my english isn't that great.
    Thank you!

    I think it only applies to certain countries.   Have you moved to a different country since you last used it.   Or do you know for sure it has been available where you live?

  • Positioning the Calendar Window under a button

    Hello,
    I wanna show that calendar under the button i've pressed. something like here (so like LOVS, they are opened under the button pressed)
    i tried with this code, in KEY-LISTVAL trigger for that text item
    declare
         pozx number:=get_item_property('btn_data',x_pos)+15;
         pozy number:=get_item_property('btn_data',y_pos)+15;
    begin
         --message(get_item_property('btn_data',x_pos));
    date_lov.get_date('01-jan-1980',         -- initial date
                      'angajati.data_nasterii',  -- return block.item
                      pozx,              -- window x position
                      pozy,              -- window y position
                      'Data nasterii',    -- window title
                      'OK',            -- ok button label
                      'Cancel',        -- cancel button label
                      TRUE,            -- highlight weekend days
                      FALSE,           -- autoconfirm selection
                      FALSE);          -- autoskip after selection
    end;     so i get the xpos and ypos of the button, and i add 15 because it's a square button of 15 px.
    however, my calendar window it's wrong displayed.. what i'm doing wrong?
    Thanks
    Edited by: Roger22 on 28.07.2009 17:57

    Hi!
    The get_item_property ( 'item', x_pos and y-Pos ) gives you the x_pos / y_pos of the position on the canvas.
    The set_window_property ( 'window', x_pos and y_pos ) sets the position on the screen.
    That is is a big difference.

  • Why do the lines in bold (unread) sit slightly offset upwards against the non-bold lines

    Since the last upgrade, unread lines in the list of messages screens are set slightly higher than unemboldened (read) lines.
    Also the To:, Cc: etc area of the compose mail screen looks kind of unfinished.
    Is this what is supposed to happen, or do I have a fonts issue.
    Thanks for your help.
    Andy M

    It's interesting that you report it happening on multiple systems. That really has me wondering why you are seeing it and yet apparently no-one else does. It's hard to see how it could be widespread and yet passing unnoticed by so many.
    When precisely was "the last upgrade"?
    What version is this? (See '''Help|About Thunderbird''')
    Which platform?
    I have zebra striping in my thread pane listing, which inserts specific spacing rules and possibly defeats that effect. Maybe yours is the default behaviour. (But I still can't see that uneven spacing here in Thunderbird's Safe mode, Windows 7, TB31.1.2).
    The first step to addressing any issue like this is identification of the steps to take to be able to reproduce it, and we don't have that yet.

  • Why is the Hand not showing over button on one level?

    I have site with multiple .swf files working on levels.  many buttons working properly - but when I get to one level - the cursor is not changing to a hand over any of the buttons.  I don't know how to trouble shoot that at all.  I am using as2 Flash player 11.
    When I test the site locally - I get the hand - when I test on the internet - I don't see the hand on this one level only.  And - I tested on a mac with an earlier operating system - I did get the hand.  What should I do?
    thanks for your help ~ Judy

    if the button responds to a mouse click then there's nothing covering them.
    the only way, i know, you can have a button respond to a click but not display the hand cursor on rollover AND have it be a flash issue is if useHandCursor was assigned to false.
    however, there are browser issues that can cause this problem and you may be able to prevent them by making sure your embedding html has wmode="window" (or, just about anything other than "transparent").

  • Why all the lines and question marks on my recovered iWeb pages?

    My iWeb recovered pages (which I did find, thanks to several of you) are covered with question marks and horizontal and < and > lines. Why would this happen and how do I know it won't happen when I publish?
    G4 Dual   Mac OS X (10.4.10)   all software updates

    is this what you see:
    http://www.geocities.com/[email protected]/images/badkidblue.jpg
    it was from this thread:
    http://discussions.apple.com/thread.jspa?messageID=2746077&#2746077
    if you see something similar as above, you may have corrupted iweb template, re-install iweb...

  • Why have the forward, back and refresh buttons stopped working in Firefox 4 Beta 10?

    Upgraded from FF4 Beta 2 to Beta 10. They were working fine in Beta 2.

    This can be a problem with the file places.sqlite that stores the bookmarks and the history.
    * http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    The shortcut key sequence to open Panorama (View > Tab Groups) has changed to Shift + Ctrl + E.

  • Why are the lines of my bulleted list flowing beyond the column boundaries?

    I have created an iBook using templates and styles. Everything looks good on my Mac. When I preview on my iPad or export to iBooks, the bullets are not indented from the left margin the same amount on the screen, and the text runs beyond the right edge of my column. How do I fix this?

    My situation is a little different.  I have a text box on the left of the page, 1 column, and a galery on the right of the page.  On the Mac, the text and gallery look fine.  But, when I preview on my ipad, some of the text at the right margin of the text box is not visible.  I have tried resizing the text box and it just causes some other text ( the last 1 or 2 letters) at the right margin to disappear.

  • Line width under 1

    I've looked through several different forums and articles about changing the width of the line to under 1 pt and have tried many different methods, such as the commas or language changing in control panel, all not working.  The odd thing about my project is that I have many different shapes on the screen and almost all of them are the correct width, only a couple are not changing and always reverts back to the 1 pt width.  Here's an image, which I hope will help.
    All of the other pieces are 0.1 pt while just these are 1 pt.

    Nevermind. I figured it out. Its just a shape tween. *kicks
    self*

  • To delete the line

    I draw a line from point A to point B (lineMove & lineTo). Am I able to delete the line by either a button or other way ?

    I am not certain on this but I think the answer is know since a line doesn't have an instance name. The only think i can think of off the top of my head would be to add an empty movieclip and add your line to the movieclip make sure you have a reference to that movieclip then if you had to delete the line you could delete the movieclip that contained the line.
    Hope this helps.
    - Adam

  • Invoicing the line irrelavant for billing

    Hi Gurus,
    We had created one text item category ZTR as an  item category which is not relavant for billing and pricing.
    There is a material with item category ZTR which is used in sales document type : CR. This material is not relavant for billing and hence this material should not be considered for invoicing.
    However, when i am trying to invoice the Credit memo request with billing type G2 ( credit memo), this item is also considered for billing and hence we are getting an error : Item 10 G2 CR ZTR not relavant for billing.
    I have a question. When i am flagging a material as not relavant for billing, why is the line considered for billing ?
    There is no copy control maintained for that item category.
    please help.
    regards,
    Krishna

    Hi Lakshmipathy,
    In the VTFA transaction , there is no copy control maintained for this item category.
    However, while creating the billing document, (since the document type is irrelavant for delivery) the item ZTR is also considered for billing.
    regards,
    Krishna

  • Why does the content spill over and how do I position this under the menu and title?

    I was following this tutorial on how to add a scrolling image gallery to a Flash website.
    (http://www.republicofcode.com/tutorials/flash/xmlimagegallery/index.php)
    From what I understand from this tutorial, it is just a matter of copying the Actionscript code and pasting it onto the timelines then making modifications on the XML.
    (kindly see a screenshot of timeline layers I made and as to where I put the Actionscript code:
    http://i429.photobucket.com/albums/qq19/tsujzpie/imagegalleryproblem_01.jpg )
    I pasted the code onto the blank keyframe labeled "Gallery"...
    But all I get is this weird effect when I click on the button for the gallery...
    (kindly see a screenshot of it here: http://i429.photobucket.com/albums/qq19/tsujzpie/imagegalleryproblem_02.jpg )
    When you put a blank keyframe on a timeline, any content put in there is supposed to only be contained in that very frame, right? How come then that - whenever the gallery button is clicked on - the content from that section spills out onto the other sections even when I click on other button for the other areas?
    I just really couldn't think why this is happening - any reason why this is so?
    And how do I position the gallery right under the section header and menu bar?
    Here is its AS2 code, by the way:
              import mx.transitions.Tween;
              import mx.transitions.easing.*;
              var myGalleryXML = new XML();
              myGalleryXML.ignoreWhite = true;
              myGalleryXML.load("gallery.xml");
              myGalleryXML.onLoad = function() {
                        _root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x;
                        _root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;
                        _root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;
                        _root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;
                        _root.myImages = myGalleryXML.firstChild.childNodes;
                        _root.myImagesTotal = myImages.length;
                        _root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;
                        _root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;
                        _root.full_x = myGalleryXML.firstChild.attributes.full_x;
                        _root.full_y = myGalleryXML.firstChild.attributes.full_y;
                        callThumbs();
                        createMask();
                        scrolling();
              function callThumbs() {
                        _root.createEmptyMovieClip("container_mc",_root.getNextHighestDepth());
                        container_mc._x = _root.gallery_x;
                        container_mc._y = _root.gallery_y;
                        var clipLoader = new MovieClipLoader();
                        var preloader = new Object();
                        clipLoader.addListener(preloader);
                        for (i=0; i<myImagesTotal; i++) {
                                  thumbURL = myImages[i].attributes.thumb_url;
                                  myThumb_mc = container_mc.createEmptyMovieClip(i,           container_mc.getNextHighestDepth());
                                  myThumb_mc._y = _root.thumb_height*i;
                                  clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);
                                  preloader.onLoadStart = function(target) {
                                            target.createTextField("my_txt",target.getNextHighestDepth          (),0,0,100,20);
                                            target.my_txt.selectable = false;
                                  preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
                                            target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
                                  preloader.onLoadComplete = function(target) {
                                            new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
                                            target.my_txt.removeTextField();
                                            target.onRelease = function() {
                                                      callFullImage(this._name);
                                            target.onRollOver = function() {
                                                      this._alpha = 50;
                                            target.onRollOut = function() {
                                                      this._alpha = 100;
              function callFullImage(myNumber) {
                        myURL = myImages[myNumber].attributes.full_url;
                        myTitle = myImages[myNumber].attributes.title;
                        _root.createEmptyMovieClip("fullImage_mc",_root.getNextHighestDepth());
                        fullImage_mc._x = _root.full_x;
                        fullImage_mc._y = _root.full_y;
                        var fullClipLoader = new MovieClipLoader();
                        var fullPreloader = new Object();
                        fullClipLoader.addListener(fullPreloader);
                        fullPreloader.onLoadStart = function(target) {
                                  target.createTextField("my_txt",fullImage_mc.getNextHighestDepth          (),0,0,200,20);
                                  target.my_txt.selectable = false;
                        fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
                                  target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
                        fullPreloader.onLoadComplete = function(target) {
                                  new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
                                  target.my_txt.text = myTitle;
                        fullClipLoader.loadClip("full_images/"+myURL,fullImage_mc);
              function createMask() {
                        _root.createEmptyMovieClip("mask_mc",_root.getNextHighestDepth());
                        mask_mc._x = _root.gallery_x;
                        mask_mc._y = _root.gallery_y;
                        mask_mc.beginFill(0x000000,100);
                        mask_mc.lineTo(_root.gallery_width,0);
                        mask_mc.lineTo(_root.gallery_width,_root.gallery_height);
                        mask_mc.lineTo(0,_root.gallery_height);
                        mask_mc.lineTo(0,0);
                        container_mc.setMask(mask_mc);
              function scrolling() {
                        _root.onEnterFrame = function() {
                                  container_mc._y += Math.cos(((mask_mc._ymouse)/mask_mc._height)          *Math.PI)*15;
                                  if (container_mc._y>mask_mc._y) {
                                            container_mc._y = mask_mc._y;
                                  if (container_mc._y<(mask_mc._y-(container_mc._height-mask_mc.          _height))) {
                                            container_mc._y = mask_mc._y-(container_mc._height-          mask_mc._height);

    You should create a manually movieclip symbol with nothing in it and take a copy of it from the library and place it in the frame where you intend for the gallery to display.  Give it an instance name of "container_mc" and remove the following line from your callThumbs function
    _root.createEmptyMovieClip("container_mc",_root.getNextHigh estDepth());
    You probably need to do the same for the mask and the full images since they appear to also be created using dynamic mc's.

Maybe you are looking for

  • Using long vs. clob datatype with Oracle 8.1.7 and interMedia

    I am trying to determine the best datatype to use for a column I wish to search using the interMedia contains() function. I am developing a 100% java application using Oracle 8.1.7 on Linux. I'd prefer to use the standard JDBC API's for PreparedState

  • How to list selected parent and child rows with values from ADF TreeTable

    I created one tree table having three levels using DepartmentsVO, EmployeesVO and JobHistoryVO where these tables contains parent and child relationship on database. Then i added one more column to the tree table which displays selectBooleanCheckBox.

  • How do I move music from an external hard drive to an ipod classic 160gb

    My computer is too old for the new itunes software.  I have my music on an external hard drive.  I have an ipod classic 160GB and need to get my music onto it. Is there a way to do this using somebody else's computer?  I have an itunes account, just

  • Minecraft not working after previous deletion.

    I had recently cleared out some space on my SSD, and Minecraft was deleted with it. I had deleted not only the .app file but also the folder under "application support." Now, upon re-downloading the .zip file and attempting to execute the .app an err

  • X11 not starting on 10.6.8

    X11 does not start (icon just bounces in the dock when directly clicked and then disappears). It sems that I have an old X11 version (1.0 according to the info panel). Error messages found in Konsole: 28.09.13 21:23:59 [0x0-0x30030].org.x.X11[410] la