This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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
jQuery in Action, 3rd edition