File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes updating list dynamically on the frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "updating list dynamically on the frame" Watch "updating list dynamically on the frame" New topic

updating list dynamically on the frame

Rajesh Chandra
Ranch Hand

Joined: Jun 13, 2005
Posts: 55
Hi everybody,

I have 2 buttons in a panel on a frame which triggers saves the data from a textfield to databse and the other get the data from database and populate into the list which i have added to the frame.When i click the view button it paints a list with data from database.And if i save
(click the save button),the database updates but if i click view again the list doesnt update withnew values(without closing the frame).Can anyone spot the error?
Thanks in advance.

This is the code snippet:-
pt is panel ,view is button

pt.view.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)


add(lst, BorderLayout.EAST);

// Point po=lst.getLocationOnScreen();
System.out.println("location "+po);



public void viewPhoneBook(){
// static int i=0;
r1=new String[35];

con=DriverManager.getConnection("jdbc dbc:acodbc","","");

rs=stmt.executeQuery("SELECT* from PHONEDIARY");

// Label ld=new Label(rs.getString(1)+" "+rs.getInt(2));

System.out.println(i+" ");
System.out.println("r[i] in while"+r1[i]);
// add(ld);
// return i;

// gridbag.setConstraints(ld, constraints);
}catch(Exception e){}

lst = new List(i, true);
System.out.println("i after while"+PhoneBook1.i);
System.out.println("r[2] after while"+r1[2]);

for(int j=0;j<i;j++){


cat cater
Ranch Hand

Joined: Jun 06, 2005
Posts: 39
I think there has a error.
"add(lst, BorderLayout.EAST);"
new code : JMainFrame.this.add(lst, BorderLayout.EAST);
you try again.
cat cater
Ranch Hand

Joined: Jun 06, 2005
Posts: 39
"JMainFrame" is the current classname.
cat cater
Ranch Hand

Joined: Jun 06, 2005
Posts: 39
new code :, BorderLayout.EAST)
I agree. Here's the link:
subject: updating list dynamically on the frame
It's not a secret anymore!