Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » structure of classes and files
structure of classes and files [message #456834] Fri, 10 June 2005 08:49
Eclipse UserFriend
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
Previous Topic:Is there a way to make top level shells on Mac OS X ?
Next Topic:Animated GIF with ImageLoader
Goto Forum:
  


Current Time: Thu Apr 25 02:04:08 GMT 2024

Powered by FUDForum. Page generated in 0.02921 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top