This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Cell limitation in AWT grid - JDK1.4.2_02 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Cell limitation in AWT grid - JDK1.4.2_02" Watch "Cell limitation in AWT grid - JDK1.4.2_02" New topic
Author

Cell limitation in AWT grid - JDK1.4.2_02

Wiz Kid
Greenhorn

Joined: Aug 05, 2004
Posts: 1
Hi,

I would like to have unlimited number of cells in one of my grid application. I am using JDK 1.4.2_02 and I provide number of rows and columns. If number of rows and columns has less number it works fine. If rows X columns > 4996 it fails and throws the exception (Exception and Java example are given below). Pls help in solving this problem.

For reference pls find below sample program

import java.awt.*;


public class GridExample
{
public static void main(String[] args)
{
int row = Integer.parseInt(args[0]);
int column = Integer.parseInt(args[1]);
Panel mainPanel = new Panel();
mainPanel.setLayout(new GridLayout(row,column));
Frame frame = new Frame("Test");
for(int i=0;i<row;i++) {
for(int j=0;j<column;j++){
Cell cell = new Cell("This is "+row+"th row and "+column+"th column");
mainPanel.add(cell);
}
}
mainPanel.validate();
frame.setLayout(null);
frame.add(mainPanel);
frame.setSize(500,300);
frame.show();
System.out.println("Hello World!");
}
}

class Cell extends Panel
{
Label label;
public Cell(String name) {
label = new Label(name);
this.setLayout(null);
this.add(label);
this.setSize(20,100);
}
}

Exception arg[0] - Rows = 5 and args[1] - columns = 1250
---------

java.lang.NullPointerException: disposed component
at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
at sun.awt.windows.Win32SurfaceData.<init>(Win32SurfaceData.java:450)
at sun.awt.windows.Win32SurfaceData.createData(Win32SurfaceData.java:326)
at sun.awt.windows.WComponentPeer.<init>(WComponentPeer.java:510)
at sun.awt.windows.WLabelPeer.<init>(WLabelPeer.java:42)
at sun.awt.windows.WToolkit.createLabel(WToolkit.java:311)
at java.awt.Label.addNotify(Label.java:171)
at java.awt.Container.addNotify(Container.java:2049)
at java.awt.Panel.addNotify(Panel.java:71)
at java.awt.Container.addNotify(Container.java:2049)
at java.awt.Panel.addNotify(Panel.java:71)
at java.awt.Container.addNotify(Container.java:2049)
at java.awt.Window.addNotify(Window.java:418)
at java.awt.Frame.addNotify(Frame.java:482)
at java.awt.Window.show(Window.java:459)
at GridExample.main(GridExample.java:38)
 
Don't get me started about those stupid light bulbs.
 
subject: Cell limitation in AWT grid - JDK1.4.2_02
 
Similar Threads
Making co-ordinates co-operate!
Swing GUI wierdness
I'm sure I'm doing something very dumb.... why can't I see my JLabel?
converting program
label loop ontop of array