Libgdx, Label doesn't show any text - libgdx

I hope this question is not too trivial, but i can not figure out why the label I have created won't show any text (the label is placed below the settings button):
edit: i am using version 1.9.3
Label currentSong = new Label("test", new Label.LabelStyle(Assets.instance.fonts.defaultSmall,
Color.BLUE));
table.add(currentSong);
if (debugEnabled) layer.debug();
return table;

I tested this code and it works. You might have problems with your font. Is the button texts a image or you are using this font?
One possible problem is that you dispose your font somewhere before using it. So it's all black and you cannot see it because you are using a black background.
Paste all your code here. At least the part you allocate/dispose the font and you create the table, the buttons and this screen...
Some code you should call:
stage.addActor(table); in the show() method.
stage.act(delta);
stage.draw();
In the render() method.
I know you probably called everything correctly, otherwise the table wouldn't apear. So check the font dispose. If you still needs help, we need the source...

Related

Is there a possibility to increase font size of the spark label truncation tip in Flex 4?

I use Spark Label (Flex 4.6 SDK) in my project to show some text on a form and in case when the text does not fit in one line a truncation tip is shown (using maxDisplayedLines="1" and showTruncationTip="true" properties). But the font size in the tip is very small and I want to increase it but actually I have no idea how to do this.
OK so this is doable but not so easy to see how at first.
showTruncationTip tells the label to create a toolTip if isTruncated is true when you mouse over it. So with this knowledge, we can listen for the events that get fired regarding the tooltip being created and do some replacing or stylizing of the toolTip.
private var myTip:IToolTip;
// somewhere in your code
label.addEventListener(ToolTipEvent.TOOL_TIP_SHOWN, createCustomTip);
private function createCustomTip(event:ToolTipEvent):void {
myTip = event.toolTip;
// do stuff to the existing toolTip or replace it with a custom one
}
There is full docs on how to create and replace custom tool tips here Creating Custom Tool Tips
There's a much simpler answer. See this link
http://blog.flexexamples.com/2008/05/22/changing-the-background-color-of-an-error-tip-in-flex/
and observe how they use <mx:Style> tags to modify the default CSS properties for .errorTip.

Text is not displayed when setting the "textFormat" style for a ComboBox control's "textField" property in Flash?

All over the net, it says I should be able to change the fl.controls.ComboBox's style with the following code, which was originally suggested here: http://blogs.adobe.com/pdehaan/2008/03/using_embedded_fonts_with_the_3.html
//assumes combobox is a fl.controls.ComboBox and has been populated and has an item selected; also assumes the Arial font has been properly embedded.
var textFormat:TextFormat = new TextFormat( "Arial", 12 );
combobox.textField.setStyle( "textFormat", textFormat );
combobox.textField.setStyle( "embedFonts", true );
combobox.dropdown.setRendererStyle( "textFormat", textFormat );
combobox.dropdown.setRendererStyle( "embedFonts", embedFonts );
Everything works correctly except the first two lines that call setStyle on the textField property (which is a TextInput component). The drop down's font is updated correctly and displays fine, using the embedded Arial font with whatever size I set, but the ComboBox's main text that displays the selected item's text does NOT work. It displays nothing.
Has anyone else run into this problem or been able to reproduce it?
I worked through the following tutorial and didn't have any issues, please try this:
ComboBox text formatting in AS3
I was having the same problem.
Apparently you need to populate the combobox before applying any styling. I was populating mine from a list in the database, once I moved my styling code into my loader's onComplete handler, it all went good.
Hope this helps

fancy tooltips in Swing

I have a JTable that I would like to display a fancy tooltip (basically a JTextArea) for particular cells in a column. I am using a custom cell renderer, so it would be easy if I could figure out how to popup a window when I hover over the cell renderer's component.
Are there any examples of how to do this?
You can use HTML in tooltips, if you use the <html> and </html> tags around the content.
Use HTML to format the tooltip. Using colored (<font>) and multi-line (<br>) tooltips is now easy.
Creating and overwriting the default JToolTip is a bit harder. Every component has a JToolTip instance and you can retrieve this one with JComponent.createToolTip(). To create a custom tooltip, extend the cell renderer and override it's createToolTip to implement your custom functionality (return a custom extended version of JToolTip).
I'm not sure I totally am clear on what sort of customizations specifically you're hoping to do, so I'll be general here.
There is a class, UIManager, that controls the look and feel of components, including the swing ToolTip class. The simple way to make an easy change is to call a method in UIManager to set properties for the tooltips. Doing this you could do things like use BorderFactory to add a decorative border, or change the background color, etc.
Here are some examples of changing some of these properties:
UIManager.put("ToolTip.background", new ColorUIResource(255, 247, 200)); // The color is #fff7c8.
Border border = BorderFactory.createLineBorder(new Color(76,79,83)); // The color is #4c4f53.
UIManager.put("ToolTip.border", border);
ToolTipManager.sharedInstance().setDismissDelay(15000);// 15 seconds
If you want to change a whole bunch of things about their look and feel, it is better to extend your current look and feel with a class implementing custom tooltip look and feel. A full example of this can be found in this blog post by a former Sun developer.
You might also have a look at this Stack Overflow question on how to set the insets on a tooltip.

