次のような状況があります。複数のタブを持つ GUI。すべてのタブには、ホーム ディレクトリの特定のディレクトリにあるファイルの内容が表示されます。これらのディレクトリには、GUI の作成時点で存在するものもあれば、存在しないものもあります。FTP経由のタブの1つで、ファイルを取得してホームディレクトリに追加します。
注: Java 5 を使用しています。
FTP がこのタブに属するディレクトリに新しいファイルを追加したことをすべてのタブに知らせる方法は?
public class ScannerPanel extends JPanel implements ChangeListener {
private void initGUI() {
setPreferredSize(new Dimension(700, 400));
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.addTab("FTP", IconLib.ICON_16X16_DATA,new FtpTabPanel (this),"FTP");
tabbedPane.addTab("PCS", IconLib.ICON_16X16_THUM,new PcsTabPanel (this),"PCS");
tabbedPane.addTab("Car", IconLib.ICON_16X16_PAPE,new CarTabPanel (this),"Car");
tabbedPane.addTab("Pic", IconLib.ICON_16X16_RETI,new PicTabPanel (this),"Pic");
tabbedPane.addChangeListener(this);
add(tabbedPane);
}
public void stateChanged(ChangeEvent e) {
//detect new file has been added to directory
// update the content of tab
}
}