|
Replies:
24
-
Pages:
2
[
Previous |
1
2
]
-
Last Post:
6 Sep 17, 15:49
Last Post By: JeffTucker
|
|
|
Posts:
8,216
Registered:
31-Jan-2006
|
|
|
Re: Repeatable item in JDraggableList()
Posted:
5 Sep 17, 18:04
in response to: davidekholm
|
|
|
Just thinking ahead a bit....
In a UI, let's say that I want to enable/disable some other fields based upon whether a given item is included in the current "used" list. In Minimal, for example, say I want to enable another field only if fileTitle is in the "used" list. What would the statement look like?
|
|
|
Posts:
3,820
Registered:
4-Aug-2006
|
|
|
Re: Repeatable item in JDraggableList()
Posted:
5 Sep 17, 21:54
in response to: davidekholm
|
|
|
Maybe a 'reset' option would be of use too, letting users quickly return the selected list back to the default setting.
Couldn't resist having a go. The attached onload.bsh is modified from the Minimal skin posted above. It offers a reset list, clear all from list and add all to the list.
Nice . I have the feeling we'll be seeing some usage of this component in your skins soon. Also check out the updated .small() method that gets you a visually smaller version of these lists. Just add .small() to the constructor call to try it out.
I was going to update Polyglot skin to use the JDraggableList but I need to find some example code to copy.
In short, I don't know how to take a list of items and use that to populate the draggable list - I have a list of languages (from the skin's texts.properties) e.g the list is "en","se","de" and I want to use that to make the list of items - using setSecondaryList(JDraggableList secondaryList)
I'm guessing.
|
|
|
Posts:
3,820
Registered:
4-Aug-2006
|
|
|
Re: Repeatable item in JDraggableList()
Posted:
6 Sep 17, 10:59
in response to: RobM
|
|
|
I seem to have a working method JDraggableList languageList = new JDraggableList(getSupportedLanguages().toArray(), new String[] { "en" }, false);
where getSupportedLanguages() is a linkedList.
|
|
|
Posts:
3,474
Registered:
18-Oct-2002
|
|
|
Re: Repeatable item in JDraggableList()
Posted:
6 Sep 17, 15:04
in response to: JeffTucker
|
|
|
Just thinking ahead a bit....
In a UI, let's say that I want to enable/disable some other fields based upon whether a given item is included in the current "used" list. In Minimal, for example, say I want to enable another field only if fileTitle is in the "used" list. What would the statement look like?
Here's how: import javax.swing.event.*;
thumbnailItems.getModel().addListDataListener(new ListDataListener() {
void intervalAdded(ListDataEvent e) {
System.out.println("Added " + e);
}
void intervalRemoved(ListDataEvent e) {
System.out.println("Removed " + e);
}
void contentsChanged(ListDataEvent e) {
System.out.println("Changed " + e);
}
});
|
|
|
Posts:
8,216
Registered:
31-Jan-2006
|
|
|
Re: Repeatable item in JDraggableList()
Posted:
6 Sep 17, 15:18
in response to: davidekholm
|
|
|
That's pretty bizarre. I was expecting a more typical StateMonitor() statement, executed upon any change, like: enable(aCheckBox.isSelected(), someotheritem);
Or: enable(aComboBox.getSelectedItem().equals("title"), someotheritem);
Edit: You know, something like: enable(aDraggableList.contains("fileTitle"), someotheritem);
|
|
|
Posts:
3,474
Registered:
18-Oct-2002
|
|
|
Re: Repeatable item in JDraggableList()
Posted:
6 Sep 17, 15:33
in response to: JeffTucker
|
|
|
Just thinking ahead a bit....
In a UI, let's say that I want to enable/disable some other fields based upon whether a given item is included in the current "used" list. In Minimal, for example, say I want to enable another field only if fileTitle is in the "used" list. What would the statement look like?
I should give a better example, but first do a core update to 14.1.12. That version has an updated StateMonitor class that accepts any JList object too (like JDraggableList for instance). Now you can write like this to check the presence of the fileName label: new StateMonitor() {
public void onChange() {
System.out.println("File name present: " +
((DefaultListModel)thumbnailItems.getModel()).contains(new Item("fileName")));
}
}.add(thumbnailItems).done();
|
|
|
Posts:
3,474
Registered:
18-Oct-2002
|
|
|
Re: Repeatable item in JDraggableList()
Posted:
6 Sep 17, 15:41
in response to: davidekholm
|
|
|
I polished JDraggableList further to simplify the coding for you. Do another core update. Now you can write like this: new StateMonitor() {
public void onChange() {
System.out.println("File name present: " +
thumbnailItems.contains(new Item("fileName")));
}
}.add(thumbnailItems).done();
Edited by: davidekholm. Pasted wrong code
|
|
|
Posts:
8,216
Registered:
31-Jan-2006
|
|
|
Re: Repeatable item in JDraggableList()
Posted:
6 Sep 17, 15:49
in response to: davidekholm
|
|
|
The StateMonitor() has proven to be one of the best tools in the box. I use it almost exclusively. There are only a few odd situations when I have to revert to something more basic.
|
|
|
|
Legend
|
|
Forum admins
|
|
Helpful Answer
|
|
Correct Answer
|
|