Home Answers Viewqa Swing-AWT problem Scrolling jTable in scrollpane

 
 


teena grover
problem Scrolling jTable in scrollpane
2 Answer(s)      2 years and 2 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 working...here is m code: try {

        PreparedStatement pst=c1.prepareStatement("select * from entry where  visit_to_person=?");
        pst.setString(1,visit_combo.getSelectedItem().toString());
        ResultSet rs =pst.executeQuery();
                        while(rs.next())
                    {

                        vno= rs.getString(1);
                        vnam=rs.getString(2);
                        vtp=rs.getString(3);
                        pur=rs.getString(4);
                        in=rs.getString(5);
                        dat=rs.getString(6);
                        String s[]={vno,vnam,vtp,pur,in,dat};
                        Vector coldata=new Vector(Arrays.asList(s));
                        rowdata.add(coldata);
                    }
            String[] head={"VISITOR NO","VISITOR NAME","VISIT TO PERSON","PURPOSE","IN TIME","DATE"};
        colname=new Vector(Arrays.asList(head));
            tableModel =new DefaultTableModel(rowdata, colname);
            table = new JTable(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    JTableHeader header = table.getTableHeader();
    JScrollPane pane = new JScrollPane(table);
            pane.setAutoscrolls(true);
            pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            pane.setSize(450,300);
            pane.setVisible(true);

    panel.add(pane,BorderLayout.CENTER);
            JFrame.setDefaultLookAndFeelDecorated(true);

     }
    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();
    try{
    Class.forName("com.mysql.jdbc.Driver");
    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++){
    columnNames.addElement(md.getColumnName(i));
    }
    while(rs.next()){
    Vector row = new Vector(columns);
    for (int i = 1; i <= columns; i++){
    row.addElement(rs.getObject(i));
    }
    data.addElement(row);
    }
   }
catch(Exception e){}
JTable table = new JTable(data, columnNames);

        setTitle(title); 
        offset += 50; 
        setLocation(offset,offset); 
        setSize(300,150); 
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); 
        JScrollPane scroll = new JScrollPane(table); 
        scroll.setHorizontalScrollBarPolicy(horizPolicy); 
        scroll.setVerticalScrollBarPolicy(vertPolicy); 
        getContentPane().add(scroll); 
    } 
    public static void main(String[] args) { 
     JTableExample f=new JTableExample(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED,JScrollPane. 
VERTICAL_SCROLLBAR_AS_NEEDED,"HORIZONTAL_SCROLLBAR_AS_NEEDED");
     f.setVisible(true);

    } 
}

March 28, 2011 at 11:05 AM


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









