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…
About The GridBagConstraints Example

AWT GridBagConstraints gridx, gridy on GridBagLayout

Here, the GridBagLayout comprises of 16 cells. In x axis, we have 4 slots and in y axis we have 4 slots. These together form a grid of 16 cells. The gridx and gridy properties of GridBagConstraints represents these slots. In the above picture you can also see placement of the 9 buttons and how they vary in size.

The properties gridheight & gridwidth tell how many cells a control must cover. The gridwidth property spawns a control horizontally and gridheight property spawns it vertically. In this example, we will create 9 buttons and add it to the AWT Frame window, which is managed by GridBagLayout. Along the way, we will learn about the gridx, gridy, gridwidth and gridheight properties of the GridBagConstraints.

Read More…
GridBagLayout WeightX WeightY Fill Combination

AWT GridBagLayout GridBagConstraints Weightx, WeightY & Fill

We had seen many Layouts in past examples on Java AWT. The GridBagLayout is the most flexible layout in the Java AWT packages. But this comes with the cost of complexity held in the setup of GridBagLayout. You can imagine GridBagLayout as GridLayout with change in cell sizes. Here, we can add controls in relation with the existing one.

The GridBagLayout makes use of the specific settings for each controls which can be set using the GridBagConstraints class. Before adding the controls to the GridBagLayout class, we need to set these component specific setup rules. The bag layout will make use of these setup factors to arrange the components in the parent container.

Read More…
Three Views of Java HashMap

Java HashMap and Its Views

The Java HashMap is a special type of Collection. Unlike other collection classes, it represents Key-Value pairs. In this example, we will explore Map Interface and its functions. Then, we will move on to the implementing class HashMap. We will see how HashMap stores collection items using Key-Value pairs and how it offers different views on its internal data store.

Read More…
Binary Search Tree - Search Efficiency

Performance Study – ArrayList vs TreeSet

In the past examples, we came across ArrayList and TreeSet. We know how Binary Tree of TreeSet involves in search efficiency. In this example, we will compare performance of the TreeSet with ArrayList, Here, we use our Product class and add Millions of it to both TreeSet & ArrayList and then search for specific items in it. We do this test to know operation performance for both adding the items as well as finding the items.

Read More…