Show selected items in StringSelectionEditor (As list in {})

This commit is contained in:
Fabian Becker
2015-12-16 19:51:53 +01:00
parent 2fb7d4cdcc
commit e1ee1c175b
3 changed files with 62 additions and 7 deletions

View File

@@ -12,7 +12,7 @@ import java.beans.PropertyEditor;
/**
*/
public abstract class AbstractListSelectionEditor extends JPanel implements PropertyEditor, PropertyChangeListener {
public abstract class AbstractListSelectionEditor implements PropertyEditor, PropertyChangeListener {
/**
* Handles property change notification
@@ -192,7 +192,10 @@ public abstract class AbstractListSelectionEditor extends JPanel implements Prop
public void paintValue(Graphics gfx, Rectangle box) {
FontMetrics fm = gfx.getFontMetrics();
int vpad = (box.height - fm.getAscent()) / 2;
String rep = "Select from list";
String rep;
if ((rep = getAsText()) == null) {
rep = "Select from list";
}
gfx.drawString(rep, 2, fm.getHeight() + vpad - 3);
}

View File

@@ -53,13 +53,12 @@ public class StringSelectionEditor extends AbstractListSelectionEditor {
}
}
@Override
public String getName() {
return "StringSelection";
}
@Override
public String getAsText() {
if (getElementCount() == 0) {
return null;
}
StringBuilder sbuf = new StringBuilder("{");
boolean first = true;
for (int i = 0; i < getElementCount(); i++) {