I have a small java application for efficiently tailing an arbitrary set of files defined in an ini file. My "LogReader" class extends the JFrame and makes a heavy lift; reading a collection of file paths into a vector, and then iterating over the vector, reading each file and adding the last X lines of each to the text areas on the JTabbedPane tabs. The process of creating a vector and iterating over files begins by pressing the JButton button through the ActionListener.
Reading the files worked fine (and still), but the process of reading some 20 files, some of which grow to 30 MB, takes some time. To help get through at this time, I decided to add a progress screen that says: “Now we read file No. 3 of 26: c: \ logs \ superduper1.log”, etc. So I created another "SplashScreen" class, also extending the JFrame and adding a JLabel that will indicate progress. The SplashScreen class has an update () method that simply executes setText () in JLabel.
The ActionListener in JButton calls RefreshLogs (), which looks something like this:
vctFileStrings.clear();
tpMain.removeAll();
frmSplash.update("Loading Configuration");
BuildVectorOfLogs(strConfFile);
frmSplash.update("Reading Logs");
ReadLogs();
and then ReadLogs () iterates over the vector, reading the files and creating the TabbedPane.
, , RefreshLogs() ActionListener, Splash Screen . , RefreshLogs() , , ( ). , , , .
:
- ? , , ActionListener?
- , ? - ? GUI ( ) , JButton?