Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions? | Software Development
 

Containers

As discussed earlier a container is a component that can be nested. The most widely used Panel is the Class Panel which can be extended further to partition GUIs. There is a Panel which is used for running the programs. This Panel is known as Class Applet

Containers

                         

As discussed earlier a container is a component that can be nested. The most widely used Panel is the Class Panel which can be extended further to partition GUIs. There is a Panel which is used for running the programs. This Panel is known as Class Applet which is used for running the programs within the Browser.

Common Container Methods

All the subclasses of the Container class inherit the behavior of more than 50 common methods of Container. These subclasses of the container mostly override the method of component. Some of the methods of container which are most widely used are as follow:

getComponents();
add();
getComponentCount();
getComponent(int);

ScrollPane

The ScrollPane container provides an automatic scrolling of any larger component which was introduced with the 1.1 release of the Java Runtime Environment (JRE). Any image which is bigger in size for the display area or a bunch of spreadsheet cells is considered as a large object. Moreover there is no LayoutManager for a ScrollPane because only a single object exists within it. However, the mechanism of Event Handling is being managed for scrolling.

The example below shows the Scrollpane. This scrollpane demonstrates the scrolling of the large image. In the program code below, first of all we have created a scrollpane by creating its object, then we have passed the parameter of image in it. We have also set the border layout as centre, as shown.

import java.awt.*; 
import java.applet.*; 
 
class Scrollpane extends Component 
  private Image image; 
  public Scrollpane(Image m) { 
    image = m; 
  
  public void paint(Graphics g) { 
    if (image != null
      g.drawImage(image, 00this)
  

 
public class ScrollingImageDemo extends Applet 
  public void init() { 
    setLayout(new BorderLayout())
    ScrollPane SC = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS)
    Image mg = getImage(getCodeBase()"cute-puppy.gif")
    SC.add(new Scrollpane(mg))
    add(SC, BorderLayout.CENTER)
  

Here is the output:

C:\newprgrm>javac ScrollingImageDemo.java

C:\newprgrm>appletviewer ScrollingImageDemo.html

 

Download this example.

 

                         

» View all related tutorials
Related Tags: c method color value line set while values to draw raw ast fixed e il last li hang use first

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
 
Tell A Friend
Your Friend Name

 

 
Recently Viewed
Software Solutions
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.