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)
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)