Create scrolling text when text is too long - css

I have a dynamically built string that is sometimes too long, but still needs to be displayed fully to the user. I would much rather have the text scroll than creating a tooltip for it.
I have creating a label with this:
Label text = new Label("hello there i hope this text is long enough to take up space");
TranslateTransition tran = new TranslateTransition(Duration.millis(75000));
tran.setNode(text);
tran.setByX(-400);
tran.setInterpolator(Interpolator.LINEAR);
tran.setCycleCount(Timeline.INDEFINITE);
// add the text
tran.play();
One, when I do this, if the text is "this is really long" and it's shortened to "this is really..." then when the label scrolls, the text remains "this is really...". Another thing is this scrolls the label away, changing the x position of the element. Is there a way to just change the text will a scroll instance?
Also, is there a way to programatically determine if a given text is going to be too large for a specified area?

The most simplest method could be "marquee":
http://www.quackit.com/html/codes/html_marquee_code.cfm
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/marquee
http://www.sitepoint.com/web-foundations/marquee-html-element/
But it´s nonstandard: http://www.w3.org/TR/css3-marquee/
A better method is CSS3: http://www.hongkiat.com/blog/css3-animation-advanced-marquee/

Related

How can I dedicate space to a label inside my component?

I have a textfield component with a label for errormessages. Whenever a errormessage appears, it missplaces the field with the error.
Is there anyway to preallocate the space needed for the errormessages?
Put your text label inside div with fixed height or width. Your space will always be there, and you show your text based on your error.

Vertical layout of the icon and text in a JMenu

I try to find a way to place the icon of a JMenu above its text. I've seen the method setComponentOrientation(..), but it influences only the horizontal order of the icon and the text (icon on the left side, text on the right - or the opposite). Is there any possibility to place these parts of a JMenu vertically (icon on the top, text under the icon)?
I'm not sure if you are fully able to do that. Maybe this page can help you out. http://www.java-forums.org/awt-swing/36112-adding-jpanel-jmenu-focus-issues.html I have never really tried adding an image onto a JMenu vertically. You could always try using a JPanel, and adding the JMenu into it, and then setting the layout of the JPanel as a BoxLayout
JLabel imageForIcon = new JLabel(// image path );
JPanel p = new JPanel(imageForIcon);
JMenu m = new JMenu(p);
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
I am not sure if this would work, but it seems as it could possibly be an option to consider.

text display starting from bottom up qt

How would I display text in something like QTextEdit starting from bottom up? QTextEdit starts writing at the top filling down to bottom. I want to start from the bottom and then pushing the previous text up as more text is added. I figure I could hack it and simply fill the field with nextlines to reach the bottom then reprinting whatever was written before again when text is to be added, but I wouldn't want to do that unless there isn't any other way.
insertPlainText inserts text at the current text position. You could move the cursor to the start of the docuement using the moveCursor function.
Every time you want to add some text do the following:
textEdit->moveCursor(QTextCursor::Start);
textEdit->insertPlainText(textToBeAdded);

Scrolling Spark Label

I am using a Spark Label component to display some text. The label has a set width and height. I am updating the text externally to give the impression text is being typed into it. When I give it the following text:
fredFlintstone#yahoo.com
It shows only the beginning of the text like this:
fredFlintstone#yah
I would like to to show the end of the text like this:
tone#yahoo.com
There are no apparent settings in the .setStyle() call.
take care,
lee

what property should i set to Fit the text in label

I want to display a big string in a Qlablel for this I simply have created a label in the Qt GUI editor.
Then set the string with the Wordwrap property to "ON".
Here text is not coming to the next line itself. Instead, it's crossing the view region.
However, if I give an "\n" it works well.
How do I put up the big string in a label to display in a visible region?
label->setWordWrap(true);
See the QLabel::setWordWrap(bool on) documentation.

Resources