Solved

SWT Text : Select part of the text?

Posted on 2011-02-14
10
507 Views
Last Modified: 2012-05-11
I have a textbox which I want to select the last two characters of.

So for example:

88.00

I would like to select the 00 only.

Thanks
0
Comment
Question by:directxBOB
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 26

Expert Comment

by:ksivananth
ID: 34886754
in swings,

textField.select( 3, 4 ) ;
0
 

Author Comment

by:directxBOB
ID: 34886892
I don't seem to have a select option. I have selectAll, setSelection
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 34886896
what are the params for setSelection?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:directxBOB
ID: 34886921
int Start
Point selection
int Start, int End

I've tried

control.setSelection(0, t.length());
0
 
LVL 26

Accepted Solution

by:
ksivananth earned 125 total points
ID: 34887085
try

control.setSelection(t.length() - 3, t.length() - 1 );
0
 

Author Comment

by:directxBOB
ID: 34887471
That doesn't appear to have done anything

It could be a timing issue, but  not really sure.
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 250 total points
ID: 34890543
With Text components
it actually does selection either selectAll(), or with like setSelection(2,4) , so that you can then get selected text later correctly,
but it does not show it.
If you want selection to be shown use
StyledText components insted of Text components.
Those will show selected text in blue - and you can of course change how it shows selection.
0
 
LVL 92

Assisted Solution

by:objects
objects earned 125 total points
ID: 34892043
it should be setSelection(3,5)
does selectAll() show it selected?
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 250 total points
ID: 34892262
At least for me it does not show selection - neither selectAll, nor setSelection(..)
Only wheh I changed to StyledText did it start showing
When I retrieve getSelection - it still retrieves seletced part from both

0
 

Author Closing Comment

by:directxBOB
ID: 35279124
For some reason my application simply was not allowing any of these selects to work. The application has been scrapped and onto another one now... sorry about not getting back, work has been insane.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 88
even odd program using while loop 3 40
servlet filter example 37 59
Facing this issue for maven proxy setting 2 10
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question