Home arrow Java & J2EE arrow Java's Advanced User Interface Components

Java's Advanced User Interface Components

javaLast time, we mastered some basic UI components and worked on how to add them to panels, organize their layout, and manage their events. Having covered all the basic techniques that we値l need to get started with Java interface programming in our first article, Java's Basic User Interface Components, we will move on to some advanced UI components. Today, I値l be covering scrolling lists, scrollbars, and canvases, and their functionality. It is amazing to see how many of complex tasks are simplified with the help of these advanced user interface components.

TABLE OF CONTENTS:
  1. Java's Advanced User Interface Components
  2. More on the List Class
  3. Scrollbars and Sliders
  4. Canvases
By: Gayathri Gokul
Rating: starstarstarstarstar / 18
November 11, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Last time, we mastered some basic UI components and worked on how to add them to panels, organize their layout, and manage their events. Having covered all the basic techniques that we値l need to get started with Java interface programming in our first article, Java's Basic User Interface Components, we will move on to some advanced UI components. Today, I値l be covering scrolling lists, scrollbars, and canvases, and their functionality. It is amazing to see how many of complex tasks are simplified with the help of these advanced user interface components.

The List Class

The list class allows us to create a scrolling list of values. We can enable single or multiple selections using a list. All that the user has to do is double-click on an item to make a selection. A scrolling list is functionally similar to a choice menu in that it lets us pick several options from a list, but scrolling lists differ in two significant ways:
  • Scrolling lists are not pop-up menus. They're displayed as a list of items from which you can choose one or more items. If the number of items is larger than the list box, a scrollbar is automatically provided so that you can see the other items.
  • You can choose more than one item in the list (if the list has been defined to allow multiple selection).

In short, scrolling lists provide a menu of items that can be selected or deselected. Unlike choice menus, scrolling lists are not pop-up menus and can be defined to allow multiple selections. To create a scrolling list, an instance of the List class is created and then we add individual items to that list.

To create a scrolling list use, one of the following constructors:
  • List() creates an empty scrolling list that enables only one selection at a time.
  • List(int, boolean) creates a scrolling list with the indicated number of items visible on the list (there is no limit as to the number of actual items you can add to the list). The boolean argument indicates whether this list enables multiple selections (true) or not (false).

After creating a List object, add items to it using the addItem() method and then add the list itself to the panel that contains it. Here's an example that creates a list five items high that allows multiple selections


 
 
>>> More Java & J2EE Articles          >>> More By Gayathri Gokul
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: