mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-30 08:23:37 -04:00
placed label at the top of the editing area ind the AttributeDIalog.
This commit is contained in:
parent
9afb828eb5
commit
146813eeb7
@ -81,11 +81,14 @@ public final class EditorFactory {
|
|||||||
*/
|
*/
|
||||||
public static abstract class LabelEditor<T> implements Editor<T> {
|
public static abstract class LabelEditor<T> implements Editor<T> {
|
||||||
private AttributeDialog attributeDialog;
|
private AttributeDialog attributeDialog;
|
||||||
|
private boolean labelAtTop = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addToPanel(JPanel panel, Key key, ElementAttributes elementAttributes, AttributeDialog attributeDialog) {
|
public void addToPanel(JPanel panel, Key key, ElementAttributes elementAttributes, AttributeDialog attributeDialog) {
|
||||||
this.attributeDialog = attributeDialog;
|
this.attributeDialog = attributeDialog;
|
||||||
JLabel label = new JLabel(key.getName() + ": ");
|
JLabel label = new JLabel(key.getName() + ": ");
|
||||||
|
if (labelAtTop)
|
||||||
|
label.setVerticalAlignment(JLabel.TOP);
|
||||||
label.setToolTipText(key.getDescription());
|
label.setToolTipText(key.getDescription());
|
||||||
panel.add(label, DialogLayout.LABEL);
|
panel.add(label, DialogLayout.LABEL);
|
||||||
JComponent component = getComponent(elementAttributes);
|
JComponent component = getComponent(elementAttributes);
|
||||||
@ -107,6 +110,15 @@ public final class EditorFactory {
|
|||||||
* @return the component
|
* @return the component
|
||||||
*/
|
*/
|
||||||
protected abstract JComponent getComponent(ElementAttributes elementAttributes);
|
protected abstract JComponent getComponent(ElementAttributes elementAttributes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the position of the label
|
||||||
|
*
|
||||||
|
* @param labelAtTop if true the label is placed at the top of the editing component.
|
||||||
|
*/
|
||||||
|
public void setLabelAtTop(boolean labelAtTop) {
|
||||||
|
this.labelAtTop = labelAtTop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static class StringEditor extends LabelEditor<String> {
|
private final static class StringEditor extends LabelEditor<String> {
|
||||||
@ -118,6 +130,7 @@ public final class EditorFactory {
|
|||||||
if (key instanceof Key.LongString) {
|
if (key instanceof Key.LongString) {
|
||||||
text = new JTextArea(6, 30);
|
text = new JTextArea(6, 30);
|
||||||
compToAdd = new JScrollPane(text);
|
compToAdd = new JScrollPane(text);
|
||||||
|
setLabelAtTop(true);
|
||||||
} else {
|
} else {
|
||||||
text = new JTextField(10);
|
text = new JTextField(10);
|
||||||
compToAdd = text;
|
compToAdd = text;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user