Dynamic Background Colour

I'm wondering if someone can shed some light on how this effect is achieved?
This site shows a constant changing background colour.
http://bdw.colorado.edu/#/index.php
I want to utilize the same "ever changing" background colour effect on my site.
Here is the link to my example site:
http://continuous.be/
(I've found the CSS but not sure how it relates? )
/* == Dynamic Colors ==
.dynamicbgcolor {
background-color: rgb(0,149,191); }
.dynamiccolor {
color: rgb(0,149,191); }
*/
You won't be able to do this using CSS alone. As Vladislav says there is a spectrum() function that does the work using javascript and jQuery. Basically:
Store an array of colours.
Use Math.Random randomly pick
one of the stored colours.
Using jQuery.animate() to animate the backgroundColor property of the required element.
On completion of the animation, use jQuery.delay() to call the above function in XX seconds time.
Update
I've had a look at the test you put up. You're missing the closing }); at the end of your script file. Also, you've only defined the function spectrum, you don't call it. Add spectrum(false); at the end of your file, just within the }); that you've just added.
Try using Firebug for firefox, this pointed out the missing }); straight away.
this is done using JavaScript - the script animates the CSS. Look in http://bdw.colorado.edu/js/main.js for function spectrum(bool)
The idea is simple. They load js script to their page. And there (from line 373) you will find necessary code (together with hardcoded background colors.

TextField autoSize+italics cuts of last character

In actionscript 3, my TextField has :
CSS styling
embedded fonts
textAlign : CENTER
autoSize : CENTER
... when italics are used the very right character gets slightly cut off (specially caps).
It basically seems that it fails detecting the right size.
I've had this problem before but just wondered is there a nice workaround (instead of checking textWidth or offsetting text etc.)?
Initialize your textField as you always do, using multiline, autosize, htmlText...
Then do this little trick :
// saving wanted width and height plus 1px to get some space for last char
var savedWidth = myTextField.width + 1;
var savedHeight = myTextField.height + 1;
// removing autoSize, wich is the origin of the problem i think
myTextField.autoSize = "none";
// now manually autoSizing the textField with saved values
myTextField.width = savedWidth;
myTextField.height = savedHeight;
Not that it is much comfort to you, but Flash sometimes has trouble with this seemingly simple task. CSS styling of html TextField was a nice addition but it has caused headaches for text-rendering. In fact I very rarely use CSS for styling text for that reason. I can only imagine that combining bold, italic and normal type faces within the HTML causes Flash to get some of the width calculations wrong which causes autoSize to set the mask a tiny bit short. I hope very much that the new text rendering engine in Flash Player 10 will finally fix these issues (it certainly looks better in theory).
So my solution is never to use HTML with the exception being when I require <a> links in my text ... and there are even some tricky text shifting issues there. In those cases I avoid mixing different font weights and font styles within the same text field. All other cases I use TextFormat directly on TextField.
I suppose if you can't get out of your current architecture (for some reason) you could try adding to the end of your html encoded strings. Or you could manually set the width of the field and not rely on autoSize (as you have mentioned). But if you keep on the CSS/HTML route you may find another new and painful limitation just when you don't want it.
I've had issues with TextField masks behaving differently in the Flash preview, and in the actual browser plugin. Usually, and this is strange to me, it would appear more correctly in the browser. Have you tried running the swf in a browser to see if the problem is actually an annoyance rather than a permanent problem?
I had said this:
My in-ideal approach to solving this is to attach a change event to the TextField which always adds a space after the last character of the field. And then to remember to trim this space off when using the value.
But that didn't take into account that this probably doesn't have a change event and that it's an HTML rendered text field. To add a trailing space in the HTML text field throw in an again, that's not really fixing the problem.