Is it possible to access the selected value of one swing component from inside another swing component?
Hallo community,
I am working on a project and need to access the values of one JComboBox from Inside the second JComboBox. I have two JComboBoxes in my root editor concept. The data of the second JComboBox is depending on the selected value of the first JCombox. Is there anyway to access the selected value of first JCombox from Inside the second JComboBox?
Please sign in to leave a comment.
Yes, it is.
At first, you need to get EditorCell of a node that contains a swing component.
For example: EditorCell editorCell = editorComponent.findModeCell(node)
Then you can use some util method like this:
public virtual JComponent getComponent(EditorCell editorCell) {
JComponent jcomponent = null;
if (inputCell instanceof EditorCell_Collection) {
for (EditorCell cell : inputCell as EditorCell_Collection.getContentCells()) {
jcomponent = getComponent(cell);
if (jcomponent != null) { break; }
}
} else if (inputCell instanceof EditorCell_Component) {
jcomponent = inputCell as EditorCell_Component.getComponent();
}
return jcomponent;
}
And then you can get what you need from this JComponent.
Hello Slavastap,
Thank you very much for the comment. I really appreciate it. I have started to work with MPS since a Month, that is why I need a little bit more information. I have just one Concept, which is also the root concept and was not able to write this code in Inspector area of the second JComboBox in Editor Concept of root concept.
Hello Gholamfaruqmajidi,
You need somehow to obtain current EditorComponent. For example: