The Artima Developer Community
Sponsored Link

Java Answers Forum
creaing own awt table

11 replies on 1 page. Most recent reply: Apr 16, 2002 8:36 PM by vinod

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 11 replies on 1 page
vinod

Posts: 22
Nickname: vinod
Registered: Feb, 2002

creaing own awt table Posted: Apr 14, 2002 3:41 AM
Reply to this message Reply
Advertisement
hi dudes,

I am a lot p=of problems when i am using swing table. So i am planning to write my own awt table. Any body can help on this.


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: creaing own awt table Posted: Apr 15, 2002 12:17 AM
Reply to this message Reply
It would be simpler if you explained what your problem is ! Basically if you cannot solve some strange user requierment swith the default JTable ... I dunno what you can do better ?
(Nothing personnal though)

Thomas,

vinod

Posts: 22
Nickname: vinod
Registered: Feb, 2002

Re: creaing own awt table Posted: Apr 15, 2002 1:04 AM
Reply to this message Reply
My problem with JTable is it had got lot of repainting problems. I am not in a position to trust the status of my application. At one point of time it works cooly at other point it gives me repainting problems. That it is very slow. So i thought of making AWT Table

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: creaing own awt table Posted: Apr 15, 2002 3:45 AM
Reply to this message Reply
Could youpost a demo of your problem ?
I am very doubting about the origin of your problem !
Thomas,

nagu

Posts: 7
Nickname: nagu
Registered: Apr, 2002

Re: creaing own awt table Posted: Apr 15, 2002 5:32 AM
Reply to this message Reply
Hi vinod,

if u wanna try something new with JTABLE..there is nothing to try hard.u can get it from kgl .they have done some extensive work on it and they developed there own components..u can try for it..

This is nagendra from Hyderabad

vinod

Posts: 22
Nickname: vinod
Registered: Feb, 2002

Re: creaing own awt table Posted: Apr 15, 2002 8:43 AM
Reply to this message Reply
hi nagendra,

May i know what is kgl.

vinod

Posts: 22
Nickname: vinod
Registered: Feb, 2002

Re: creaing own awt table Posted: Apr 15, 2002 8:46 AM
Reply to this message Reply
hi thomas,

I was trying to add components in each grid. Let me make clear for u. I am working on a reporting component. In that i need to place a text field in each row of JTable. When i am running my application , i am either getting my application run slow or getting my repainting probelms. Could u suggest a solution for this.

vinod.

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: creating own awt table Posted: Apr 15, 2002 10:21 AM
Reply to this message Reply
Well
if you use John ZUKOWSKI's book & unless you really heavy bitmaps, it should not be an issue.

I'll advise you to modify the code here under with you DataMode & keep the Runnable as it should be to also update you datas & you will see that unless you have thousands of records being diplayed, it should not be a issue !

Rgds,

Thomas,

p.s. : All my example need Log4J 1.2 Beta in the Classpath to run.
package test.gui;
  
import org.apache.log4j.Category;  
import org.apache.log4j.BasicConfigurator;
                               
import javax.swing.*; 
import javax.swing.table.*; 
public class ScrollTable 
{ 
  static public Category sLog = null;
  
  public static void main(String[] args) 
  { 
    sLog = Category.getInstance (ScrollTable.class);
    BasicConfigurator.configure ();
    
    TableModel dataModel =   new TableModel ();    
    
    JTable table = new JTable(dataModel);  
    JScrollPane scrollpane = 
          new JScrollPane(table); 
    scrollpane.setHorizontalScrollBarPolicy (
          JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED ); 
    scrollpane.setVerticalScrollBarPolicy (
          JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED );
              
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 
    JFrame frame = new JFrame(); 
    frame.getContentPane ().add (scrollpane);
    frame.setDefaultCloseOperation (frame.EXIT_ON_CLOSE);
    frame.pack ();    
    frame.setSize( 300, 100); 
    frame.setVisible(true);     
  } 
 
  
  static class TableModel
    extends AbstractTableModel
  {
     int offSet = 0; 
                    
    TableModel() 
    {          
      Thread t = new Thread ( 
        new Runnable ()
        {
          int i = getOffSet();
          long startTime = System.currentTimeMillis ();
          public static final long WAIT_TIME = 100;
          public void run ()
          {
            long runTime;
            do            
            {
              runTime = System.currentTimeMillis () - startTime;
              sLog.info (" i = " + i 
                + " ( RunTime / ExpectedRunTime = " + runTime + " / " + (i*WAIT_TIME) + " )");
              try 
              {
               Thread.sleep (WAIT_TIME);
              } catch (Exception ex) 
              {
              }
              setOffSet(i++);
            } while (true);
          }
        }
                    );
        t.start();                              
    }    
    
    public int getColumnCount() 
    { 
     return 10000; 
    }  
    
    public int getRowCount() 
    { 
      return 1000;
    } 
    
    public Object getValueAt(int row, int col) 
    { 
      sLog.info ("getValueAt (row " + row + ", col "+ col + ") ");
      return new Integer(row*col+offSet); 
    }  
    
    public int setOffSet(int newOffSet) 
    { 
      offSet = newOffSet;
      fireTableDataChanged ();
      return offSet;
    }
   
    public int getOffSet() 
    { return offSet; }    
  }   // End of inner class     
} 

vinod

Posts: 22
Nickname: vinod
Registered: Feb, 2002

Re: creating own awt table Posted: Apr 15, 2002 8:35 PM
Reply to this message Reply
hi thomos,

Thank u for ur help. I will try with ur suggestion. Till now i am simply simply updating my records with out using runnable. I will modify my code and get back to u.

vinod.

vinod

Posts: 22
Nickname: vinod
Registered: Feb, 2002

Re: creating own awt table Posted: Apr 16, 2002 1:18 AM
Reply to this message Reply
hi thomas,

I got the root of my problem. Actually i am using Visual Age for Java for developing my java pplications. This tool is giving me problems. I executed ur code in the tool, it is very very slow and there are repainting problems when i resize. Then i exceuted it in normal JDK. It is working very fine. Thank u once again for ur timely help.

vinod.

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: creating own awt table Posted: Apr 16, 2002 4:47 AM
Reply to this message Reply
I would advise your boss (if possible) to use either JBuilder or any other very simple tool. I start to code on 2.x release of VAfJ & it was a real pain.
3 year later it's still plagues with stupidities.

I personally use jcreator (www.jcreator.com) with ANT & JUnit. Many people use NetBean but I do not believe that these "one size fit all" tools will ever be good to smthg (except for JBuilder of course :-) ).

Thomas,

vinod

Posts: 22
Nickname: vinod
Registered: Feb, 2002

Re: creating own awt table Posted: Apr 16, 2002 8:36 PM
Reply to this message Reply
hi thomas,

If u consider the advantages we have when we are using J2EE frame work i feel Visual Age for Java is more handy then any other tool in the market. I am telling u out this with experience. The facilities like EJB creartion, Persistence and all can be very easily and very fastly done by VAJ i feel.

with best regards,
vinod.

Flat View: This topic has 11 replies on 1 page
Topic: help on a program for saving a file on a web server Previous Topic   Next Topic Topic: JavaServlets and sessions. Need a little help!!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use