Solved

SWT Text : Select part of the text?

Posted on 2011-02-14
10
512 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
Independent Software Vendors: 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 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

728 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