I have a Label which I want to shrink into the space.
In my case I want to write the text in two lines:
2. New Connection
Credentials
I Tested this but the result is not accomplished:
Label lbb = new Label("2. New Connection Credentials");
lbb.setMaxWidth(10);
lbb.setTextOverrun(OverrunStyle.CLIP);
How I can split the string into two lines if the size exceeds 10 letters?
Use lbb.setWrap(true) to activate text wrapping.
Related
I'm using JTextPane because I need to markup text.
When typing into the JtextPane the second word always goes to new line. Then also when making the second word longer (after it went to a new line) the scroll bar appears and the JTextPane resizes. If I start typing in a new row then second word in that line does not go to a new line (as long the second word does not exceed width)
I tried adding a blank string that is very long in the first line and seems to do the trick, but this blank line is not really what I want to have.
Also tried adding it to after the text but it gives more problems
Is there something else that I can do to make the text only go to new line when I press enter? I can do it without a blank string using jtextarea, but then I can't markup text as I type.
I found the answer:
JTextPane textPane = new JTextPane()
{
public boolean getScrollableTracksViewportWidth()
{
return getUI().getPreferredSize(this).width
<= getParent().getSize().width;
}
};
We can overite the getScrollableTracksViewportWidth method to have a no wrapping text pane.
Website for more info: Here
I need to develop an application in C# with two screens, each contains 2 text Areas/Boxes in it.
When user presses the Start button on first screen, the application should start reading the text file ( having some data on each line ) and populate the odd lines in one text area and even lines on other text area parallelly.
Also, there will be a separate screen ( with 2 text areas ) where you will send data from first screen via TCP to fill the 2 text areas based upon the odd/even line #.
Please help me on this.
try this
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\";
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
textbox1.Text = File.ReadAllText(openFileDialog1.FileName);
I have a virtual keyboard created in RealBasic.
When I press letters, numbers I append it to a textfield all its ok but, how do I delete characters from that textfield from current cursor position when I press "Delete" button from virtual keyboard?
To append letters or numbers to the textfields I use:
TextField1.Text = TextField1.text + me.Caption //to append caption
TextField1.SelStart = Len(TextField1.text) // to move cursor at the end of string
Paul's solution works if you only plan to delete the last typed character.
But beware: If you let the user also move the cursor left and right, you have to delete the text at the position of the cursor, of course. And if you also allow the user to select text, then it's even more complicated.
I suggest that your virtual keyboard simply send the typed key to the system as if the user had pressed the key. That way, the TextEdit field will do everything for you.
To make this work, however, you need custom solutions for each OS platform you want to support.
Let me know which platforms you plan to support and I'll see what I can find. I have some code for OSX but not for Windows, yet.
Doing what Thomas said means:
dim n as String = TextField1.Text
n = newText.left(TextField1.selStart) + n.right(n.len - textField1.selStart - 1)
textField1.text = n
Just lop off the last character:
TextField1.Text = TextField1.Text.Left(TextField1.Len-1)
I am creating the SVG text by using the <text> with <tspan> for each line.
The text has many lines and one of them is empty line, some thing like this:
this is text line 1
this is text line 3
the example above is a text with three lines, one of them is empty.
the problem is the SVG text only displays two lines instead of three lines (the first and the end line, without the middle line).
See here: http://jsfiddle.net/svincoll4/DX4Cn/
Anyone have solution about this to make it display three lines?
Note: I am using the Raphael JS to create these text.
By default whitespace is compressed in html and svg so \n\n\n becomes \n. Also if there's no text at all then the middle line is ignored. xml:space="preserve" stops whitespace compression in SVG and and extra space makes the middle line exist.
var $svg = Raphael('container', 400, 400);
var $text = "this is line 1\n \nthis is line 3";
$svg.canvas.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space","preserve");
$svg.text(50, 100, $text);
I was writing a custom chart component where. To add labels, I create a spark label and add it on screen. Although all other labels rendered, I noticed that the zero label does not render at all. Here's my code:
var invisibleTextField:TextField = new TextField();
var zeroLabel:spark.components.Label = new spark.components.Label();
zeroLabel.text = "0";
zeroLabel.name = "0Label";
invisibleTextField.text = " 0 ";
zeroLabel.width = invisibleTextField.textWidth;
zeroLabel.height = invisibleTextField.textHeight;
addChild(zeroLabel);
After multiple attempts, I figure that the label discards "0" as an empty string. I managed to workaround using spaces before and after the zero. Only one space would also do, but I needed center aligning. Anyone has any idea why this happens?
There's a delay between text is filled into a text field and when it's dimensions are updated. Try using TextExtent instead of an invisible text field to do what you're doing.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextExtent.html