void userNameWin(Shell ParentShell) { GPFlag = false; Shell SubShell = new Shell(ParentShell.getDisplay()); GridLayout SubShellGL = new GridLayout(); SubShell.setLayout(SubShellGL); SubShellGL.numColumns = 2; SubShellGL.makeColumnsEqualWidth = true; String UserName = ""; Label UserNameLab; Text UserNameInp; Button ApplyBut, CancelBut; UserNameLab = new Label(SubShell, SWT.NORMAL | SWT.CENTER); UserNameLab.setLayoutData(new GridData()); UserNameLab.setText("Your User Name:"); UserNameInp = new Text(SubShell, SWT.SINGLE | SWT.BORDER); UserNameInp.setLayoutData(new GridData()); ApplyBut = new Button(SubShell, SWT.PUSH); ApplyBut.setLayoutData(new GridData()); ApplyBut.setText("Apply"); ApplyBut.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent Evt) { if (confirmWin( ((Button) Evt.widget).getShell(), "Are you sure you want to save changes?", JTC.YESNO) == true) { GPFlag = true; } } }); CancelBut = new Button(SubShell, SWT.PUSH); CancelBut.setLayoutData(new GridData()); CancelBut.setText("Cancel"); CancelBut.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent Evt) { ((Button) Evt.widget).getShell().dispose(); } }); if (UserProfile == JTC.SERVER) { UserNameInp.setText(MainServer.getLocalUserName()); } else if (UserProfile == JTC.CLIENT) { UserNameInp.setText(MainClient.getLocalUserName()); } SubShell.pack(); SubShell.setLocation(centralize(ParentShell.getBounds(), SubShell)); SubShell.open(); while (!SubShell.isDisposed()) { if (!SubShell.getDisplay().readAndDispatch()) SubShell.getDisplay().sleep(); if (GPFlag == true) { UserName = UserNameInp.getText(); SubShell.dispose(); } } if (GPFlag == true) { if (UserProfile == JTC.SERVER) { if (MainServer.setLocalUserName(UserName)) MainShell.setText("JeremeTalk v1.0 : Welcome " + UserName + " | You are " + UserProfile); } else if (UserProfile == JTC.CLIENT) { if (MainClient.setLocalUserName(UserName)) MainShell.setText("JeremeTalk v1.0 : Welcome " + UserName + " | You are " + UserProfile); } } }