ElegantJ Beans – Entry Masks Programmers Guide
ElegantJBeans – Entry Masks
Programmers’ Guide
Table of Content
5 Installation
and Registration
5.4.2 Using with Graphical User Interface
of IDE
5.4.3 Using directly with source code
6.1.1.1 Creating an instance of EditMask
6.1.1.2 Setting general formatting attributes
6.1.1.4 Configuring mask pattern
6.1.1.5 Configuring include characters and
exclude characters
6.1.1.7 Configuring decimal points, digits
after decimal point and minus sign
6.1.1.8 Configuring minimum and maximum range
6.1.1.9 Implementing cut, copy and paste
functionality
6.1.1.10 Configuring selection,
selection background, and selection foreground
6.1.1.11 Configuring disabled
background and foreground
6.1.1.12 Configuring double
buffering
6.1.1.13 Configuring caret color
and caret blink rate
6.1.1.14 EditMask
events/listeners
6.1.2.1 Creating an instance of DateBox
6.1.2.2 Setting formatting attributes
6.1.2.3 Configuring date format
6.1.2.4 Configuring separator char
6.1.2.5 Configuring popup size
6.1.2.6 Configuring how arrows will appear
6.1.2.7 Configuring popup calendar look and
feel
6.1.3.1 Creating an instance of DateMask
6.1.3.2 Setting formatting attributes
6.1.3.3 Configuring mask pattern
6.1.3.4 Configuring week day properties
6.1.3.5 Configuring separator character
6.1.3.6 Enabling spinning of date
6.1.3.7 Configuring caret color
6.1.4.1 Creating an instance of TimeMask
6.1.4.2 Setting formatting attributes
6.1.4.4 Configuring separator character and
caret color
6.1.4.5 Configuring mask spinning
7 Product
and Support Information
This preface describes the document. The preface contains the following sections:
|
Section |
Page |
|
Purpose of this document |
4 |
|
Assumptions |
4 |
|
Document Organization |
4 |
|
Conventions Used |
5 |
The purpose of this document is to provide the fundamental skills necessary to productively install, program, integrate, and use the ElegantJ EntryMasks. This document provides both programmer and user perspective to the audience.
This manual assumes that readers are having reasonable level of exposure to fundamentals of Java programming and various architectures.
This document is organized as described in following tables.
Table 1 – Organization of the document
|
Chapter |
Contents |
|
About ElegantJ
EntryMasks |
Ø What’s new Ø Toolkit |
|
Features |
Ø ElegantJ Edit Mask Ø ElegantJ Date Box Ø ElegantJ Date Mask Ø ElegantJ Time Mask |
|
Product
demo |
Ø Installing demo Ø View demo |
|
Installation
and Registration |
Ø Prerequisite Ø Installation Procedure Ø Using with Different IDEs Ø Getting Registered |
|
Programmers’
Guide |
Ø Core components and definitions for different entry masks Ø Programmer's guide to frequently asked questions |
|
File |
Italic (slanted) type indicates variable values, instruction operands. |
|
[ | ] |
In syntax definitions, brackets indicate items that are optional and braces indicate items that are required. Vertical bars separating items inside brackets or braces indicate that you choose one item from among those listed. |
|
. . . |
In syntax definitions, a horizontal ellipsis indicates that the preceding item can be repeated one or more times. |
|
Get(1) |
A cross-reference to a reference page includes the appropriate section number in parentheses. For example, get(1) indicates that you can find information on the get command in Section 1 of the reference pages. |
|
// |
An explanation of a particular function performed by preceding code. |
ElegantJ EntryMasks are tools for ready made validation logic for accurate data entry. Allow to enter two digits after decimal point. Entry of date in a specific format. Allow to enter temperature between range of 10 deg C and 90 deg C. Use ElegantJ EntryMask beans to give your JAVA based solution true advantage of masking. Data is checked on key press. Masks for Numeric, Alphanumeric, Alphabetic, Date, Time, Date Box and many more. All with user defined patterns [for example, Phone *No:(NNN)-(NNN)-(NNNNNNN)]. Many pre defined Date and Time formats. And a lot more. Let our beans handle your masking and other needs of validation. You concentrate on core features of your application.
IT ensures efficient Data handling. Data Access components that are shipped with this bean are so powerful and flexible, they can work in most of the limitations imposed by architectural circumstances, security and accessibility constraints on servers. With ElegantJ Data Access component, you will be able connect and communicate with any computer through protocols like FILE, JDBC, FTP or HTTP.
In case you are using evaluation, an Evaluation Dialog used to popup every 10 minutes. This dialog will now appear only once, making evaluation without interruption.
Others
Ø A mask can be enabled or disabled.
Ø Foreground and background color can be set for disabled items.
Ø Edit Mask: Introduced one more mask type All - This allows all characters to be entered. Now, EditMask can be used as textfield too.
Ø Edit Mask: Selection - Property to allow / not allow selection. Handle selection using Keyboard as well as mouse.
Ø Edit Mask - Now you can specify characters that you want to allow users to enter (Include characters) and characters that you do not want users to enter (Exclude characters).
Ø HOME, END, INSERT and key combination Ctrl+A is now available for use.
Ø Text can be selected, color for selected background and foreground can be set.
Ø Now you have blinking cursor. Possible to control cursor blinking-speed in terms of milliseconds.
Ø Alignment can be set as - Left, Right and Center.
Ø Cut, Copy and Paste functions with Ctrl+X, Ctrl+C and Ctrl+V key-combinations.
Ø Numeric Mask - You can set acceptable Minimum value and Maximum value.
Ø Numeric Mask - Allow or not allow entry numbers with decimal values, also control number of digits after decimal point.
Ø Numeric Mask - Allow entry to negative numbers prefixed with minus sign.
Ø Facility to set double-buffering ON or OFF.
Ø Take actions - When text gets changed and when text was going to be changed.
ElegantJ Entry Mask is shipped with following Beans -
Ø ElegantJ DateBox (datebox.jar)
Ø ElegantJ DateMask (datemask.jar)
Ø ElegantJ EditMask (editmask.jar)
Ø ElegantJ TimeMask (timemask.jar)
Ø General formatting features like background and foreground color, fonts, visibility, etc.
o Background
o Foreground
o Font
o Visibility
o Enability
o Locale
o Cursor
o Bounds
o Border (none, simple, raised, lowered) with different color and width.
Ø Customize color of selected item's background and foreground.
Ø Option to select color of disabled item's background and foreground
Ø Separate masks to allow entry of Numeric, Alphabetic and Alphanumeric characters.
Ø Mask Pattern for Numeric (N), Alphabetic (A) and Alphanumeric (X) to allow mixed entries for a field.
Ø You can use EditMask without supplying mask pattern.
o Only Numerals (0-9) with decimal point, minus sign, minimum and maximum limits and restrict user to enter up to a specific number of digits after decimal point.
o Only Numerals + Decimal Point + Minus Sign.
o Only Alphabet.
o Only Alphabet and Numerals both.
o Only Alphabet with some characters INCLUDED as well as EXCLUDED. User can set Included and excluded characters for specific mask type (i.e. user can set individually for Numeric, Alphabet and Alpha Numeric mask type).
o Only Alpha Numeric with some characters INCLUDED as well as EXCLUDED. User can set included and excluded characters for specific mask type (i.e. user can set individually for Numeric, Alphabet and Alpha Numeric mask type).
Ø Maximum and Minimum ranges for numeric entries.
Ø Masks to allow or not allow entries with decimal and minus sign.
Ø ElegantJ EditMask has functionality to include or exclude characters within each mask.
o If user wants to allow only (0-3) numerals and underscore('_') in user input.
o If user wants to allow only (a-g) in user input.
o If user wants to allow (a-z) + some special characters like "!@#$%^&*()' in user input.
Ø Mask for alignment - Left, Center or Right.
Ø Customizable caret color and blink rate.
Ø ElegantJ EditMask provides full support with all key and mouse input.
Ø Option for user to allow / not allow edit.
Ø Option to enable or disable selection.
Ø Double buffering can be turned on / off.
Ø Provides Cut, Copy and Paste functionality.
Ø Range of appearance and formatting features - arrow background and foreground, font properties, etc.
o Arrow background
o Arrow foreground
o Background
o Foreground
o Font
o Visibility
o Enability
o Locale
o Cursor
o Bounds
Ø Four date formats -
o DDMMYY
o DDMMYYYY
o MMDDYY
o MDDYYYY
Ø Separator character to separate date, month and year.
Ø Appearance and Formatting attributes - Background and foreground, font properties, locale, etc.
o Background
o Foreground
o Font
o Visibility
o Enability
o Locale
o Cursor
o Bounds
o Border (none, simple, raised, lowered) with different color and width
Ø An array of date mask patterns. Permissible date masks are –
o dd_mm_yyyy
o dd_mmm_yyyy
o dd_mmmmm_yyyy
o mm_dd_yyyy
o mmm_dd_yyyy
o mmmmm_dd_yyyy
o yyyy_mm_dd
o yyyy_mmm_dd
o yyyy_mmmmm_dd
Ø Customizable separator character to be used between date, month and year.
Ø Turn on or off the feature to display of week day.
Ø Turn or off the feature to display week day in long (Monday) or short (Mon).
Ø With ElegantJ DateMask allows to customize caret color.
Ø Spin over the date, month and year using Up and Down arrow key. This feature can be turned on or off.
Ø User can directly set the java.util.Date object to the ElegantJ DateMask.
Ø Appearance and Formatting attributes - Background and foreground, font properties, locale, etc.
o Background
o Foreground
o Font
o Visibility
o Enability
o Locale
o Cursor
o Bounds
o Border (none, simple, raised, lowered) with different color and width.
Ø Two time mask patterns - 12 hour clock (am / pm) and 24 hour clock.
Ø Customizable separator character to be used between hours, minutes and seconds.
Ø ElegantJ TimeMask allows to customize caret color.
Ø Spin over the hours, minutes and second using Up and Down arrow key. This feature can be turned on or off.
Extracted file(archive) contains demos directory. All the demos are located in this demos directory.
Your classpath environment variables must be set correctly in order to run the demos. For windows users we have provided rundemo.bat file which will run demo directly. All Demo Applets contain HTML file to run an Applet associated with it.
For more information on how to set classpath, refer Installation procedure.
Masking demo applet
Description: This demo provides data entry form. It demonstrates all the masks including EditMask, DateMask, TimeMask and DateBox.
To run this demo application,
Go to ElegantJEntryMasks\demos\applets\masking_demo directory, then open maskingapplet.html in any Java compliant Web browser.
Masking demo application
Description: This demonstration provides a data entry form. It demonstrates all the masks including EditMask, DataMask, TimeMask and DateBox.
To run this demo application,
Go to ElegantJEntryMasks\demos\applications\masking_demo directory, then execute java -jar masking_demo_app.jar command
Personal information entry form application
Description: This demonstration provides personal information entry form using all the masks including EditMask, DataMask, TimeMask and DateBox.
To run this demo application,
Go to ElegantJEntryMasks\demos\applications\entry_form directory, then execute java -jar entry_form_app.jar command
Note: For windows user we have provided the rundemo.bat file to run demo application.
Before installing ElegantJBeans, please ensure that your computer system and development environment are setup and working as per expectations. Person evaluating ElegantJBeans is expected to be able to write and execute simple JAVA applications.
We provide free pre-purchase technical support to help you complete process of evaluation. Mail to support@elegantJBeans.com for pre-purchase technical support.
To be able to use ElegantJBeans, your computer systems are required to have -
Ø An IDE that supports Java 2 or higher, or
Ø JDK 1.2.2 or higher
Please note that evaluation version of ElegantJBeans cannot be deployed for commercial, non-commercial or any other purpose in any possible way. You may not build any software, applets or applications for distribution with evaluation version of ElegantJBeans.
This evaluation version is to be solely used by you to evaluate suitability of ElegantJbeans for your needs. For more details please go through License Agreement.
On extracting ejentrymasks_v1.zip, following directories will be created inside ElegantJEntryMasks directory -
Directory [jars] contains Jar file(s)
Directory [demos] contains demo application(s) with source code
Directory [docs] contains path for document(s) access
Installing on Windows 95/98
To include ElegantJ Beanery in CLASSPATH, add following statement to your autoexec.bat file,
set CLASSPATH= %CLASSPATH%;C:\ELEGANTJ\<ELEGANTJ_BENARY_HOME>
\jars\<ELEGANTJ_BEAN>.jar;
Restart Windows to make changes effective.
Installing on Windows NT / 2000
Go to Control Panel and select System. You will find environment variables on Environment tab in Windows NT systems and on Advanced tab in Windows 2000 systems.
Find CLASSPATH environment variable or create it.
To include ElegantJ Beanary in the CLASSPATH, specify or add following value for variable -
[EXISTING-CLASSES];C:\<ELEGANTJ_BEANARY_HOME>\jars\<ELEGANTJ_BEAN>.jar
Installing on UNIX / Linux
Before you begin using ElegantJ Beanary, you must manually configure CLASSPATH environment variable. CLASSPATH must point to the location of classes and installation directory.
For example, to set CLASSPATH for ElegantJ Beanary,
setenv CLASSPATH .:/usr/local/<ELEGANTJ_BEANARY_HOME>/jars/
<ELEGANTJ_BEAN>.jar:
If you are using Bourne Shell, commands are,
CLASSPATH= $CLASSPATH:.:/usr/local/<ELEGANTJ_BEANARY_HOME>/jars/
<ELEGANTJ_BEAN>.jar:export CLASSPATH
Follow the steps given below to create a new category and install Bean into Borland JBuilder.
Create a New Category
Ø Click menu Tools > Configure Palette. It opens Palette Properties dialog box.
Ø Click Add button. It opens Add Page Dialog box. Specify name (for example ElegantJ) and click OK. New Category gets created.
Create New Library and Install / Import Bean
Ø On Palette Properties dialog box, click Pages tab. Select Newly created page (for example ElegantJ).
Ø Click button Select Library. Select a Different Library dialog box opens.
Ø Click New button on Select a Different Library dialog box. New Library Wizard dialog box opens.
Ø Specify name for library and click Add button. Select One or More Directory dialog box opens.
Ø Select directory where jar files are located, or select jar file to be imported. Click OK. Dialog box gets closed and New Library Wizard dialog box appears in front.
Ø Click OK on New Library Wizard. It opens Select a Different Library dialog box.
Ø Confirm that newly created library is selected. Click OK. It opens Add Components under Palette Properties.
Ø Click Add from Selected Libraries button. It opens Results dialog box, click OK.
Ø Results dialog box disappears. Click OK on Palette Properties dialog box.
Ø Beans are ready to use.
Follow the steps given below to import ElegantJBeans in Oracle JDeveloper.
To Import beans into a project
Ø Click menu Project > Project Settings. It opens Project Settings dialog box.
Ø Click Libraries entry appearing on the pane on left side.
Ø Click New button. It opens New Library dialog box.
Ø In Library Name entry box, specify Library name. In Location entry box, specify location where you want the library to be located. In Class Path entry box, specify path of jar file of Bean. Browse the location by clicking Edit... button if required.
Ø Click OK. The library you selected appears in Available Libraries list of Project Properties dialog box.
Ø Select the library you want and click > button to add it to Selected Libraries list.
Ø Click menu Tools > Configure Component Palette. It opens Configure Component Palette dialog box.
Ø To create a new palette page, click New Page... button. It opens New Palette Page dialog box. Specify Page Name and Page Type. Click OK. A new page with specified name will be created.
To add component to page
Ø On Configure Component dialog box, from Pages list, select the page and click Add Component button. It opens Add JavaBeans dialog box with available libraries.
Ø Select a library from Library combo box.
Ø Browse the hierarchy and select a component. It displays preview of icon for selected component. Click OK. It shows Palette Confirmation dialog box.
Ø Click Yes on Palette Confirmation dialog box to complete the process.
Ø Beans are ready to use.
You can purchase a license from our web site www.elegantJBeans.com
You can also contact our sales team sales@elegantJBeans.com
On purchasing a license, you will receive a mail having your license key.
License key can be applied to ElegantJ Java Bean using any of the following ways,
Ø Using with Graphical User Interface of IDE
Ø Using directly with source code
While Designing an application or an applet graphically in an Integrated Development Environment, you will find a property named licensekey along with other properties of the bean. Specify key (serial number) in LicenseKey Property.
Note: Instead of typing the
license key, we suggest you to copy the license key from mail and paste it at
required place. Make sure that the
selection does not have any leading or trailing spaces.
When you use the Bean within code, you need to set the key by providing value in setLicenseKey Method.
Note: Instead of typing the
license key, we suggest you to copy the license key from mail and paste it at
required place. Make sure that the
selection does not have leading or trailing spaces.
ClassName object = new ClassName();
object.setLicenseKey("LICENSE_KEY");
Example
AWTTree awtTree = new AWTTree();
awtTree.setLicenseKey("LICENSE_KEY");
6.1.1.1 Creating an instance of EditMask
Ø To create an instance of ElegantJ EditMask,
com.elegnatj.util.editmask.EditMask editMask = new com.elegantj.util.editmask.EditMask();
This creates an instance of EditMask.
6.1.1.2 Setting general formatting attributes
ElegantJ EditMask offers following formatting attributes -
Ø Font
Ø Background
Ø Foreground
Ø Visible
Ø Enabled
Ø Locale
Ø Cursor
Ø Bounds
Ø Border (none, simple, raised, lowered) with different color and width
Ø To set Font
editMask.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12)); // sets font as dialog, style plain, size of 12
Ø To set Background color
editMask.setBackground(java.awt.Color.cyan); // sets background color as cyan
Ø To set Foreground color
editMask.setForeground(java.awt.Color.black); // sets foreground color as black
Ø To set Visibility
editMask.setVisible(true); // sets visibility as true
Ø To set Enability
editMask.setEnabled(true); // sets enability as true
Ø To set Locale
editMask.setLocale(java.util.Locale.ENGLISH); // sets locale as English
Ø To set Cursor
editMask.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); // sets cursor type as hand cursor
Ø To set Bounds
int x = 5;
int y = 5;
int width = 300;
int height = 200;
editMask.setBounds(x, y, width, height); // sets bounds to x, y, width and height
Ø To set Border
int borderStyle =
com.elegantj.editors.AWTBorder.SIMPLE;
int borderWidth =
com.elegantj.editors.AWTBorder.POINT2;
Color borderColor = java.awt.Color.black;
com.elegantj.editors.AWTBorder border = new
com.elegantj.editors.AWTBorder(borderStyle,
borderWidth, borderColor);
editMask.setBorder(border);
ElegantJ EditMask allows customizable Mask Type,
Ø Permissible values are -
com.elegantj.util.editmask.EditMask.ALL - accepts all characters
com.elegantj.util.editmask.EditMask.NUMERIC_MASK - accepts only numeric characters
com.elegantj.util.editmask.EditMask.ALPHABETIC_MASK - accepts only alphabetic characters
com.elegantj.util.editmask.EditMask.ALPHA_NUMERIC_MASK - accepts only alpha numeric characters
In case of NUMERIC_MASK user can turn on / off decimal point as well as turn on/off minus sign input. Also In case of NUMERIC_MASK user can configure number of digits that can be inputted after decimal point.
For all above four mask type user can set INCLUDE and EXCLUDE characters using setIncludeChars and setExcludeChars methods.
Ø To set mask type
editMask.setMaskType(com.elegantj.util.editmask.EditMask.ALL);
This sets mask type to ALL.
6.1.1.4 Configuring mask pattern
ElegantJ EditMask allows user to set customizable mask pattern,
ElegantJ EditMask provides the three special characters to set mask -
N for Numeric input
A for Alphabet input
X for Alpha Numeric input
If your mask pattern's static portion contains any of the above special characters, then put prefix(*) before special character.
Example of mask patterns:
1. Employee Phone *No:(NNN)-(NNN)-(NNNNNNN)
2. Employee *Name:AAAAAAAAAA AAAAAAAAAAAAAAA AAAAAAAAAA
3. Employee Code:XX/NNNNN
Ø To set mask pattern
editMask.setMaskPattern("Employee
Phone *No:(NNN)-(NNN)-
(NNNNNNN)");
This sets the mask pattern.
6.1.1.5 Configuring include characters and exclude characters
ElegantJ EditMask allows user to include and exclude characters for each mask type.
When user enters / inputs any character, EditMask first of all checks if mask pattern is empty or not.
If mask pattern is empty then it works like this -
Ø Firstly, it checks the mask type (if it is NUMERIC, ALPHABETIC or ALPHANUMERIC)
Ø Then it checks the character currently being entered against Include and Exclude characters
Ø After all checks if the character is found valid, it is allowed to be entered.
If mask pattern is not empty then it works like this -
Ø Firstly, it checks exact nature of the character in mask pattern where user is inputting / entering character
Ø Then it checks the character currently being entered against Include and Exclude characters
Ø After all checks if the character is found valid, it is allows it to entered.
Ø To set Include Characters
editMask.setIncludeChars("#$%^&");
This includes "#$%^&" characters.
Ø To set Exclude Chars
editMask.setIncludeChars("ABCDEFG123");
This excludes "ABCDEFG123" characters.
ElegantJ EditMask allows user to set alignment for EditMask.
Ø Permissible values for alignment are
com.elegantj.util.editmask.EditMask.LEFT
com.elegantj.util.editmask.EditMask.CENTER
com.elegantj.util.editmask.EditMask.RIGHT
Ø To set alignment
editMask.setAlignment(com.elegantj.util.editmask.EditMask.CENTER)
This sets alignment to center.
6.1.1.7 Configuring decimal points, digits after decimal point and minus sign
Configuring decimal point, digits after decimal point and minus sign
Decimal Point
ElegantJ EditMask allows user to turn on / off input of decimal point in case of NUMERIC_MASK
Ø To allow decimal point in user input
editMask.setDecimalPointAllowed(true);
This allows the decimal point in user input.
Digits after decimal point
ElegantJ EditMask allows to set number of digits user can input after decimal point. If user set number of digits as 2, user can not enter more than 2 digits after decimal point.
Ø To set number of digits after decimal point
editMask.setDigitsAfterDecimalPoint(2);
This allows only up to 2 digits after decimal point.
Minus sign
ElegantJ EditMask allows to turn on/off input of minus (-) sign
Ø To allow minus sign in user input
editMask.setMinusSignAllowed(true);
This allows a minus sign in user input.
Note: These functionalities are effective only If mask type is NUMERIC_MASK and mask pattern is blank / null, If mask type is not NUMERIC_MASK and mask pattern is not null then doesn't remain effective.
6.1.1.8 Configuring minimum and maximum range
ElegantJ EditMask allows user to set minimum and maximum value in case of NUMERIC_MASK.
Ø To set minimum value
editMask.setMinNumericValue(0.0);
This sets minimum limit for numeric value.
Ø To set maximum value
editMask.setMaxNumericValue(100.0);
This sets maximum limit for numeric value.
Note:
1. To check if numeric value is valid (between minimum and maximum limit) or not, call isValidNumericValue method on focus lost event of the mask.
2. These functionalities are effective only If the mask type is NUMERIC_MASK and mask pattern is blank / null. If mask type is not NUMERIC_MASK and mask pattern is not null then it doesn't remain effective.
6.1.1.9 Implementing cut, copy and paste functionality
ElegantJ EditMask provides Cut, Copy and Paste functionality
Keyboard short cut for Copy is CTRL + C
Keyboard short cut for Cut is CTRL + X
Keyboard short cut for Paste is CTRL + V
Ø To copy selected content
editMask.copy();
This copies selected content to the clipboard.
Ø To cut the selected content
editMask.cut();
This cuts selected content and put it to the clipboard.
Ø To paste
editMask.paste();
This pastes content from clipboard to EditMask.
6.1.1.10 Configuring selection, selection background, and selection foreground
ElegantJ EditMask allows user to turn on / off selection functionality
Ø To turn on selection allowed
editMask.setSelectionAllowed(true);
This turns on selection functionality of EditMask
Ø To set selection background
editMask.setSelectionBackground(Color.red);
This sets selection background color as red
Ø To set selection foreground
editMask.setSelectionForeground(Color.white);
This sets selection foreground color as white.
6.1.1.11 Configuring disabled background and foreground
ElegantJ EditMask allows user to set customized disabled background and foreground,
Ø To set disabled background,
editMask.setDisabledBackground(Color.gray);
This sets disabled background as gray.
Ø To set disabled foreground,
editMask.setDisabledForeground(Color.white);
This sets disabled foreground as white.
6.1.1.12 Configuring double buffering
ElegantJ EditMask allows user to enable or disable double buffering
Ø To turn double buffering on,
editMask.setDoubleBuffered(true);
This turns double buffering on.
6.1.1.13 Configuring caret color and caret blink rate
ElegantJ EditMask allows customization of caret color and caret blink rate
Caret color
Ø To set the caret color
editMask.setCaretColor(Color.red);
This sets caret color to red
Caret blink rate
Ø To set the caret blink rate
editMask.setCaretColor(700);
This sets caret blink rate to 700 milliseconds.
6.1.1.14 EditMask events/listeners
EditMask events/listeners
ElegantJ EditMask provides following two events
Ø TEXT_CHANGED - This is fired when text changed
Ø TEXT_WAS_GOING_TO_CHANGE - This is fired when text was going to be changed but could not change due to mask
To take actions while these events are fired -
Ø Implement com.elegantj.util.editmask.EditMaskListener and implements following two methods
public void
textChanged(com.elegantj.util.editmask.EditMaskEvent e)
public void
textWasGoingToChange(com.elegantj.util.editmask.EditMaskEvent
e)
6.1.2.1 Creating an instance of DateBox
Ø To create an instance of ElegantJ Datebox,
com.elegantj.util.datebox.Datebox datebox =
new
com.elegantj.util.datebox.Datebox();
This creates an instance of datebox.
6.1.2.2 Setting formatting attributes
ElegantJ DateBox Provides following formatting attributes
Ø Font
Ø Background
Ø Foreground
Ø Visible
Ø Enabled
Ø Locale
Ø Cursor
Ø Bounds
Ø To set Font
dateBox.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12)); // sets font as dialog, style of plain, size of 12
Ø To set Background
dateBox.setBackground(java.awt.Color.cyan);
Ø To set Foreground
dateBox.setForeground(java.awt.Color.black);
Ø To set Visibility
dateBox.setVisible(true); // sets visibility to true
Ø To set Enability
dateBox.setEnabled(true); // sets enability to true
Ø To set Locale
dateBox.setLocale(java.util.Locale.ENGLISH); // sets the locale to English
Ø To set Cursor
dateBox.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); // sets cursor type to hand cursor
Ø To set Bounds
int x = 5;
int y = 5;
int width = 300;
int height = 200;
dateBox.setBounds(x, y, width, height); // sets bounds to x, y, width and height
6.1.2.3 Configuring date format
In ElegantJ Datebox, date format can be customized -
Ø Permissible values are
com.elegantj.util.datebox.Datebox.DDMMYY
com.elegantj.util.datebox.Datebox.MMDDYYYY
com.elegantj.util.datebox.Datebox.DDMMYY
com.elegantj.util.datebox.Datebox.MMDDYY
Ø To set DateFormat
datebox.setDateFormat(com.elegantj.util.datebox.Datebox.MMDDYYYY);
This sets date format to MMDDYYYY
6.1.2.4 Configuring separator char
ElegantJ Datebox allows customizable separator character. The separator character appears as a separator between MM, DD and YYYY. e.g. MM/DD/YYYY where "/" is separator character.
Ø To set separator character
datebox.setSeparatorChar('/');
This sets separator character to '/'
6.1.2.5 Configuring popup size
In ElegantJ Datebox you can set popup size of the calendar. This popup calendar is provided with ElegantJ Datebox to select date.
Ø To set the popup (calendar) size
datebox.setPopupSize(new
java.awt.Dimension(210, 150);
This sets the popup (calendar) width as 210 pixels and height as 150 pixels.
6.1.2.6 Configuring how arrows will appear
ElegantJ Datebox allows user to configure background and foreground for the arrow button
Ø To set arrow background
datebox.setArrowBackground(java.awt.Color.blue);
This sets arrow background color as blue.
Ø To set arrow foreground
datebox.setArrowForeground(java.awt.Color.black);
This sets arrow foreground color as black.
6.1.2.7 Configuring popup calendar look and feel
Ø You can configure popup calendar look and feel in following way,
java.awt.Color backColor = new java.awt.Color(230, 240, 248); // provides background color
java.awt.Color foreColor = new java.awt.Color(0, 0, 89); // provides foreground color
com.elegantj.util.calendar.ExtCalendar
extCalendar =
datebox.getCalendar(); // gets calendar's object from datebox
calendar.getParent().setBackground(backColor); // sets background as backColor for calendar's parent
com.elegantj.editors.AWTTitleBorder titleBorder = new com.elegantj.editors.AWTTitleBorder(com.elegantj.editors.AWTTitleBorder.NONE, com.elegantj.editors.AWTTitleBorder.POINT5, foreColor, "", new Font("Dialog", Font.PLAIN, 12), foreColor, com.elegantj.editors.AWTTitleBorder.LEFT); // creates border
calendar.setBorder(titleBorder); // sets border as titleBorder for popup calendar
calendar.setMonthDaysBackground(backColor); // sets month days background as backColor for popup calendar
calendar.setMonthDaysForeground(foreColor); // sets month days foreground as foreColor for popup calendar
calendar.setWeekDaysBackground(foreColor); // sets week days background as foreColor for popup calendar
calendar.setWeekDaysForeground(backColor); // sets week days background as backColor for popup calendar
calendar.setSelectedMonthDayBackground(foreColor); // sets selected month day background as foreColor for popup calendar
calendar.setSelectedMonthDayForeground(backColor); // sets month day foreground as backColor for popup calendar
6.1.3.1 Creating an instance of DateMask
Ø To create an instance of ElegantJ DateMask,
com.elegantj.util.datemask.DateMask
dateMask = new com.elegantj.util.datemask.DateMask();
This creates DateMask.
6.1.3.2 Setting formatting attributes
ElegantJ DateMask Bean provides following formatting attributes -
Ø Font
Ø Background
Ø Foreground
Ø Visible
Ø Enabled
Ø Locale
Ø Cursor
Ø Bounds
Ø Border
Ø To set Font
dateMask.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12)); // this sets fonts as dialog, style as plain, size of 12
Ø To set Background color
dateMask.setBackground(java.awt.Color.cyan); // this sets background color as cyan
Ø To set Foreground color
dateMask.setForeground(java.awt.Color.black); // this sets foreground color as black
Ø To set Visibility
dateMask.setVisible(true); // sets visibility as true
Ø To set Enability
dateBox.setEnabled(true); // sets enability as true
Ø To set Locale
dateMask.setLocale(java.util.Locale.ENGLISH); // sets locale as English
Ø To set Cursor
dateMask.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); // sets cursor type as hand cursor
Ø To set Bounds
int x = 5;
int y = 5;
int width = 300;
int height =
200;
dateMask.setBounds(x, y, width, height); // sets bounds to x, y, width and height
Ø To set Border
int borderStyle
= com.elegantj.editors.AWTBorder.SIMPLE;
int borderWidth
= com.elegantj.editors.AWTBorder.POINT2;
Color
borderColor = java.awt.Color.black;
com.elegantj.editors.AWTBorder
border = new
com.elegantj.editors.AWTBorder(borderStyle,
borderWidth, borderColor);
dateMask.setBorder(border);
This sets simple border with 2 pixel width and of black color.
6.1.3.3 Configuring mask pattern
ElegantJ DateMask allows customizable mask patterns,
Ø Permissible values for mask pattern are,
com.elegantj.data.datemask.DateMask.dd_mm_yyyy
com.elegantj.data.datemask.DateMask.dd_mmm_yyyy
com.elegantj.data.datemask.DateMask.dd_mmmmm_yyyy
com.elegantj.data.datemask.DateMask.mm_dd_yyyy
com.elegantj.data.datemask.DateMask.mmm_dd_yyyy
com.elegantj.data.datemask.DateMask.mmmmm_dd_yyyy
com.elegantj.data.datemask.DateMask.yyyy_mm_dd
com.elegantj.data.datemask.DateMask.yyyy_mmm_dd
com.elegantj.data.datemask.DateMask.yyyy_mmmmm_dd
Ø To set mask pattern
dateMask.setMaskPattern(com.elegantj.data.datemask.DateMask.mm_dd_yyyy);
This sets mask pattern as mm_dd_yyyy.
6.1.3.4 Configuring week day properties
ElegantJ DateMask provides following properties for week day,
Ø Show week day or not. If false, it does not show week day.
Ø Show short week day or long week day. If false it shows long week day.
Ø To display week day after date in DateMask
dateMask.setShowWeekDay(true);
This shows week day after date in DateMask.
Ø To display short week days after date in DateMask
dateMask.setShowShortWeekDay(true);
This displays short week days after date. If this is false, it displays long week days.
6.1.3.5 Configuring separator character
e.g. MM/DD/YYYY where '/' is separator character.
Ø To set separator character
dateMask.setSeparatorChar('/');
This sets separator character as '/' .
6.1.3.6 Enabling spinning of date
ElegantJ DateMask allows user to spin over date on Up and Down arrow key
Ø To enable spinning of date on Up and Down arrow key
dateMask.setSpinAllowed(true);
This enables spinning on Up and Down arrow key.
6.1.3.7 Configuring caret color
In ElegantJ DateMask, you can set customized caret color,
Ø To set caret color
dateMask.setCaretColor(Color.red);
This sets caret color as red.
6.1.4.1 Creating an instance of TimeMask
Ø To create an instance of ElegantJ TimeMask,
com.elegantj.util.timemask.TimeMask
= new
com.elegantj.util.timemask.TimeMask();
This creates an instance of TimeMask.
6.1.4.2 Setting formatting attributes
ElegantJ TimeMask provides following formatting attributes -
Ø Font
Ø Background
Ø Foreground
Ø Visible
Ø Enabled
Ø Local
Ø Cursor
Ø Bounds
Ø Border
Ø To set Font
timeMask.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12)); // sets font as dialog, style to plain and size of 12
Ø To set Background color
timeMask.setBackground(java.awt.Color.cyan); // sets background color as cyan
Ø To set Foreground color
timeMask.setForeground(java.awt.Color.black); // sets foreground color as cyan
Ø To set Visibility
timeMask.setVisible(true); // sets visibility as true
Ø To set Enability
timeMask.setEnabled(true); // sets enability as true
Ø To set Locale
timeMask.setLocale(java.util.Locale.ENGLISH); // sets locale as English
Ø To set Cursor
timeMask.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); // sets cursor type as hand cursor
Ø To set Bounds
int x = 5;
int y = 5;
int width = 300;
int height =
200;
timeMask.setBounds(x, y, width, height); // sets bounds to x, y, width and height
Ø To set Border
int borderStyle
= com.elegantj.editors.AWTBorder.SIMPLE;
int borderWidth
= com.elegantj.editors.AWTBorder.POINT2;
Color
borderColor = java.awt.Color.black;
com.elegantj.editors.AWTBorder
border = new
com.elegantj.editors.AWTBorder(borderStyle,
borderWidth, borderColor);
timeMask.setBorder(border);
This sets simple border with 2 pixel width and of black color.
ElegantJ TimeMask allows user to customize mask type.
Ø Permissible mask types are
com.elegantj.util.timemask.TimeMask.hh_mm_ss - This mask type displays 12 hour clock. Shows AM/PM after time.
com.elegantj.util.timemask.TimeMask.HH_MM_SS - This mask type displays 24 hours clock. does not display AM/PM after time.
Ø To set mask type
timeMask.setMaskType(com.elegantj.util.timemask.TimeMask.hh_mm_ss);
This sets mask type to hh_mm_ss (Time with AM/PM).
6.1.4.4 Configuring separator character and caret color
Ø To set separator character
timeMask.setSeparatorChar(':');
This sets the separator character to ':'
Ø To set caret color
timeMask.setCaretColor(Color.red);
This sets caret color to red.
6.1.4.5 Configuring mask spinning
ElegantJ TimeMask provides spinning on Up and Down arrow key
Ø To allow spinning on use of Up and Down arrow key of the keyboard,
timeMask.setSpinAllowed(true);
This allows spinning on use of Up and Down arrow key of the keyboard.
Product and Support Information:
Ø You can find more information about ElegantJ Entry Masks and its features on www.ElegantJBeans.com.
Ø Forward your support related mails to support@ElegantJBeans.com.
Ø Forward your sales related mails to sales@ElegantJBeans.com.
Feedback and Suggestions:
Ø We will be pleased to get your feedback as well as suggestions about our product.
Ø Forward any feedback or suggestions related mails to support@ElegantJBeans.com.