package org.minimalj.frontend.impl.swing.toolkit;

import javax.swing.JLabel;
import javax.swing.UIManager;

import org.minimalj.frontend.Frontend.Input;

public class SwingReadOnlyTextField extends JLabel implements Input<String> {
	private static final long serialVersionUID = 1L;

	public SwingReadOnlyTextField() {
	}

	@Override
	public void updateUI() {
		super.updateUI();
		setBackground(UIManager.getColor("TextField.background"));
		setOpaque(true);
	}

	@Override
	public void setValue(String text) {
		super.setText(text);
	}

	@Override
	public String getValue() {
		return super.getText();
	}

	@Override
	public void setEditable(boolean editable) {
		// read only field cannot be enabled
	}

	@Override
	public void requestFocus() {
		// read only field cannot be focused
	}
}


@@ -44,16 +44,50 @@
 olkit;%0A%0A
+import javax.swing.BorderFactory;%0A
 import j
@@ -180,16 +180,54 @@
 d.Input;
+%0Aimport org.minimalj.util.StringUtils;
 %0A%0Apublic
@@ -515,96 +515,438 @@
 %09set
-Opaque(true);%0A%09%7D%0A%0A%09@Override%0A%09public void setValue(String text) %7B%0A%09%09super.setText(text);
+Border(BorderFactory.createLineBorder(UIManager.getColor(%22TextField.shadow%22), 1));%0A%09%09setOpaque(true);%0A%09%7D%0A%0A%09@Override%0A%09public void setValue(String string) %7B%0A%09%09if (string != null) %7B%0A%09%09%09if (string.contains(%22%5Cn%22)) %7B%0A%09%09%09%09string = StringUtils.escapeHTML(string);%0A%09%09%09%09string = string.replaceAll(%22%5Cn%22, %22%3Cbr%3E%22);%0A%09%09%09%09setText(%22%3Chtml%3E%3Cbody%3E%22 + string + %22%3C/body%3E%3C/html%3E%22);%0A%09%09%09%7D else %7B%0A%09%09%09%09setText(string);%0A%09%09%09%7D%0A%09%09%7D else %7B%0A%09%09%09setText(null);%0A%09%09%7D
 %0A%09%7D%0A

support multi line