[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform.swt] structure of classes and files
|
- From: Martin Röhricht <ng@xxxxxxxxxxx>
- Date: Fri, 10 Jun 2005 10:49:39 +0200
- Newsgroups: eclipse.platform.swt
- Organization: EclipseCorner
- User-agent: Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux))
Hello together,
by creating a new GUI project with Eclipse and SWT, I was wondering how to
structure the elements and seperate them into different files. For
instance, I don't want to concentrate the whole menu in the main GUI
class.
Currently I created something like this:
-------------(TestGUI.java)---------------------
package entities;
[...]
public class TestGUI {
[...]
protected static Shell iMainWindow;
[...]
public TestGUI() {
iDisplay = new Display();
iMainWindow = new Shell(iDisplay);
[...]
}
private void createGUI() {
[...]
MyMenuBar mb = new MyMenuBar();
iMainWindow.setMenuBar(mb.createMenuBar());
[...]
}
public static void main(String[] args) {
TestGUI gui = new TestGUI();
gui.createGUI();
[...]
}
}
------------------------------------------------
I create the Shell iMainWindow in the main TestGUI-class and want to
create the Menu for this shell in another class (and file):
-------------(MyMenuBar.java)-------------------
package entities;
[...]
public class MyMenuBar {
protected Menu createMenuBar() {
Menu mb = new Menu(TestGUI.iMainWindow, SWT.BAR);
Menu fileMenu = new Menu(mb);
MenuItem fileMenuItem = new MenuItem(mb,SWT.CASCADE);
fileMenuItem.setText("File");
fileMenuItem.setMenu(fileMenu);
[...]
}
}
------------------------------------------------
Is this the designated way? Or has someone a recommendation for a better
solution? I'd appreciate any help.
Martin