I've a linkedhashmap that I put into Properties file, and it shows the fields in the menu. I've an others color option and I want it to be seen at the end.
So colormap is my linkedhashmap and I put others the end. So when I look inside colormap, last element is Others. But changes when I put it in properties file.
My code is like this:
colormap.put("Others",Color.GRAY);
Properties prop = new Properties();
prop.putAll(colormap);
And order changes inside prop. Do you have any idea how to solve this problem?
The java.util.Properties type inherits from java.util.Hashtable and there is no guarantee that the table will retain its order even after you've loaded the properties.
to fix that you can use OrderedProperties
Related
I am currently trying to create a custom UINavigationBar Subclass.
What i want to achieve is that all custom navigationbars inside my app should have a couple of barbuttonitems in common. But it should still be possible to define left or .rightbarItems on the navigationItem in code.
What i tried so far is that subclassed the UINavigationBar and played around with all methods and delegate callbacks i could potentially use to change the navigationItem. There are methods like
setItems:animated:
setItems:
navigationBar:didPushitem etc.
.. which could be used to modify the navigationItem somehow.
But there is no callback which can be used to change the item initially.
What i basically want to know is how it is possible to change navigationItem initially before it is being pushed ?
Solved it by myself using
willShowViewController of the UINavigationControllerDelegateProtocol
to modify the navigationItem
In gwt how to get a widget's default style(CSS Selector).For example, gwt button has style name "gwt-button" which is referenced in gwt theme css file.
How to got that programmatically.
Is there any,
DOM.getStyleAttribute();
to accomplish this. GWT experts please help.
In your example of button (or any object that is a child of UIObject) can call getStyleName()
UIObject documentation
String com.google.gwt.user.client.ui.UIObject.getStyleName()
Gets all of the object's style names, as a space-separated list. If you wish to retrieve only the primary style name, call getStylePrimaryName().
Now as to why you need this information is the real question. It is my guess that you want to change the styling of an object (add or remove). This would best be done by either of the following methods.
1) Supplying a custom resources file to the object that has your styling
2) creating a class that extends Composite and create a custom UIBinder class with all of your styles within it.
When dynamically adding an element to the DOM, is it possible to add a binding to it?
var element = $('#div1').after('<span></span>');
element.data("name", ???); // create binding equivalent to data-name="{{Name}}"
I know that I could use ractive.observe() to watch changes to the keypath and update the element accordingly, but the binding syntax is more concise so I'm hoping I can still leverage it.
Here's a JSFiddle that shows how I'm using ractive.observe().
I have a QGraphicsLinearLayout with a series of QGraphicsWidgets within. I can hide the widgets just fine, but the layout spaces out all of the remaining widgets as if the hidden ones are still visible. How can I get the layout to use this space?
My code is something like this:
//scene is a QGraphicsScene*, myWidget# inherits QGraphicsWidget
scene->addItem(myWidget1);
layout->addItem(myWidget1);
scene->addItem(myWidget2);
layout->addItem(myWidget2)
scene->addItem(myWidget3);
layout->addItem(myWidget3)
//then later, I call
myWidget2->hide();
But although myWidget2 is now invisible, the layout is still spaced as though it were there. How can I change that?
Thanks.
Try calling QGraphicsLinearLayout::invalidate() to clear any cached geometry information after hiding the widget. If that doesn't help I would assume that removing the widget from the layout (if that is feasible for you) should do it.
I think you are loking for QWidget::findChild<T>(Qstring name)
name - an object name which can be set with QObject::setObjectName(Qstring name)
T - is a type of an object you are loking for.
so in your case code should look like:
MyWidget* myWidget1 = new MyWidget(this);
myWidget1->setObjectName("myWidget1");
........
MyWidget* requiredWidget=scene->findChild<MyWidget*>("myWidget1");
Flex 3 question:
I trying here to avoid having to bind resources to all my components labels ( ie a button) and find a way to have this automated.
Problem:
It corrupts the layout in design mode to bind directly in the mxml label="{resourceManager.getString('myResources', 'submit')}" and makes the design view useless. but when declaring bindings elsewhere, in actionScript or via a bind tag, it is counter productive and prone to many errors and miss.
Proposition:
I would like to create my own button that automatically invoke resources to localize a button label. So the author puts "Submit" in the mxml description of my button, and when running it would take the value of the label ie "submit" and use resourceManager.getString('myResources', 'submit').
but I can't find the way to override the set label function, Is it possible if yes how? else how can I go about it?
Maybe I am missing an essential process here that would make the use of resources more elegant, as well as how to override such thing as a button's label.
Thanks for your advices.
Create a component called MyButton, extending Button. Then use this:
override public function set label(value:String):void {
super.label = resourceManager.getString('myResources', value) || value;
}
Assuming the resource manager returns "null" or "undefined" this will work, and will only replace the value if it exists in "myResources".
If you don't want to override every component you need to do this with, then you can add a FlexEvent.CREATION_COMPLETE event on every component. Then use a single generic function to do your label localization.