From 146813eeb7cbe7d7d0329c5af08918f964809e42 Mon Sep 17 00:00:00 2001 From: hneemann Date: Mon, 31 Oct 2016 08:46:16 +0100 Subject: [PATCH] placed label at the top of the editing area ind the AttributeDIalog. --- .../digital/gui/components/EditorFactory.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/de/neemann/digital/gui/components/EditorFactory.java b/src/main/java/de/neemann/digital/gui/components/EditorFactory.java index 1b6b0e1c9..ce2cd6fea 100644 --- a/src/main/java/de/neemann/digital/gui/components/EditorFactory.java +++ b/src/main/java/de/neemann/digital/gui/components/EditorFactory.java @@ -81,11 +81,14 @@ public final class EditorFactory { */ public static abstract class LabelEditor implements Editor { private AttributeDialog attributeDialog; + private boolean labelAtTop = false; @Override public void addToPanel(JPanel panel, Key key, ElementAttributes elementAttributes, AttributeDialog attributeDialog) { this.attributeDialog = attributeDialog; JLabel label = new JLabel(key.getName() + ": "); + if (labelAtTop) + label.setVerticalAlignment(JLabel.TOP); label.setToolTipText(key.getDescription()); panel.add(label, DialogLayout.LABEL); JComponent component = getComponent(elementAttributes); @@ -107,6 +110,15 @@ public final class EditorFactory { * @return the component */ 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 { @@ -118,6 +130,7 @@ public final class EditorFactory { if (key instanceof Key.LongString) { text = new JTextArea(6, 30); compToAdd = new JScrollPane(text); + setLabelAtTop(true); } else { text = new JTextField(10); compToAdd = text;