problem scrolling jtable

problem scrolling jtable

hi, i've to query the table thousand of times...m table display is not getting stable/proper,especially after getting the empty table...

for removing the table i'm doing this::

numrows = tableModel.getRowCount();

for(int i = numrows - 1;i>=0; i--) { tableModel.removeRow(i); }

pane.remove(table); panel.remove(pane);

for getting the table:: String[] head={"VISITOR NO","VISITOR NAME","VISIT TO PERSON","PURPOSE","IN TIME","DATE"}; colname=new Vector(Arrays.asList(head)); tableModel =new DefaultTableModel(rowdata, colname){public boolean isCellEditable(int row, int column) { return false;}}; table = new JTable(tableModel); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setFillsViewportHeight(true);

              settabWidth(table, head.length);
     header = table.getTableHeader();

     pane = new JScrollPane(table);


View Answers

April 1, 2011 at 1:32 PM

change the size of pane so that both the bars will get visible.

import java.sql.*;
import java.util.*;
import javax.swing.*; 

class JTableExample extends JFrame { 
    private static int offset = 50; 

    public JTableExample(int horizPolicy, int vertPolicy, String title) { 
    final Vector columnNames = new Vector();
    final Vector data = new Vector();
    JPanel panel=new JPanel();
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
    Statement st = con.createStatement();
    ResultSet rs= st.executeQuery("Select * from employee");
    ResultSetMetaData md = rs.getMetaData();
    int columns = md.getColumnCount();
    for (int i = 1; i <= columns; i++){
    Vector row = new Vector(columns);
    for (int i = 1; i <= columns; i++){
catch(Exception e){}
JTable table = new JTable(data, columnNames);

        offset += 50; 
        JScrollPane scroll = new JScrollPane(table); 
    public static void main(String[] args) { 
     JTableExample f=new JTableExample(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED,JScrollPane. 



Related Tutorials/Questions & Answers:
problem Scrolling jTable in scrollpane
problem Scrolling jTable in scrollpane  hi i get into a problem of scrolling jtable in scrollpane.Only horizontal scroll is working, vertical scroll...)); tableModel =new DefaultTableModel(rowdata, colname); table = new JTable
problem Scrolling jTable in scrollpane
problem Scrolling jTable in scrollpane  hi i get into a problem of scrolling jtable in scrollpane.Only horizontal scroll is working, vertical scroll...)); tableModel =new DefaultTableModel(rowdata, colname); table = new JTable
problem scrolling jtable
problem scrolling jtable  hi, i've to query the table thousand...;}}; table = new JTable(tableModel...); MAIN PROBLEM HERE'S M TABLE IS NOT PROPERLY SETTING IN SCROLLPANE...REPLY SOON
jTable data problem
jTable data problem  Hello. I have a code that read file and store in arraylist and then convert to array(To use for table model) My class extends...(){ JFrame frame=new JFrame(); JTable table=new JTable(rftl); JPanel panel
jtable  hey i have build a form and i m also able to add data from database to jtable along with checkbox.the only problem is that if i select multiple checkboxes the data doesnt get inserted into new database and if only one
scrolling image
scrolling image  How create a scrolling image in java
JTable  Values to be displayed in JTextfield when Clicked on JTable Cells
JTable  i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
JTable   how to select a definite cell which containing a similar text containg to the one which the user entering from a jtable at runtime in java
image scrolling
image scrolling  A brief description of scrolling image
JTable  Hello, i cannot display data from my table in the database to the cells of my JTable. please help me
JTable  below describes a program of research that results in a table, my problem is that this same table to see it only accepts a single line even..."}; JTable table=new JTable(data,labels); JScrollPane pane=new JScrollPane
jtable  how to get the values from database into jtable and also add a checkbox into it and then when selected the checkbox it should again insert into database the selected chewckbox.plzz help
jtable  hi Sir i am working netbeans IDE,I have a jtable when i insert values in jtable then i am unable to print all inserted values,For eg if i insert 1,2,3,4,5,6,7,8 values then , i am getting output
Scrolling in UIWebView
Scrolling in UIWebView  How to make an un-scroll able UIWebView
JTable  Hi I have problems in setting values to a cell in Jtable which is in a jFrame which implements TableModelListener which has a abstract method tableChanged(TableModelEvent e) . I'll be loading values from data base when
Scrolling UIWebView JavaScript
Scrolling UIWebView JavaScript  Hi, i am looking for an example code to make a scrolling function for UIWebView in JavaScript. Thanks
Disable UITableView Scrolling
Disable UITableView Scrolling   How to disable the UITableView Scrolling either programmatically or in XIB
scrolling div ipad
scrolling div ipad   Please suggest me how to scroll the div in iPad UIWebView? Thanks
scrolling text in applet
scrolling text in applet  applet to display the scrolling text. The text should move from right to left. When it reaches to start of the applet border, it should stop moving and restart from the left. When the applet
Database Scrolling Buttons
Database Scrolling Buttons  Sir, I have two button "Next" and "Previous". I'am able to retrieve data from database but I don't understand as to how display data on next and previous button clicks. Please help me out
JTable populate with resultset.
JTable populate with resultset.  How to diplay data of resultset using JTable?   JTable is component of java swing toolkit. JTable class is helpful in displaying data in tabular format. You can also edit data. JTable
JTABLE OF JAVA  i have a jtable in java,i have used checkbox in jtable. now i want to add(submit) only those records that i have checked by checkbox how? i want small example with coding
Jtable-Java  Hi all,I have a Jtable And i need to clear the data in the table .I only Need to remove the data in the table.not the rows.Please help me
sum in JTable
sum in JTable  how to calculate sum from JTable's one field like total
JTABLE Issue  Hi Eveyone, I am developing a small application on Swing-AWT. I have used JTABLE to show data. There is "input field" and "search... on basis of input data provided in input field. For JTABLE is on some other
jtable query
jtable query  I need a syntax...where i could fetch the whole data from the database once i click the cell in jtable...and that must be displayed in the nearby text field which i have set in the same frame
java jtable
java jtable  Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to read only... that in jtable. plz help me with the code
regarding jtable...
regarding jtable...  sir, im working with jtables. i wanted to populate a jtable from the database and when i click any row it should add a container... a container on the jtable. kindly help me sir. thanks in advance regards, rajahari
ABOUT Jtable
ABOUT Jtable  My Project is Exsice Management in java swing Desktop Application. I M Use Netbeans & Mysql . How can retrive Data in Jtable from Mysql Database in Net Beans
JTable duplicate values in row
JTable duplicate values in row  JTable duplicate values in row