Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing table using AWT...  RSS feed

 
Ann Toh
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anybody tell me how to write a table using AWT and not Swing??
Can provide a simple codes for me so that i can understand easily??
i am using j2sdk1.4.1 and applet..

Thanx alot!!!
[ July 25, 2003: Message edited by: Ann Toh ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the short answer is that it's going to be hard. Swing has a table widget, and AWT doesn't, so you're going to have to write it from scratch.
Now, if it's a small table (no more than a hundred cells or so) you could probably get away with using a GridLayout and a bunch of Label objects. If it's larger, there's no way to do it other than to draw it onto a Canvas component, from scratch. There were, long ago, third party widget sets that did this for AWT; don't know if you could find one anymore, or one that still worked. But it might be worth searching.
Question is, if you're using 1.4.1, why not just use Swing?
 
Ann Toh
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
actually now i'm using swing but then sometimes it don't display everything. eg..when i switch to other application and when i return to the swing, some of the things are not display. so i heard from people that using awt will not have this problem and i know that awt does not have table, so can anybody give me a sample codes for writing a table??

Thank You!!
 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
call invalidate() on whatever you are adding your table to. That might fix the problem.
Thank you
Garandi
[ July 25, 2003: Message edited by: Garandi Garandi ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah... you would probably be better off fixing the update problem in your application than re-writing a Table widget in AWT... what are the specs of the computer you are running the application on? If it is really old, has a slow CPU, etc. then maybe you would be better off using AWT ( or SWT ) instead of Swing, but in most cases Swing should work fine for you. Are you doing any custom painting (i.e. overriding paint() or paintComponent() methods on any components, or using any custom renderers), or are you blocking or making complex method calls in the event thread? Either of this could cause the problem you describe, and it would be simpler to fix this problem before re-writing a table widget for AWT.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!