?
Solved

SWT Text : Select part of the text?

Posted on 2011-02-14
10
Medium Priority
?
513 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 500 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 1000 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 500 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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 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