JTree Node Names / Group names are not visible - swing

I've written a JTree with couple of nodes. When I launch the program, I only see the node icons like folder or file and not the names associated with them. I could expand and collapse the nodes. When I debug, I see that the nodes are set with proper data whatever I used while building the model. In this program, i've written wrappers for JTree, TreeModel, DefaultMutableTreeNode. What could be the problem? Any pointers would be of great help.
-Paul

Sorry for not posting more details/code. Anyway, I've found the problem with my code. The problem was that I had overridden the toString() method in the class that I use to set as user object for the tree node, but that was returning null. As the method was returning null, there was nothing displayed. I made it to return the string to be displayed. It is working good now.
Thanks guys..!

Related

getIn() not traversing an Immutable structure

I have an OrderedMap called "firebase" from the immutable-js library which has three leaf nodes:
but then I'd expect to be able to inspect the ordered map at firebase.auth with:
newValue.getIn(['firebase', 'auth'])
But that doesn't work:
Can someone help me understand what I'm doing wrong.
Your auth is an Immutable OrderedMap, but it seems that your firebase is a simple JavaScript object, not an Immutable.js one. Hence why getIn would not work. Thus newValue.get('firebase').auth would suffice.
If you are not using the redux-immutable package then you are probably going to have these (and other) issues due to combineReducers. However, combineReducers created using redux-immutable uses Immutable.js API to iterate the state so check it out.

AS3 accessing variables from timeline from nested MovieClip(s)

EDIT: I figured this problem out on my own, and have included the answer below.
I have a variable in my main timeline called characterDismissed which is a Boolean. I also have a series of nested MovieClips (MovieClips within MovieClips) which look something like: Stage > Container > List > Buttons.
In the Buttons MovieObject at the bottom of the nest I'm trying to output characterDismissed's value just to see if it can see or modify it:
trace("characterDismissed is: " + characterDismissed);
This obviously doesn't work, and I understand why it doesn't work (because characterDismissed is not a variable in the Buttons ActionScript, but rather in the main timeline's ActionScript, so it has no concept of the characterDismissed variable yet.)
How would I go about making this variable accessible to the Buttons MovieClip in AS3? I've tried root.characterDismissed, parent.characterDismissed, this.parent.characterDismissed, even parent.parent.parent.characterDismissed, etc. These always give me some flavor of this error, however:
1119: Access of possibly undefined property characterDismissed through a reference with static type flash.display:DisplayObjectContainer.
I feel like I've been reading suggestions for handling this for days, but nothing is working, and with my understanding of AS3 being limited already, I don't have a proper grasp on the vocabulary to better research it past what I've already searched, or make sense of what typically ends up being a vague response on other forums, or for similar, but not-quite-right questions/answers.
I ended up figuring out the answer on my own, here's what I came up with:
I made a new ActionScript 3.0 Class file and named it GlobalVars (though, you can name it whatever you like.) and saved it into my project directory alongside my main .FLA file. In GlobalVars I made a test variable named testVar, set it to public, and then static.
My understanding for this is that public means anything can modify it, and static means that this variable will be the same value throughout your entire program. That looks like this:
public static var testVar:Number = 1234;
Then in both my Main project AS3, and the nested object's AS3 I added:
import GlobalVars;
This adds the class I made, and any functions or variables I configured within GlobalVariables to my Main AS3 script on the timeline.
Now, I have can access or change my variables in those AS3 scripts by simply prefixing the variable with the class name, like so:
GlobalVars.testVar += 20; // Add 20 to testVar.
Now, as long as I import GlobalVars into my script, I can access, and modify these variables from anywhere.
Hope this helps anybody else out there who found themselves lacking the vocabulary to properly articulate a search on this subject. I have attempted to include as many keywords in my explanation as possible to help people with similar search queries.

Get the loaded instance of the code behind of ResourceDictionary

I've made a resource dictionayry for a user control and create a class that derived from ResourceDictionary that managed different eventsetters and handlers for controls contained in the resource dictionary. So far so good, everything is working fine. My problem is to access members contained in my ResourceDictionary class from the user control. How to access a property in ResouceDictionary object from the user control?
Thanks a lot!
Ben
I finally find a way to handle it. I create a variable of my resourcedictionary type that handle also his events. After, I set the resource dictionary to the control by code with my variable. So now, I can handle events declared in my resource dictionary.
If someone need to see codes needed to get the job done, let me know.

How to implement PropertyDefiner for logback to access multiple properties

I would like to define some properties in my logback.xml config file and saw that by implementing the PropertyDefiner was a great way to set properties in a customizable way.
After starting to implement it I began to wonder how to access the value of the name attribute of the element within the tag. I'm not seeing anyway to do this and I'm scratching my head. Would this PropertyDefiner really make you create a new implementation for every single property? Why not just hard code it? I didn't see much discussion about this out on the web.
I hope I'm just not seeing it and that the brains of stackoverflow can help me out. Does anyone know how to do this? Thanks!
I found this discussion: essentially the same question is asked, but no answer was returned.
fyi: I want to customize how I get my properties because I am pulling it from a database. I have a helper class which pulls the properties in on server startup. These properties vary based on environment (dev, test, prod, etc.)
As of logback version 1.0.6, the value of the name attribute cannot be accessed directly. However, nothing prevents you from passing the value of the name attribute in a property of your choice. Example:
<define name="rootLevel" class="Your.PropertyDefiner">
<myKey>rootLevel</myKey>
</define>
where myKey is a property of Your.PropertyDefiner. For example:
class Your.PropertyDefiner implements PropertyDefiner {
String myKey;
public void setMyKey(String k) {
this.myKey= k;
}
public String getPropertyValue() {
return ...
}
}
Joran, logback's configuration framework, takes care of the wiring. Joran will inject the value of the myKey element into the myKey property of Your.PropertyDefiner. If you are curious about the technical details, see the documentation on implicit actions and implicit actions in practice.

JTreeTable model updating

I'm following the example of JTreeTable filesystem2 taken from the sun site http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html#updating_the
My problem is that I can't update my model (and then my JTreeTable)...
In fact I create my model, I pass it to the JTreeTable and all work fine...but I need to modify the model...
I've yet answer a similar question, but now I've changed my code, without find a solution.
The problem is when and how I have to call the method fireTreeNodesChanged()...in the example above is used the method getPath() to retrieve information about the root node...but this is a method of File class..not my case...
Does anyone have a link to a simple code which shows how create a TreeTabelModel (with objects as nodes) and how update it?
FileBrowser is a good example of modeling a hierarchical file system as a tree. While its TreeModel is implemented using DefaultTreeModel, an alternative FileTreeModel is shown here. As mentioned in How to Use Trees: Creating a Data Model "the TreeModel interface accepts any kind of object as a tree node."