TextGrids in Java (help required)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 13 of 13

Thread: TextGrids in Java (help required)

Hybrid View

  1. #1
    Join Date
    May 2005
    Posts
    22

    TextGrids in Java (help required)

    I am currently working on a project in which I need to have a textGrid displaying a series of numbers.
    I downloaded two textGrid classes that seem unable to allow me to enter text into them, or move around the grids using the keyboard.
    I asked a friend of mine who mentioned I should attempt to write my own class, but I have no idea of how to do it properly so that values display correctly.
    If anybody is able to either write me a demonstration class or explain how I could go about this endevour, it would be greatly appreciated.
    Thanks

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    what does the documentation you received with the textGrid classes say about creating an instance of textGrid or invoiking the methods of the class?

  3. #3
    Join Date
    May 2005
    Posts
    22
    That's the problem. I don't have any documentation with them
    I can get the textgrid to display in the applet, but it doesn't do what it should i.e it just shows a series of boxes according to my specifications.

    I realise that I can possibly clarify what I want better:
    I'm looking for some kind of code that will allow me to display a series to editable textareas in this fashion:
    _____________
    |6|5|3|4|4|0|4|
    |7|4|8|9|9|5|6| etc.

    I need to be able to move between the individual cells with the keyboard arrow keys and each cell can accomodate a maximum of 2 characters.

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    So it sounds that you are invoking the textGrid class and can change the rows and columns.

    Did you get the code for these classes?

    A shot in the dark - there is a method which probably takes row, column, and text or string as arguments. Something such as "writeGrid()" or "addToGrid()" - can you find a method such as this?

  5. #5
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    This could be used

    I need to be able to move between the individual cells with the keyboard arrow keys and each cell can accomodate a maximum of 2 characters.
    .. at least it covers the specs qoted, it also uses a mouselistener:
    Attached Files Attached Files
    eschew obfuscation

  6. #6
    Join Date
    May 2005
    Posts
    22
    Thanks a lot sjalle, this class is just what I need.
    I have one or two problems that I can't quite figure out though.

    How do I specify the number of rows and columns, is it in a method that I missed somewhere?
    And how would I interface the textgrid with a non-applet program? I can't seem to get it to display in a frame or pane. The pane.add() method doesn't seem to take effect.
    Also, do the different cells have coordinates that can be displayed and used as variables when the individual cells are accessed?


    Again, thanks a lot.
    Last edited by cirrus; 05-23-2005 at 03:17 PM.

  7. #7
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    No, do not mix awt & swing components. Rename all components in my source to
    J<name> components (JApplet, JFrame), and change to the
    <name>.getContentPane().add(<component>)
    way of adding components , - where it is required.
    eschew obfuscation

  8. #8
    Join Date
    May 2005
    Posts
    22
    Ah, right. Should've seen that.
    Been fiddling with class and it works perfectly.
    thanks a lot!

  9. #9
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    Dynamic grid

    This version uses arrowkeys + CTRL to add/remove rows/columns in the
    textGrid
    Attached Files Attached Files
    eschew obfuscation

  10. #10
    Join Date
    May 2005
    Posts
    22
    Thanks a lot for all your help!

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