About AWT Scrollbar Example

Java AWT Scrollbar Example

In our example, we will have three panels and the AWT Frame hosts them via BorderLayout manger. The top panel hosts three AWT Scrollbar controls to denote red, blue, green color values. Middle panel will live in the centre part of the Frame Window. Gray Scale check box will sit in the South part of the Frame window’s border layout.

All three AWT Scrollbar together represent an RGB color value. So, each Scroll can produce a range of values which falls between 0 to 255. When the user adjusts the Scrollbar, we will create RGB Color and apply that to the panel in the middle of the Frame. When Gray Scale is in checked state, we produce the grey-scaled color and apply that to the middle panel. This example helps you to learn how to use AWT Scrollbar and how to handle the AdjustmentEvent raised by it.

Read More…
Java AWT Multi-Select List Example

AWT MULTI-SELECT LIST Control

Here is the screenshot of the sample AWT window, which we will create in this example:

In our example, we have a Multi-Select List box control in the upper left portion of the AWT Frame. When the user clicks the Get Fruits button, the AWT TextArea control will show all the selected list items in it. The Clear Output button will delete the text displayed in the AWT TextArea Control. This example will help you learn how to add strings on AWT List Control and how to retrieve all the items selected by the user. Now, we will proceed with the example.

Read More…
Keyboard Hook and Filter Functions

MFC – Keyboard Hook Filter Functions

The SDI sample, under the file menu, has two menu items called Hook CAPS Lock, Unhook CAPS Lock. When the user clicks the Hook Caps Lock menu item, the Keyboard hook is attached to the application and hooks the keyboard event. The UnHook CAPS Lock event removes installed hook from the application.

Our example SDI contains two menu items called First Dialog and Second Dialog under view menu. These menu items will bring up two dialogs with text boxes in it. When a hook is installed, you can type only the capital letters in the dialogs. After opting for the Un-Hook action, you will not have upper case constraint on the dialogs. Let us jump into the explanation-based walk-through.

Read More…
About TextArea Example

TEXTAREA Control Of AWT – EXAMPLE

The item marked as 1 is the AWT TextArea control. We will add this control to the center of AWT Frame and you can see it occupies 80% of the space. Towards the bottom we add three more AWT Controls. First one is the TextField (Marked as 2) and after that we add an AWT Button (Marked as 3). Finally, we add a Checkbox Control (Marked as 4) and we use this check box to insert text in the TextArea control.

We can type a line of text in the TextField and click on the Add Text button. This will add a single line of text in the AWT TextArea Control. Each time we click Add Text button, a new line of text is added to the TextArea Component. When the check box not checked, we are in text selection mode. User can move their mouse and select any text and delete it or add text manually by changing the cursor position through the mouse.

When the Check box is in checked state, we are in Text-Insert mode. We can type a word or line of text in the text field and then click the mouse cursor at a different location on the TextArea Control to insert it. This way we can insert same text at different location quickly.

Read More…
AWT Choice Control Example

AWT Choice Control Explained

Top portion of the Frame window has the AWT Choice Control. There are two Text fields in the Frame. The first one takes a string and adds it to the Choice Control via Add button click. The next text field is used to display the selected text of the Choice Control. Moreover, the Remove button click will use this text field to delete an item in the Choice.

Read More…