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
Solved

SWT Text : Select part of the text?

Posted on 2011-02-14
10
509 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference of if loops 23 62
Convert from a json string array to a Java object 3 53
Problem to Alipay 10 44
Eclipse Help Java EE 5,6,7 Documentation, why not Java EE 8 8 30
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

828 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