Make a crossword game with 2D array of JButton??


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Make a crossword game with 2D array of JButton??

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Posts
    2

    Question Make a crossword game with 2D array of JButton??

    I'm new in java and here is what i'm trying to do:
    1. Make a crossword grid / layout with 2D array of JButton.
    2. Put number on the top left of JButton and color the JButton with black and white (maybe with paint component)
    3. Make small window that have TextField in it that show up when the white colored JButton being clicked where people can input the answer there, click the "ok" button and get the input text to show up in the JButton. if the black colored being clicked, it will show up message box that say "You can't input".
    4. Make question that show up in other window. So there will be two window, the one that show the crossowrd and the one that show the question. Or maybe the question is in the same window with the TextField. Which is the easy/simplest way..
    5. To check whether the input and the answer is same if it's true it will show message box "Your guess is right!", and the input text will show up in the JButton with black color and can't be clicked anymore. But if false, it will show message button "Your guess is wrong!", and the input text will show up in the JButton with re color and can be clicked again untill the input is the right one.

    Any help would be appreciated..,
    Thanks..

    I tried to put the number but the order of array is wrong or upside down. How to solve this??
    Code:
    final int ROWS = 12;
    
    final int COLS = 12;
    
    final static int topLeftNum[][]= {
    	{-1, 1, 0, 2, 0, 0, 3, -1, 4, 0, 5, 0},
        {6, 0, 0, 0, -1, -1, 0, -1, -1, -1, 0, -1},
        {-1, 0, -1, 0, -1, 7, 0, 0, 8, -1, 0, -1},
        {9, 0, 0, 0, 10, -1, -1, -1, 11, 0, 0, -1},
        {0, -1, -1, 12, 0, 0, 13, -1, 0, -1, -1, -1},
        {0, -1, 14, -1, 0, -1, 0, -1, 15, 0, 0, 16},
        {17, 0, 0, 18, 0, -1, 19, 20, 0, -1, -1, 0},
        {0, -1, 0, 0, -1, 21, 0, 0, 0, -1, -1, 0},
        {22, 23, 0, 0, -1, 0, -1, 0, -1,24, 0, 0},
        {-1, 0, -1, 25, 0, 0, -1, 0, -1, 0, -1, -1},
        {26, 0, 0, -1, -1, 0, -1, 27, 0, 0, 0, -1},
        {-1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, -1}
        };
     
    public Lat1() {
    
    
    this.getContentPane().setLayout(new GridLayout(ROWS, COLS));
    
    for (int j=0; j<COLS; j++) {
    	for (int i=0; i<ROWS; i++)	{
    this.getContentPane().add(new Box(i, //the boxes index
    
    (topLeftNum[j][i] < 0) ? Color.BLACK : Color.WHITE, //pick the color
    
    topLeftNum[j][i], //the topleft number
    
    (char)(65+i), //the char inside
    
    this), //the action listener for the button
    
    i); //the index to place it on the container
    
    }
    }
    
    this.pack();
    
    this.setVisible(true);
    
    }

  2. #2
    Join Date
    Aug 2009
    Posts
    2
    And user can only insert 1 character in the TextField.

Similar Threads

  1. Re: MAKE $$$$$$$$$$ FAST THIS REALLY WORKS
    By Mark Campisi in forum .NET
    Replies: 0
    Last Post: 07-14-2002, 04:05 PM
  2. Framework of a complex game...
    By AGuy in forum Java
    Replies: 0
    Last Post: 07-31-2000, 07:35 AM
  3. SafeArrayCopy SLOWER than iterating string array!
    By Mark Alexander Bertenshaw in forum VB Classic
    Replies: 10
    Last Post: 06-16-2000, 05:34 AM
  4. SafeArrayCopy SLOWER than iterating string array!
    By Mark Alexander Bertenshaw in forum VB Classic
    Replies: 0
    Last Post: 06-12-2000, 08:15 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center