Solved

SWT Text : Select part of the text?

Posted on 2011-02-14
10
505 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 74
bitbucket vs gitbucket 3 57
Java Server Faces parameter pass? 6 37
GUI builder for Eclipse? 8 27
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…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.

914 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now