Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Text Field Display

 
deepa anandan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Created a class MessageDisplay

public class MessageDisplay extends Window{
private IWorkbenchWindow window;
Text t;

MessageDisplay(Shell parent){
super(parent);
t=new Text(parent.getShell(),SWT.SINGLE | SWT.BORDER);

}

public static void createForm(Shell parent, String title){

MessageDisplay md=new MessageDisplay(parent);

md.open();



}


}

When the application [MessageDisplay.createForm(window.getShell(),"hi")] is run its only a window that is being displayed but no testbox appears though it has been added.

Please let me know where it has gone wrong.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Swing/AWT forum.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please use code tags to post code; it makes it easier to read.
Have you actually added the Text object? It has been created, but I can't seem to see you adding it.
 
deepa anandan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
t=new Text(parent.getShell(),SWT.SINGLE | SWT.BORDER);

Does it not add the Text object??
If I am wrong please correct me and pls do specify how to add the Text object.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it creates the object, but you have to add it specifically. You use the add() calls so you can decide where to locate your object. Otherwise they might be put in the wrong position, or even on the wrong component.

Go through the API specifications, find the Window class and look through to find methods to add. (Hint ctrl-F may help .)

Do you really mean to use Window as a container rather than JFrame? Remember a Window has no border or toolbar or close button or anything.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic