DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    3

    Cool 2D array of textfields

    I,m trying to create a application wthat as 100 textfields in the frame, but can,t get the textfields to display,
    any help appreciated
    thanks again

    import java.awt.*;import java.awt.event.*;//import javax.swing.*;public class Minefield extends Frame{ private int rows = 10; private int columns = 10; private TextField[][] tCells = new TextField[rows][columns]; private Frame f1; public Minefield( ) { f1=new Frame(); f1.setSize(350,350); f1.setLocation(100,0); f1.setTitle("MineSweeper"); for(int rowCount = 0; rowCount < rows; rowCount++) for(int columnCount = 0; columnCount < columns; columnCount++) { tCells = new TextField[rows][ columns]; tCells[rowCount][columnCount] = new TextField(); f1.add(tCells[rowCount][columnCount] ); } f1.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { dispose(); System.exit(0); } }); f1.setVisible(true); } public static void main(String args[]) { Minefield mainFrame=new Minefield(); mainFrame.setSize(300, 300); mainFrame.setTitle("Minefield"); mainFrame.setVisible(false); }}

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    Doing this isn't a problem, but can you please re-post your code properly layed out - it's impossible to read.
    ArchAngel.
    O:-)

  3. #3
    Join Date
    Dec 2003
    Posts
    3

    2D array/textfields

    Sorry about last post,
    I,ll try again

    import java.awt.*;
    import java.awt.event.*;

    public class Minefield extends Frame
    {
    private int rows = 10;
    private int columns = 10;
    private TextField[][] tCells = new TextField[rows] [columns];
    private Frame f1;

    public Minefield( )
    {
    f1=new Frame();
    f1.setSize(350,350);
    f1.setLocation(100,0); f1.setTitle("MineSweeper");

    for(int rowCount = 0; rowCount < rows; rowCount++) for(int columnCount = 0; columnCount < columns; columnCount++)
    {
    tCells = new TextField[rows][ columns];
    tCells[rowCount][columnCount] = new TextField()
    f1.add(tCells[rowCount][columnCount] );
    }
    f1.addWindowListener(new WindowAdapter()
    {
    public void windowClosing(WindowEvent we)
    {
    dispose();
    System.exit(0);
    }
    );
    f1.setVisible(true);
    }

    public static void main(String args[])
    {
    Minefield mainFrame=new Minefield();
    mainFrame.setSize(300, 300);
    mainFrame.setTitle("Minefield");
    mainFrame.setVisible(false);
    }
    }

    cheers

  4. #4
    Join Date
    Dec 2003
    Posts
    10
    Arent you suppose to have panes?

  5. #5
    Join Date
    Dec 2003
    Posts
    3
    No,
    its sorted just needed a layout manager
    don,t need panes

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links