I'm new to Java, Eclipse and the Designer Editor.
I use a class MyTextField that extends JTextFields that lets me set the maxLength and allowedChars of that TextField.
I can create it like this:
- Code: Select all
txtFoo = new MyTextField(100,CHAR_ALL);
// user can enter up to 100 characters
or I could do this:
- Code: Select all
// user can enter up to 30 characters (a-Z0-9-_.@)
txtFoo = new MyTextField();
txtFoo.setMaxLength(30);
txtFoo.setAllowedChars(CHAR_EMAIL);
I have two problems:
1: I can choose the maxLength in the inspector and it will use the setter (setMaxLength). That's great. But when I set it in the sourcecode using the constructor it will not be recognized by the designer. It sometimes mistakes it for the property columns. Why is that so? Other components like JTextField can be created with arguments (e.g. the text) that will be recognized by the designer. How can I tell the designer what will be set by the constructor?
2: Since allowedChars is a String I'd like to use constants (see above) but they can not be selected using the inspector. But it often is possible to choose from constants, e.g. when selecting a color.
Claude