-
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); }}
-
Doing this isn't a problem, but can you please re-post your code properly layed out - it's impossible to read.
ArchAngel.
O:-)
-
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
-
Arent you suppose to have panes?
-
No,
its sorted just needed a layout manager
don,t need panes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks