structure of classes and files [message #456834] |
Fri, 10 June 2005 08:49 |
Eclipse User |
|
|
|
Originally posted by: ng.felicis.org
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
|
|
|
Powered by
FUDForum. Page generated in 0.02921 seconds