Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » A question about display
A question about display [message #435686] Sat, 01 May 2004 22:30 Go to next message
Eclipse UserFriend
Originally posted by: sarahjws.hotmail.com

I am a Eclipse beginner. I am working on a library Management System.
There is a main menu and when the menu item is selected, a new dialog
should be displayed. For example, when I selects "Add Borrower", a dialog
appears and I can input some informaiton about the new borrower such as
name and ID. My question is, so far I got the dialog, but nothing appears
in this dialog. The following is my program:

public class MenuSample {

public static void main(String[] args) {
MenuSample window = new MenuSample();
window.open();
}

public void open() {
final Display display = new Display();
final Shell shell = new Shell();
shell.setText("Library Management System");

Menu menu=new Menu(shell,SWT.BAR);
shell.setMenuBar(menu);

MenuItem bomenu=new MenuItem(menu,SWT.CASCADE);
bomenu.setText("Borrower");

Menu filemenu=new Menu(bomenu);
bomenu.setMenu(filemenu);

MenuItem addBoItem=new MenuItem(filemenu,SWT.NONE);
addBoItem.setText("Add Borrower");

MenuItem updBoItem=new MenuItem(filemenu,SWT.PUSH);
updBoItem.setText("Update Borrower");

MenuItem seperator=new MenuItem(filemenu,SWT.SEPARATOR);

MenuItem quitItem=new MenuItem(filemenu,SWT.PUSH);
quitItem.setText("Exit");

addBoItem.addListener(SWT.Selection,new Listener(){
public void handleEvent(Event e){

BorrowerFrame bf=new BorrowerFrame(shell);
bf.open();
}
});
.........
}

public class BorrowerFrame extends Dialog {

Object result;

public BorrowerFrame(Shell parent, int style) {
super (parent, style);
}

public BorrowerFrame(Shell parent) {
this (parent, 0);
}

public Object open () {
Shell parent = getParent();
Shell dialog = new Shell(parent, SWT.DIALOG_TRIM |
SWT.APPLICATION_MODAL);
dialog.setText("Add Borrower");

Label label1=new Label(dialog,SWT.NONE);
label1.setText("Last Name");

Text text1=new Text(dialog,SWT.BORDER);
text1.setTextLimit(20);

dialog.open();

return result;
}

}
I know I should add something like layout manager, but I think that is not
the key for this question.
Anyone can give me suggestion? This is my final project. Your help will be
greatly appreciated!

sarah
Re: A question about display [message #435687 is a reply to message #435686] Sun, 02 May 2004 00:16 Go to previous messageGo to next message
Daniel Spiewak is currently offline Daniel SpiewakFriend
Messages: 263
Registered: July 2009
Senior Member
You do need to add a layout manager. Unlike Swing, in SWT there is no
default layout manager.

Daniel

sarahsarah wrote:

>I am a Eclipse beginner. I am working on a library Management System.
>There is a main menu and when the menu item is selected, a new dialog
>should be displayed. For example, when I selects "Add Borrower", a dialog
>appears and I can input some informaiton about the new borrower such as
>name and ID. My question is, so far I got the dialog, but nothing appears
>in this dialog. The following is my program:
>
>public class MenuSample {
>
> public static void main(String[] args) {
> MenuSample window = new MenuSample();
> window.open();
> }
>
> public void open() {
> final Display display = new Display();
> final Shell shell = new Shell();
> shell.setText("Library Management System");
>
> Menu menu=new Menu(shell,SWT.BAR);
> shell.setMenuBar(menu);
>
> MenuItem bomenu=new MenuItem(menu,SWT.CASCADE);
> bomenu.setText("Borrower");
>
> Menu filemenu=new Menu(bomenu);
> bomenu.setMenu(filemenu);
>
> MenuItem addBoItem=new MenuItem(filemenu,SWT.NONE);
> addBoItem.setText("Add Borrower");
>
> MenuItem updBoItem=new MenuItem(filemenu,SWT.PUSH);
> updBoItem.setText("Update Borrower");
>
> MenuItem seperator=new MenuItem(filemenu,SWT.SEPARATOR);
>
> MenuItem quitItem=new MenuItem(filemenu,SWT.PUSH);
> quitItem.setText("Exit");
>
> addBoItem.addListener(SWT.Selection,new Listener(){
> public void handleEvent(Event e){
>
> BorrowerFrame bf=new BorrowerFrame(shell);
> bf.open();
> }
> });
> .........
> }
>
>public class BorrowerFrame extends Dialog {
>
> Object result;
>
> public BorrowerFrame(Shell parent, int style) {
> super (parent, style);
> }
>
> public BorrowerFrame(Shell parent) {
> this (parent, 0);
> }
>
> public Object open () {
> Shell parent = getParent();
> Shell dialog = new Shell(parent, SWT.DIALOG_TRIM |
>SWT.APPLICATION_MODAL);
> dialog.setText("Add Borrower");
>
> Label label1=new Label(dialog,SWT.NONE);
> label1.setText("Last Name");
>
> Text text1=new Text(dialog,SWT.BORDER);
> text1.setTextLimit(20);
>
> dialog.open();
>
> return result;
> }
>
> }
>I know I should add something like layout manager, but I think that is not
>the key for this question.
>Anyone can give me suggestion? This is my final project. Your help will be
>greatly appreciated!
>
>sarah
>
>
>
>
Re: A question about display [message #436085 is a reply to message #435686] Tue, 11 May 2004 11:44 Go to previous message
Eclipse UserFriend
Originally posted by: "prenom.,nom".sextant.thomson-csf.com

I've got the same problem. Did you find the solution?

sarahsarah a écrit :
>
> I am a Eclipse beginner. I am working on a library Management System.
> There is a main menu and when the menu item is selected, a new dialog
> should be displayed. For example, when I selects "Add Borrower", a dialog
> appears and I can input some informaiton about the new borrower such as
> name and ID. My question is, so far I got the dialog, but nothing appears
> in this dialog. The following is my program:
>
> public class MenuSample {
>
> public static void main(String[] args) {
> MenuSample window = new MenuSample();
> window.open();
> }
>
> public void open() {
> final Display display = new Display();
> final Shell shell = new Shell();
> shell.setText("Library Management System");
>
> Menu menu=new Menu(shell,SWT.BAR);
> shell.setMenuBar(menu);
>
> MenuItem bomenu=new MenuItem(menu,SWT.CASCADE);
> bomenu.setText("Borrower");
>
> Menu filemenu=new Menu(bomenu);
> bomenu.setMenu(filemenu);
>
> MenuItem addBoItem=new MenuItem(filemenu,SWT.NONE);
> addBoItem.setText("Add Borrower");
>
> MenuItem updBoItem=new MenuItem(filemenu,SWT.PUSH);
> updBoItem.setText("Update Borrower");
>
> MenuItem seperator=new MenuItem(filemenu,SWT.SEPARATOR);
>
> MenuItem quitItem=new MenuItem(filemenu,SWT.PUSH);
> quitItem.setText("Exit");
>
> addBoItem.addListener(SWT.Selection,new Listener(){
> public void handleEvent(Event e){
>
> BorrowerFrame bf=new BorrowerFrame(shell);
> bf.open();
> }
> });
> .........
> }
>
> public class BorrowerFrame extends Dialog {
>
> Object result;
>
> public BorrowerFrame(Shell parent, int style) {
> super (parent, style);
> }
>
> public BorrowerFrame(Shell parent) {
> this (parent, 0);
> }
>
> public Object open () {
> Shell parent = getParent();
> Shell dialog = new Shell(parent, SWT.DIALOG_TRIM |
> SWT.APPLICATION_MODAL);
> dialog.setText("Add Borrower");
>
> Label label1=new Label(dialog,SWT.NONE);
> label1.setText("Last Name");
>
> Text text1=new Text(dialog,SWT.BORDER);
> text1.setTextLimit(20);
>
> dialog.open();
>
> return result;
> }
>
> }
> I know I should add something like layout manager, but I think that is not
> the key for this question.
> Anyone can give me suggestion? This is my final project. Your help will be
> greatly appreciated!
>
> sarah
>
Previous Topic:Problem with FileDialog
Next Topic:Problem with SWT_AWT
Goto Forum:
  


Current Time: Tue Apr 16 07:30:53 GMT 2024

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

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

Back to the top