Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problems with Text control
Problems with Text control [message #432867] Tue, 30 March 2004 12:04 Go to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

I want to create a multiline Text control using the native Text widget.
The problem with the above snippet is that I cannot introduce more than 7
lines of text.
Well, in the examples provided by Eclipse (ControlExample) the Text control
created with SWT.MULTI it has'nt this limitation.
What is wrong in my snippet ?


import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;

/**
* @author Robert Bacs
*/
public class XTableTest {
public static void main(String []args){
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout());

Group textGroup = new Group (shell, SWT.NULL);
textGroup.setLayout (new GridLayout ());
textGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL |
GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
textGroup.setText ("Text");

Text text = new Text(textGroup, SWT.MULTI);
int size = 100;
GridData gridData = new GridData ();
gridData.widthHint = size;
gridData.heightHint = size;
text.setLayoutData(gridData);
text.setText("Multiline\nText\ncontrol");

shell.pack();
shell.open();

while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Re: Problems with Text control [message #432935 is a reply to message #432867] Tue, 30 March 2004 14:16 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
1) Give it a vertical scroll bar using SWT.V_SCROLL (in SWT 2.1.x)
2) The problem has already been worked around in SWT 3.0 (SWT.V_SCROLL
should not be necessary but it's not harmful).

"Robert Bacs" <boby@zerosoft.ro> wrote in message
news:c4bms6$9qe$1@eclipse.org...
> Hi,
>
> I want to create a multiline Text control using the native Text widget.
> The problem with the above snippet is that I cannot introduce more than 7
> lines of text.
> Well, in the examples provided by Eclipse (ControlExample) the Text
control
> created with SWT.MULTI it has'nt this limitation.
> What is wrong in my snippet ?
>
>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.widgets.*;
>
> /**
> * @author Robert Bacs
> */
> public class XTableTest {
> public static void main(String []args){
> final Display display = new Display();
> final Shell shell = new Shell(display);
> shell.setLayout(new GridLayout());
>
> Group textGroup = new Group (shell, SWT.NULL);
> textGroup.setLayout (new GridLayout ());
> textGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL |
> GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
> textGroup.setText ("Text");
>
> Text text = new Text(textGroup, SWT.MULTI);
> int size = 100;
> GridData gridData = new GridData ();
> gridData.widthHint = size;
> gridData.heightHint = size;
> text.setLayoutData(gridData);
> text.setText("Multiline\nText\ncontrol");
>
> shell.pack();
> shell.open();
>
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
> }
> }
>
>
>
Re: Problems with Text control [message #432944 is a reply to message #432935] Tue, 30 March 2004 15:30 Go to previous messageGo to next message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

Yes, I know that, but in the ControlExample it's working without
SWT.V_SCROLL and I'm runninng with the same SWT version both example
(ControlExample and my snippet).
What is the difference between my snippet and the example provided by
ControlExample ?
Because, I do not see any !

Best regards,
Boby


"Steve Northover" <steve_northover@ca.ibm.com> wrote in message
news:c4bv5u$lh4$1@eclipse.org...
> 1) Give it a vertical scroll bar using SWT.V_SCROLL (in SWT 2.1.x)
> 2) The problem has already been worked around in SWT 3.0 (SWT.V_SCROLL
> should not be necessary but it's not harmful).
>
> "Robert Bacs" <boby@zerosoft.ro> wrote in message
> news:c4bms6$9qe$1@eclipse.org...
> > Hi,
> >
> > I want to create a multiline Text control using the native Text widget.
> > The problem with the above snippet is that I cannot introduce more than
7
> > lines of text.
> > Well, in the examples provided by Eclipse (ControlExample) the Text
> control
> > created with SWT.MULTI it has'nt this limitation.
> > What is wrong in my snippet ?
> >
> >
> > import org.eclipse.swt.SWT;
> > import org.eclipse.swt.layout.*;
> > import org.eclipse.swt.widgets.*;
> >
> > /**
> > * @author Robert Bacs
> > */
> > public class XTableTest {
> > public static void main(String []args){
> > final Display display = new Display();
> > final Shell shell = new Shell(display);
> > shell.setLayout(new GridLayout());
> >
> > Group textGroup = new Group (shell, SWT.NULL);
> > textGroup.setLayout (new GridLayout ());
> > textGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL |
> > GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
> > textGroup.setText ("Text");
> >
> > Text text = new Text(textGroup, SWT.MULTI);
> > int size = 100;
> > GridData gridData = new GridData ();
> > gridData.widthHint = size;
> > gridData.heightHint = size;
> > text.setLayoutData(gridData);
> > text.setText("Multiline\nText\ncontrol");
> >
> > shell.pack();
> > shell.open();
> >
> > while (!shell.isDisposed ()) {
> > if (!display.readAndDispatch ()) display.sleep ();
> > }
> > display.dispose ();
> > }
> > }
> >
> >
> >
>
>
Re: Problems with Text control [message #433000 is a reply to message #432944] Wed, 31 March 2004 13:46 Go to previous message
Robert Bacs is currently offline Robert BacsFriend
Messages: 165
Registered: July 2009
Senior Member
Hi,

I found the difference: in the Java build path I have two version of swt.jar
:).

Best regards,
Boby

"Robert Bacs" <boby@zerosoft.ro> wrote in message
news:c4c2ua$r78$1@eclipse.org...
> Hi,
>
> Yes, I know that, but in the ControlExample it's working without
> SWT.V_SCROLL and I'm runninng with the same SWT version both example
> (ControlExample and my snippet).
> What is the difference between my snippet and the example provided by
> ControlExample ?
> Because, I do not see any !
>
> Best regards,
> Boby
>
>
> "Steve Northover" <steve_northover@ca.ibm.com> wrote in message
> news:c4bv5u$lh4$1@eclipse.org...
> > 1) Give it a vertical scroll bar using SWT.V_SCROLL (in SWT 2.1.x)
> > 2) The problem has already been worked around in SWT 3.0 (SWT.V_SCROLL
> > should not be necessary but it's not harmful).
> >
> > "Robert Bacs" <boby@zerosoft.ro> wrote in message
> > news:c4bms6$9qe$1@eclipse.org...
> > > Hi,
> > >
> > > I want to create a multiline Text control using the native Text
widget.
> > > The problem with the above snippet is that I cannot introduce more
than
> 7
> > > lines of text.
> > > Well, in the examples provided by Eclipse (ControlExample) the Text
> > control
> > > created with SWT.MULTI it has'nt this limitation.
> > > What is wrong in my snippet ?
> > >
> > >
> > > import org.eclipse.swt.SWT;
> > > import org.eclipse.swt.layout.*;
> > > import org.eclipse.swt.widgets.*;
> > >
> > > /**
> > > * @author Robert Bacs
> > > */
> > > public class XTableTest {
> > > public static void main(String []args){
> > > final Display display = new Display();
> > > final Shell shell = new Shell(display);
> > > shell.setLayout(new GridLayout());
> > >
> > > Group textGroup = new Group (shell, SWT.NULL);
> > > textGroup.setLayout (new GridLayout ());
> > > textGroup.setLayoutData (new GridData (GridData.GRAB_HORIZONTAL |
> > > GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL));
> > > textGroup.setText ("Text");
> > >
> > > Text text = new Text(textGroup, SWT.MULTI);
> > > int size = 100;
> > > GridData gridData = new GridData ();
> > > gridData.widthHint = size;
> > > gridData.heightHint = size;
> > > text.setLayoutData(gridData);
> > > text.setText("Multiline\nText\ncontrol");
> > >
> > > shell.pack();
> > > shell.open();
> > >
> > > while (!shell.isDisposed ()) {
> > > if (!display.readAndDispatch ()) display.sleep ();
> > > }
> > > display.dispose ();
> > > }
> > > }
> > >
> > >
> > >
> >
> >
>
>
Previous Topic:Native Window ID using SWT/GTK/Linux
Next Topic:Programming Model of SWT.
Goto Forum:
  


Current Time: Tue Apr 23 17:09:36 GMT 2024

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

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

Back to the top