problem Scrolling jTable in scrollpane



Share on Google+Share on Google+

teena grover
problem Scrolling jTable in scrollpane
2 Answer(s)      6 years and 7 months ago
Posted in : Swing AWT

hi i get into a problem of scrolling jtable in scrollpane.Only horizontal scroll is working, vertical scroll is not is m code: try {

        PreparedStatement pst=c1.prepareStatement("select * from entry where  visit_to_person=?");
        ResultSet rs =pst.executeQuery();

                        vno= rs.getString(1);
                        String s[]={vno,vnam,vtp,pur,in,dat};
                        Vector coldata=new Vector(Arrays.asList(s));
        colname=new Vector(Arrays.asList(head));
            tableModel =new DefaultTableModel(rowdata, colname);
            table = new JTable(tableModel);
    JTableHeader header = table.getTableHeader();
    JScrollPane pane = new JScrollPane(table);


    catch(SQLException sq){}
View Answers

March 26, 2011 at 4:39 PM

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. 


March 28, 2011 at 11:05 AM

really thanku sir for ur early reply...but still have the problem


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...); MAIN PROBLEM HERE'S M TABLE IS NOT PROPERLY SETTING IN SCROLLPANE...REPLY SOON...;}}; table = new JTable(tableModel
scrolling problem - Framework
scrolling problem  I have eco framework application in that i created... on contentpane also. while scrolling only image is moving but window is not moving . can anybody tell me how can solve this problem
jtable problem
jtable problem  how to make a cell text hypertext
problem in scrolling SVG drawing in canvas - MobileApplications
problem in scrolling SVG drawing in canvas  hi all, i'm...- usually map's size is bigger than mobile screen , so i need to make scrolling over the drawing , scrolling works well in wireless toolkit emulator , but when i
problem with JTable - Swing AWT
problem with JTable  hi guys, i was a student and i am very new to swings.i was having an assignment like i need to create a JTable... an action event such that if i check the checkbox outside the JTable,all the checkboxes
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
scrolling image
scrolling image  How create a scrolling image in java
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
image scrolling
image scrolling  A brief description of scrolling image
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
Scrolling in UIWebView
Scrolling in UIWebView  How to make an un-scroll able UIWebView
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
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
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
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
scrolling a drawing..... - Swing AWT
scrolling a drawing.....  I am using a canvas along with other components like JTable over a frame the drawing which i am going to show over canvas is dynamic and hence there is no fixed size, that's why i need to make
Disable UITableView Scrolling
Disable UITableView Scrolling   How to disable the UITableView Scrolling either programmatically or in XIB
Scrolling UIWebView JavaScript
Scrolling UIWebView JavaScript  Hi, i am looking for an example code to make a scrolling function for UIWebView in JavaScript. Thanks
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
(Exception e){} JTable table = new JTable(data, columnNames); JScrollPane scrollPane = new JScrollPane(table); panel.add(scrollPane); add(panel); } public static void
JTable - Java Beginners
JTable  Hi, I have some problem with JTable. On show All button hit.... my problem is with Jtable, sometimes it is visible and sometimes it is not. when... it is on the panel with records. An another problem is that, i want
keep spacings between images when adding to scrollpane
keep spacings between images when adding to scrollpane  !alt textI'm adding a list of images from a directory using an arraylist.When images are added,my ScrollPane gets crowded.How can I keep spacings between images ? here's my


Advertisement null