SWT を使用してアプリケーションのメニューを作成しています。
クラス "B" では、メソッド createContents() がフォームのコンテンツを作成します。
protected void createContents() {
shell = new Shell();
shell.setSize(500, 315);
shell.setText("SWT Application");
Label lblNewLabel = new Label(shell, SWT.NONE);
lblNewLabel.setFont(SWTResourceManager.getFont("Segoe UI", 14, SWT.NORMAL));
lblNewLabel.setBounds(188, 0, 108, 25);
Button btnLogs = new Button(shell, SWT.NONE);
btnLogs.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Window3 window = new Window3();
window.open();
}
});
btnLogs.setBounds(386, 242, 75, 25);
StyledText styledText = new StyledText(shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
styledText.setBounds(10, 64, 357, 203);
Label lblRealTimeLogs = new Label(shell, SWT.NONE);
lblRealTimeLogs.setBounds(10, 35, 108, 15);
Button btnFilters = new Button(shell, SWT.NONE);
btnFilters.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Window2 window = new Window2();
window.open();
}
});
btnFilters.setBounds(386, 204, 75, 25);
btnFilters.setText("FILTRES");
Label lblConfiguration = new Label(shell, SWT.NONE);
lblConfiguration.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
lblConfiguration.setText("Configuraci\u00F3");
lblConfiguration.setBounds(386, 128, 88, 15);
Button btnNewButton = new Button(shell, SWT.NONE);
btnNewButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Window4 window = new Window4();
window.open();
}
});
btnNewButton.setBounds(386, 165, 75, 25);
}
次に、アプリケーションを実行すると、クラス「B」のフォームが表示されます。問題は、別のクラスの styledtext に新しいテキスト行を追加する必要があることです。私がする必要があるのは、クラス「A」でファイルのコンテンツをチェックし、コンテンツが変更された場合、メソッド createContents() 内のクラス「B」で作成された styledtext に新しい行を追加することです...簡単に思えますが、クラス「B」で作成されたスタイル付きテキストをクラス「A」から参照して、これらの新しい行を追加することはできません...
わかりにくかったらすみません、私の英語はあまり上手ではありません...
どんな助けでも大歓迎です。ありがとう。