Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to do Dialog return a String?
How to do Dialog return a String? [message #448069] |
Thu, 30 December 2004 10:23 |
Eclipse User |
|
|
|
Originally posted by: dicesCAVA.ctonet.it
I must a Dialog with Text field who return text in field if click ok.
How i can do that?
I wrote:
public class Question extends MessageDialog {
public Question(Shell parentShell, String dialogTitle,Image
dialogTitleImage, String dialogMessage, int dialogImageType,String[]
dialogButtonLabels, int defaultIndex,String text) {
super(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
dialogImageType, dialogButtonLabels, defaultIndex);
this.mess=text;
// TODO Auto-generated constructor stub
}
private Text text=null;
private String mess=null;
public static String show(Shell parent, String title,String message){
Question q=new Question(parent, title, null,message, QUESTION, new
String[]{IDialogConstants.YES_LABEL,IDialogConstants.NO_LABE L}, 0,"");
if(q.open()==0)
return q.text.getText();
return "";
}
protected Control createMessageArea(Composite composite) {
text = new Text(composite, SWT.SINGLE);
text.setText(mess);
GridData data=new GridData(
GridData.HORIZONTAL_ALIGN_CENTER
| GridData.VERTICAL_ALIGN_BEGINNING);
data.widthHint =
convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSA GE_AREA_WIDTH);
text.setLayoutData(data);
return super.createMessageArea(composite);
}
}
but is wrong, help me.
(Sorry for my spaghetti English)
|
|
|
Re: How to do Dialog return a String? [message #448087 is a reply to message #448069] |
Thu, 30 December 2004 23:24 |
Daniel Spiewak Messages: 263 Registered: July 2009 |
Senior Member |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="serif">Use the following form:<br>
<br>
public class MyDialog extends Dialog {<br>
private Shell shell;<br>
<br>
public MyDialog(Shell parent) {<br>
shell = new Shell(parent, SWT.DIALOG_TRIM);<br>
}<br>
<br>
public String open() {<br>
shell.open();<br>
<br>
// etc<br>
}<br>
}<br>
</font><br>
SaThot wrote:
<blockquote cite="midopsjtgh8mv5horlisaDjehwty@djehwty.mes" type="cite">I
must a Dialog with Text field who return text in field if click ok.
<br>
How i can do that?
<br>
I wrote:
<br>
<br>
public class Question extends MessageDialog {
<br>
<br>
public Question(Shell parentShell, String dialogTitle,Image
dialogTitleImage, String dialogMessage, int dialogImageType,String[]
dialogButtonLabels, int defaultIndex,String text) {
<br>
super(parentShell, dialogTitle, dialogTitleImage,
dialogMessage,
<br>
dialogImageType, dialogButtonLabels, defaultIndex);
<br>
this.mess=text;
<br>
// TODO Auto-generated constructor stub
<br>
}
<br>
<br>
private Text text=null;
<br>
private String mess=null;
<br>
<br>
public static String show(Shell parent, String title,String
message){
<br>
Question q=new Question(parent, title, null,message, QUESTION,
new String[]{IDialogConstants.YES_LABEL,IDialogConstants.NO_LABE L},
0,"");
<br>
if(q.open()==0)
<br>
return q.text.getText();
<br>
return "";
<br>
}
<br>
<br>
protected Control createMessageArea(Composite composite) {
<br>
<br>
text = new Text(composite, SWT.SINGLE);
<br>
text.setText(mess);
<br>
GridData data=new GridData(
<br>
GridData.HORIZONTAL_ALIGN_CENTER
<br>
| GridData.VERTICAL_ALIGN_BEGINNING);
<br>
data.widthHint =
convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSA GE_AREA_WIDTH);
<br>
text.setLayoutData(data);
<br>
return super.createMessageArea(composite);
<br>
}
<br>
}
<br>
<br>
but is wrong, help me.
<br>
(Sorry for my spaghetti English)
<br>
</blockquote>
</body>
</html>
|
|
|
Goto Forum:
Current Time: Thu Apr 25 22:12:50 GMT 2024
Powered by FUDForum. Page generated in 0.03411 seconds
|