Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-09-2008, 09:23 PM
Member
 
Join Date: May 2008
Posts: 29
adeeb is on a distinguished road
Problem in getting table on panel
Hi,
this is the code for the layout as well as for the button listener. I have tried to write the code to get data in table. But i dont see any table on the panel except two text fields and a button which i have add below. More Over when i tried to display the table in another panel without any other component it was successfully seen. Means i dint add any button so that on clicking that i could get the table. But i actually need the button so that i get the table when i click it.
ftf = new JTextField(20);
ftf1 = new JTextField(20);
froll = new JLabel("Roll No");
fname = new JLabel("Name");
find = new JButton("Find");
//tb = new JTable();
//ta = new JTextArea(10,10);
GroupLayout gl5 = new GroupLayout(jp5);
jp5.setLayout(gl5);
gl5.setAutoCreateGaps(true);
gl5.setAutoCreateContainerGaps(true);
gl5.setHorizontalGroup(gl5.createSequentialGroup()
.addGroup(gl5.createParallelGroup(LEADING)
.addComponent(froll)
.addComponent(fname))
.addGroup(gl5.createParallelGroup(LEADING)
.addComponent(ftf)
.addComponent(ftf1)
.addComponent(find, (CENTER))
.addComponent(tb, (CENTER)))
);
gl5.setVerticalGroup(gl5.createSequentialGroup()
.addGroup(gl5.createParallelGroup(BASELINE)
.addComponent(froll)
.addComponent(ftf))
.addGroup(gl5.createParallelGroup(BASELINE)
.addComponent(fname)
.addComponent(ftf1))
.addGroup(gl5.createParallelGroup(BASELINE)
.addComponent(find))
.addGroup(gl5.createParallelGroup(BASELINE)
.addComponent(tb))
);
gl5.linkSize(SwingConstants.HORIZONTAL, ftf, ftf1);
find.addActionListener(new ActionListener()
{

public void actionPerformed(ActionEvent e)
{
Vector colnames = new Vector();
Vector tbdata = new Vector();
try
{
conn = DriverManager.getConnection("jdbc dbc:addissue", "library","adeeb");
String rollno = ftf.getText();
int roll = Integer.parseInt(rollno);
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM addissue WHERE rollno="+roll);
ResultSetMetaData md = rs.getMetaData();
int col = md.getColumnCount();

for (int i=1;i<=col;i++)
{
colnames.addElement(md.getColumnName(i));
}
while(rs.next())
{
Vector row1 = new Vector(col);
for(int i=1;i<=col;i++)
{
row1.addElement(rs.getObject(i));
}
tbdata.addElement(row1);
}
rs.close();
stmt.close();
conn.close();
tb = new JTable(tbdata,colnames);
JScrollPane jsp1 = new JScrollPane(tb);
}

catch(Exception ce)
{
System.out.println("Exception"+ce);
}
}
});
So any body please help.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with jTable that is binded with a table in MySQL Database rajkenneth NetBeans 0 03-29-2008 04:36 PM
Problem with sorting Table sireesha264 Advanced Java 0 02-08-2008 03:21 PM
Problem with applying Sql order by to html table sireesha264 Advanced Java 2 02-04-2008 11:20 AM
Why the panel text changed? ottawalyli SWT / JFace 0 12-16-2007 05:16 PM
Help with drag from panel fernando AWT / Swing 2 08-07-2007 11:19 PM


All times are GMT +3. The time now is 04:19 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org