Related Pages:
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
jtable
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
JTable
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 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
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
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
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
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 - Java Beginners
want my JTable on the panel. and i also want to increase height and width of the columns. how can i do this. and one more problem is that i want windows look...); } res2.close(); stat3.close(); JTable table = new JTable(data
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
Multi-line cells in the JTable - Java Tutorials
Multi-line cells in the JTable 2002-04-11 The Java Specialists' Newsletter [Issue 045] - Multi-line cells in the JTable Author: Dr. Heinz M. Kabutz... any more time, let's look at a real-life Java problem... Multi-line cells
REPORT WITH JTABLE
(Exception e){} JTable table = new JTable(data, columnNames); JScrollPane scrollPane = new JScrollPane(table); panel.add(scrollPane); add(panel); } public static void
printout problem
) ); } data.addElement( row ); } } catch(Exception e){} JTable table = new JTable(data, columnNames); JScrollPane scrollPane = new JScrollPane(table); panel.add(scrollPane); add(panel); } public static void main(String arg[]) { try
scrolling image
scrolling image  How create a scrolling image in java
JTable - Java Beginners
JTable search example  I've problem about JTable, i wan to search records when i types words in JTable cell,can u give the source code.I'm Beginner and i start begins learning java programming.Please send the example into my
image scrolling
image scrolling  A brief description of scrolling image
java swing (jtable)
java swing (jtable)  hii..how to get values of a particular record in jtable from ms access database using java swing in netbeans..?? please help... from database and display it in jtable. import java.awt.*; import java.sql.
Scrolling in UIWebView
Scrolling in UIWebView  How to make an un-scroll able UIWebView
update a JTable - Java Beginners
update a JTable   how to update a JTable with Mysql data through user... in an updatable JTable You would create the table as follows: conn... = new ResultSetTableModel(rs); table = new JTable(model
Jtable Question - Java Beginners
Jtable Question  Hello Sir, I have Created Database in MS access 2007 ,I want show the table data in to Swing JTable, How I can Show it, plz Help...(); stmt.close(); } catch(Exception e){ System.out.println(e); } JTable table = new
JTable - Swing AWT
JTable  Hi Deepak, i m facing a problem with jtable. i am able to display the values from the database into the jtable. but not able to modifying multiple cell values in a row. also i want to store those modified
update a JTable - Java Beginners
update a JTable   i have tried your advice as how to update a JTable... main(String args[]) { JTable table; Connection con = null..."); ResultSetTableModel model = new ResultSetTableModel(rs); table = new JTable(model
Connecting JTable to database - JDBC
Connecting JTable to database  Hi.. I am doing a project on Project... interface in which i have used JTables.. Now my problem is I dont know how to how to store this JTable content in my database table.. This is a very important
JTable
JTable  Values to be displayed in JTextfield when Clicked on JTable Cells
JTable
JTable  i want to delete record from JTable using a MenuItem DELETE. and values of JTable are fetched from database....please reply soon
JTable
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
JTABLE SCROLL PANE
JTABLE SCROLL PANE  The scrollpane for a image in Jtable is only showing but not working ....here is the code i am doing please suggest something... import java.awt.Component; import java.io.FileReader; import
JTABLE SCROLL PANE
JTABLE SCROLL PANE  The scrollpane for a image in Jtable is only showing but not working ....here is the code i am doing please suggest something... import java.awt.Component; import java.io.FileReader; import
JTable
JTable  need to add values to a JTable having 4 coloumns ,2 of them are comboboxes
JTable
JTable  Hello, i cannot display data from my table in the database to the cells of my JTable. please help me
How to use JTable with MS-Access
How to use JTable with MS-Access   I have Three Column in Database... this data in JTable. How can I do it. I also want to EDIT and DELETE this Data... and display it in JTable. import java.awt.*; import java.sql.*; import java.util.
How to use JTable with MS-Access
How to use JTable with MS-Access   I have Three Column in Database... this data in JTable. How can I do it. I also want to EDIT and DELETE this Data... and display it in JTable. import java.awt.*; import java.sql.*; import java.util.
jtable
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
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
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
This JDK Tutorial shows you how to wrap text inside cells of a JTable
JDK Tutorial - Multi-line cells in JTable in JDK 1.4+ This JDK Tutorial shows you  how to wrap text inside cells of a JTable. 2005-04-14 The Java Specialists' Newsletter [Issue 106] - Multi-line cells in JTable in JDK 1.4
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
How to refresh a jTable On adding or deleting record ....
How to refresh a jTable On adding or deleting record ....   Hii Sir, I am developing a project in which a jtable is getting populated... from same panel and i want jtable to be refreshed after every addition
Java insert file data to JTable
Java insert file data to JTable In this section, you will learn how to insert text file data into JTable. Swing has provide useful and sophisticated set...; JTable class. Here is the code: import java.io.*; import java.awt.
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
Extract File data into JTable
Extract File data into JTable In this section, you will learn how to read the data from the text file and insert it into JTable. For this, we have created...(); JTable table = new JTable(); table.setModel(model); JScrollPane
Add XML to JTable
Add XML to JTable In this section, you will learn how to access the contents or data of xml document and display its information into the jtable. Java... all the xml file data into the JTable . Here is the person.xml file

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.