• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cell limitation in AWT grid - JDK1.4.2_02

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
reply
    Bookmark Topic Watch Topic
  • New Topic