Board index » jbuilder » how can I display the output from system.out.println message to JDialog?

how can I display the output from system.out.println message to JDialog?


2005-08-31 08:13:29 AM
jbuilder7
Hi,
I don't what would be the best approach to my problem.
I have a routine that populate user data into oracle table. This operates is
quite lenghty. I want to show
what's happening as the data is being inserted into the table.
Is there a way to direct the output of the system.out.println("") to Jdialog
as a popup window to show the user what's being inserted?
code snip:
..
JDialog jwin = new JDialog();
String statusTitle = "Populating initial data... please wait...";
jwin.setTitle(statusTitle);
jwin.setResizable(true);
jwin.setBackground(Color.lightGray);
jwin.setBounds(50, 50, 400, 400);
jwin.setVisible(true);
...
try {
...
while (rset.next()) {
//print each row
System.out.println(rset.getString(1) + " " + rset.getString(2) + " " +
rset.getString(3) + " " + rset.getString(4) + " " +rset.getString(5));
}
} catch (SQLException ex) {
}
Thanks,
Tom
 
 

Re:how can I display the output from system.out.println message to JDialog?

I would create an interface like (maybe with percentage, if you need to
change a progress bar):
public interface Progress {
void changeStatus(String msg);
}
Then create an implementation in your dialog. Since the interface will
be called from another thread, do not modify the dialog directly, but
from invokeLater().
- Alexey.
tom wrote:
Quote
Hi,

I don't what would be the best approach to my problem.

I have a routine that populate user data into oracle table. This operates is
quite lenghty. I want to show
what's happening as the data is being inserted into the table.

Is there a way to direct the output of the system.out.println("") to Jdialog
as a popup window to show the user what's being inserted?

code snip:
..
JDialog jwin = new JDialog();
String statusTitle = "Populating initial data... please wait...";
jwin.setTitle(statusTitle);
jwin.setResizable(true);
jwin.setBackground(Color.lightGray);
jwin.setBounds(50, 50, 400, 400);
jwin.setVisible(true);
...
try {
...
while (rset.next()) {
//print each row
System.out.println(rset.getString(1) + " " + rset.getString(2) + " " +
rset.getString(3) + " " + rset.getString(4) + " " +rset.getString(5));
}

} catch (SQLException ex) {
}
Thanks,


Tom


--
Alexey N. Solofnenko {trelony at gmail.com}
home: trelony.cjb.net/