Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Scrabble GUI

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Scrabble GUI

      public class Cell extends JPanel {
        // Indicate the row and column of this cell in the board
        private int row;
        private int column;
     
        // initial used for this cell
        private char initial= ' ';
     
        public Cell(int row, int column) {
          this.row = row;
          this.column = column;
          setBorder(new LineBorder(Color.BLACK,1));
          setOpaque(false);
     
        }


    Sorry, if it was posted before ,coz I dunno what i am looking for. Thanks in advance.
    Last edited by davidpi; May 15th, 2011 at 01:15 PM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,483
    My Mood
    Hungover
    Thanks
    144
    Thanked 642 Times in 548 Posts

    Default Re: Scrabble GUI

    I would probably extend JPanel and override paintComponent() to draw the board, then use a MouseListener to detect mouse movement, dragging, and releases. There are other ways to go about this, but that's how I would do it.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Scrabble GUI

    EDIT : I meant the mouseListener part concerning the elaboration.
    Last edited by davidpi; May 15th, 2011 at 01:16 PM.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,483
    My Mood
    Hungover
    Thanks
    144
    Thanked 642 Times in 548 Posts

    Default Re: Scrabble GUI

    Let's see, I have an example of extending JPanel and overriding paintComponent to paint a grid, then using a MouseListener to detect mouse events around here somewhere...

    Ah, here it is: (Kevin's) Conway's Game of Life

    You can download the source and check it out if you want.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Scrabble GUI

    what u mean by using MouseListener is that i use it to find where did the mouse drop the tile and then get the info of the tile?
    Last edited by davidpi; May 15th, 2011 at 01:17 PM.

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,483
    My Mood
    Hungover
    Thanks
    144
    Thanked 642 Times in 548 Posts

    Default Re: Scrabble GUI

    Yep. I use a MouseListener in my code, or you can read through the tutorial: How to Write a Mouse Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Junior Member
    Join Date
    Apr 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Scrabble GUI

    Okay thanks alot for ur help, I will play with it and figure it out =)