Hi

I have a problem with look after this sequence in ULC/Swing:
ULCTextField field = ...
JTextField field = ....
..
field.setBackground(Color.yellow);
..
field.setBackground(ClientContext.getColor("TextField.background"));
field.setBackground(UIManager.getDefaults().getColor("TextField.background")
);
..
field.setEditable(false)


In ULC, the field is white as a result of the sequence above
In Swing, the field is gray (default background color of not editable
textfield)

Attached ULC application log of sequence:

background after setBackground(): Color: red = 255, green = 255, blue = 0,
alpha = 255
background after setBackground(): Color: red = 255, green = 255, blue = 255,
alpha = 255
background after setEditable(false): Color: red = 255, green = 255, blue =
255, alpha = 255

Attached Swing application log of sequence:

background after setBackground(): java.awt.Color[r=255,g=255,b=0]
background after setBackground():
javax.swing.plaf.ColorUIResource[r=255,g=255,b=255]
background after setEditable(false):
javax.swing.plaf.ColorUIResource[r=238,g=238,b=238]

how can I achieve the Swing behaviour in ULC?

Regards

Vlado


--------------------------------------------------------------------------
Tato sprava a vsetky pripojene subory su doverne a urcene vyhradne osobam
alebo organizaciam, ktorym boli adresovane. Ak ste dostali tento e-mail
omylom, prosim, upovedomte Chemosvit, a.s. ([EMAIL PROTECTED]).

This email and any files transmitted are confidential and intended
solely for the use of the individual or entity to which they are
addressed. If you have received this email in error, please notify
Chemosvit, a.s. ([EMAIL PROTECTED]).
--------------------------------------------------------------------------- 
import java.io.Serializable;

import com.ulcjava.base.application.AbstractApplication;
import com.ulcjava.base.application.ClientContext;
import com.ulcjava.base.application.ULCBoxPane;
import com.ulcjava.base.application.ULCButton;
import com.ulcjava.base.application.ULCFrame;
import com.ulcjava.base.application.ULCTextField;
import com.ulcjava.base.application.event.ActionEvent;
import com.ulcjava.base.application.event.IActionListener;
import com.ulcjava.base.application.util.Color;

public class TestEditableULCMain extends AbstractApplication implements Serializable {
	private static final long serialVersionUID = 3685352913887556198L;

	public static void main(String[] args) {
		com.ulcjava.base.development.DevelopmentRunner.setApplicationClass(TestEditableULCMain.class);
		com.ulcjava.base.development.DevelopmentRunner.setUseGui(false);
		com.ulcjava.base.development.DevelopmentRunner.run();
	}

	public void start() {
		ULCFrame frame = new ULCFrame();
		frame.setDefaultCloseOperation(ULCFrame.TERMINATE_ON_CLOSE);
		frame.add(createMainPane());
		frame.setSize(600, 400);
		frame.setVisible(true);
	}

	private ULCBoxPane createMainPane() {
		ULCBoxPane mainPane = new ULCBoxPane();
		final ULCTextField field = new ULCTextField(20);
		ULCButton colorBtn = new ULCButton("setBackground");
		colorBtn.addActionListener(new IActionListener() {
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent arg0) {
				if (field.getBackground().equals(ClientContext.getColor("TextField.background"))) {
					field.setBackground(Color.yellow);
				} else {
					field.setBackground(ClientContext.getColor("TextField.background"));
				}
				System.out.println("background after setBackground(): " + field.getBackground());
			}
		});

		ULCButton editableBtn = new ULCButton("setEditable");
		editableBtn.addActionListener(new IActionListener() {
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent arg0) {
				field.setEditable(!field.isEditable());
				System.out.println("background after setEditable(" + field.isEditable() + "): " + field.getBackground());
			}
		});
		mainPane.add(field);
		mainPane.add(editableBtn);
		mainPane.add(colorBtn);
		return mainPane;
	}
}
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;

public class TestEditableSwingMain {

	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(300, 200);
		final JTextField field = new JTextField(20);
		JButton colorBtn = new JButton("setBackground");
		colorBtn.addActionListener(new ActionListener() {
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent e) {
				if (field.getBackground().equals(UIManager.getDefaults().getColor("TextField.background"))) {
					field.setBackground(Color.yellow);
				} else {
					field.setBackground(UIManager.getDefaults().getColor("TextField.background"));
				}
				System.out.println("background after setBackground(): " + field.getBackground());
			}
		});

		JButton editableBtn = new JButton("setEditable");
		editableBtn.addActionListener(new ActionListener() {
			private static final long serialVersionUID = 1L;

			public void actionPerformed(ActionEvent arg0) {
				field.setEditable(!field.isEditable());
				System.out.println("background after setEditable(" + field.isEditable() + "): " + field.getBackground());
			}
		});

		JPanel mainPane = new JPanel(new BorderLayout());
		mainPane.add(field, BorderLayout.NORTH);
		mainPane.add(colorBtn, BorderLayout.CENTER);
		mainPane.add(editableBtn, BorderLayout.SOUTH);

		frame.getContentPane().add(mainPane, BorderLayout.CENTER);
		frame.pack();
		frame.setVisible(true);
	}

}

Reply via email to