🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #11455

Problems with JTable and Scrollpane

#11455
From: LMarco
Date: Wed, 02 Jun 1999 00:00
92 lines
3231 bytes
Dear All
I use JBuilder2 Standard with Swing1.01 (I cant update to a newer
version of Swing :-( because I'm not allowed to do this) and I have the
following problem with a scrollpane for a jtable:
I use the jtable to show the results of a database research. Everytime
when to much hits are found, the vertical scrollbar should be shown, but
it doesnt show up. when I minimize/maximize the whole applet-window the
Scrollbar is shown (but only to call repaint doesnt solve the problem).
When the next search has only a few hits (the scrollbar isn't necessary)
the Scrollbar should be hidden, but it doesnt.
Please help me with this problem!
Thanks...
LMarco

PS: Here is the Sourcecode for the jtable and the Tablemodel:
  JTable jTableResultset = new JTable();
  //JScrollPane jScrollPane1 = new JScrollPane();
  JScrollPane jScrollPane1 =
jTableResultset.createScrollPaneForTable(jTableResultset);


in the jbinit:
    jTableResultset.addMouseListener(new
SearchPanel_jTableResultset_mouseAdapter(this));
    jTableResultset.setModel(myTableModel);
    jTableResultset.setSelectionMode(0);
    jTableResultset.setToolTipText("Doppelklick f�r Details");


to set the data in the Table I set the data in the vector StartApplet.av
and then I call repaint(). The tabelModel gets it data from the above
vector.



class MyTableModel extends DefaultTableModel
{
  protected String[] columnName =
{"Vorname","Nachname","PLZ","Ort","Jahrgang"};

  public String getColumnName(int index)
  {
    return columnName[index];
  }

  public int getColumnCount()
  {
    return 5;
  }

  public int getRowCount()
  {
    if (StartApplet.av != null)        //Startapplet.av is a list
        return StartApplet.av.size();
    else
        return 0;
  }

  public Object getValueAt(int row, int col)
  {
    Object result = null;
    if (row < StartApplet.av.size())
    {
      int i=0;
      //Absolvent f�r aktuelle Zeile aus Vektor holen
      for (StartApplet.a = StartApplet.av.first(),i=0;i<row;i++)
      {
        StartApplet.a = StartApplet.av.forward();
      }

      switch (col)
      {
        case 0: result = StartApplet.a.getVorname();
                         break;
        case 1: result = StartApplet.a.getNachname();
                         break;
        case 2: result = StartApplet.a.getPlz();
                         break;
        case 3: result = StartApplet.a.getOrt();
                         break;
        case 4: result = new Integer(StartApplet.a.getJahrgang());
                         break;
      }
    }
    return result;
  }

  public boolean isCellEditable(int row, int col)
  {
    return false;
  }
}
Technical Details
Message-ID: <375532AE.9AC4DB4C@gmx.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,1e3ea87ca05e4cda,start
X-Google-Attributes: gid111d45,public
From: LMarco <LMarco@gmx.net>
Subject: Problems with JTable and Scrollpane
Date: 1999/06/02
Message-ID: <375532AE.9AC4DB4C@gmx.net>
X-Deja-AN: 484858851
Content-Transfer-Encoding: 8bit
Organization: Another Netscape Collabra Server User
X-Accept-Language: en
Content-Type: text/plain; charset=iso-8859-1
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing