Common Interfaces like Peer and abstract interfaces in Java

Spread the love

This post will talk about Common Interfaces in Java, the interface of java, Inbuilt Interfaces of java, Interface, Interface example in java, interface java example, interface used in java, interface program in java, interface java program.

Table of Contents

SocketImplFactory Interface

SocketImplFactory interface designs a factory for the socket implementation. It is used by the classes Socket and ServerSocket to create actual socket implementation. TTranhis is one of the Inbuilt Interfaces of java.

The SocketImplFactory Interface structure is given as:

public interface java.net.SocketImplFactory{
//method
public abstract SocketImpl createSocketImpl();
//returns a new instance of socket impl 
}

Interface MenuBarPeer in Java:

The MenuBarPeer interface specifies the methods that all implementation of Abstract Window Toolkit menubar must define. This is one of the Inbuilt Interfaces of java.

The interface structure of MenuBarPeer is given by:

public interface java.awt.peer.MenuBarPeer extends java.awt.peer.ManuComponentPeer{
//methods
public abstract void addHelpManu(Menu m);
//sets the help menu on the menu bar to be the specified menu
public abstract void addMenu(Menu m);
//adds the specified menu to the menu bar.
public abstract void delMenu(int index);
//remove the menu located at the specified index from the menu bar.
} 

The MenuComponentPeer interface specifies the methods that all implementation of Abstract Window Toolkit menu components must define. This is one of the Inbuilt Interfaces of java.

The structure of MenuComponentPeer is given as:

public interface java.awt.peer.MenuComponentPeer{
//method
public abstract void dispose();
//dispose of the menu component peer and any other resource used by it.
} 

Interface MenuItemPeer in Java:

The MenuItemPeer interface specifies the methods that all implementation of the Abstract Window Toolkit menu item must define. This is one of the Inbuilt Interfaces of java.

The structure of interface MenuItemPeer is given as:

public interface java.awt.peer.MenuItemPeer extends 
                 java.awt.peer.ManuComponentPeer{
//methods:
public abstract void disable();
//disables this menu item.It can no longer be selected by users.
public abstract void enable();
//enables this menu ite,.It can be selected by users.
public abstract void setLabel(String label);
//changes the menu item's label to be the specified String.
public abstract void setEnabled(boolean b);
} 

Interface MenuPeer in java:

The MenuPeer interface specifies the methods that all implementation of Abstract Window Toolkit menu item must define. This is one of the Inbuilt Interfaces of java.

The structure of MenuPeer interface is given as:

public interface java.awt.peer.MenuPeer extends
                 java.awt.peer.ManuItemPeer{
//methods
public abstract void addItem(MenuItem item);
//adds the specified menu item to this menu.
public abstract void addSeparator();
//adds a separator line to this menu.
public abstract void delItem(int index);
//deletes the item at the specified index from the menu.
}

Interface PanelPeer in Java:

The PanelPeer interface specifies the methods that all implementation of the Abstract Window Toolkit Panel must define. This is one of the Inbuilt Interfaces of java.

The structure of interface PanelPeer is given as:

public interface java.awt.peer.PanelPeer extends
                 java.awt.peer.ContainerPeer{
} 

Interface ScrollBarPeer in Java:

The ScrollBarPeer interface specifies the methods that all implementation of the Abstract Window Toolkit Scroll bar must define. This is one of the Inbuilt Interfaces of java.

The structure of the ScrollBarPeer interface is given as:

public interface java.awt.peer.ScrollBarPeer extends
                 java.awt.peer.ComponentPeer{
//method
public abstract void setLineIncrement(int l);
//sets the line increment of the scroll bar.The line increment
//is the value that is added to or subtracted from the value
//of the scroll bar when the user hits the line down or line up
// the gadget.
public abstract void setPageIncrement(int l);
//sets the page increment of the scroll bar.The page increment is the 
//value that is added to or subtracted from the value of 
//the scrollbar when the user hits the page down or page up the gadget.
public abstract void setValue(int value);
//sets the value of the scrollbar to the specified value.
public abstract void setValue(int value,int visible,int min,int max);
//sets several parameters of the scroll bar simultaneously.
} 

Interface TextAreaPeer in java:

The TextAreaPeer interface specifies the methods that all implementation of Abstract Window Toolkit TextArea must define. This is one of the Inbuilt Interfaces of java.

READ  Static Keyword Simplified in Java

The structure of the TextAreaPeer interface is given as:

public interface java.awt.peer.TextAreaPeer extends
                 java.awt.peer.TextComponentPeer{
//method
public abstract void insertText(String txt,int position);
//inserts the specified text at the specified position.
public abstract Dimension minimumSize(int rows,int cols);
//returns the minimum dimension needed for the text area.
public abstract Dimension preferredSize(int rows,int cols);
//returns the preferred dimension needed for the text area.
public abstract void replaceText(String txt,inst start,int end);
//replaces the text from the start(inclusive) index to the end
//(exclusive) index with the new text specified.
} 

Interface TextComponentPeer in Java:

The TextComponentPeer interface specifies the methods that all implementation of the Abstract Window Toolkit text component must define. This is one of the Inbuilt Interfaces of java.

The structure of the TextComponentPeer interface is given as:

public interface java.awt.peer.TextComponentPeer extends
                 java.awt.peer.ComponentPeer{
//method
public abstract int getSelectionEnd();
//returns the end position of the selected text.
public abstract int getSelectionStart()
//returns the start position of the selected text.
public abstract String getText();
//returns the text of this text component.
public abstract void select(int startIndex,int endIndex);
//selects the text in the text component from the startIndex (inclusive) and 
//endIndex(exclusive).
public abstract void setEditable(Boolean editable);
//sets the text component to be user editable if the boolean argument is true.
//if the flag is false ,sets the text component non editable so that the users 
//can not change its content.
public abstract void setText(String txt);
//sets the txt to the text component.
} 

Interface CheckboxMenuPeer in AWT in Java

The CheckboxMenuPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with the Checkbox menu. This is one of the Inbuilt Interfaces of java.

The interface structure of CheckboxMenuPeer is described as

public interface java.awt.peer.CheckboxMenuPeer extends java.awt.peer.MenuItemPeer{
//Methods
public abstract void setState(boolean t);
//sets the checkbox to the specified boolean state.true indicates it is on,false indicated that it is off.
} 

Interface CheckboxPeer in AWT in Java

The CheckboxPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with Checkbox.

The structure of interface CheckboxPeer is given as:

public interface java.awt.peer.CheckboxPeer extends java.awt.peer.ComponentPeer{
//Methods
public abstract void setCheckboxGroup(CheckboxGroup g);//sets the group of the checkbox to the specified group.
public abstract void setState(boolean state);//sets the checkbox to the specified boolean state:true indicates on and false indicates off.
public abstract void setLabel(string label);//sets the checkbox's label to the specified argument.
} 

Interface ChoicePeer in AWT in Java

The ChoicePeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with Choice.

The structure of interface ChoicePeer is given as:

public interface java.awt.peer.ChoicePeer extends java.awt.peer.ComponentPeer{
//Methods
public abstract void addItem(String item,int index); //adds an item to the choice menu at the specified index position.
public abstract void select(int index);//sets the selected position item to be the item at the specified position.
public abstract void remove(int index);
public abstract void add(String item, int index);

Interface ComponentPeer in AWT in Java

The ComponentPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with Component.

The structure of interface ComponentPeer is given as:

public abstract interface java.awt.peer.ComponentPeer{
//Methods
public abstract void disable();
public abstract void dispose();
public abstract void enable();
public abstract void hide();
public abstract void nextFocus();
public abstract void requestFocus();
public abstract void show();
public abstract void setForeground(Color c);
public abstract void setBackground(Color c);
public abstract void setFont(Font f);
public abstract void reshape(int x,int y,int width,int height);
public abstract void paint(Graphics g);
public abstract void print(Graphics g);
public abstract void repaint(long tm,int x,int y,int width,int height);
public abstract ColorModel getColorModel();
public abstract FontMetrics getFontMetrics(Font f);
public abstract Graphics getGraphics();
public abstract Toolkit getToolkit();
public abstract Dimension minimumSize();
public abstract Dimension preferredSize();
public abstract boolean handleEvent(Event e);
public abstract boolean handleEvent(AWTEvent e);
public abstract boolean prepareImage(Image img,int w,int h,ImageObserver o);
public abstract int checkImage(Image img,int w,int h,ImageObserver o);
public abstract Point getLocationOnScreen();
public abstract Dimension getMinimumSize();
public abstract Dimension getPreferredSize();
public abstract boolean isFocusTraversable();
public abstract void setBounds(int x, int y, int width, int height);
public abstract void setCursor(Cursor cursor);
public abstract void setEnabled(boolean b);
public abstract void setVisible(boolean b);
public abstract Image createImage(ImageProducer p);
public abstract Image createImage(int w,int h);
} 

Interface ContainerPeer in AWT in Java:

The ContainerPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with Container.

The structure of interface ContainerPeer is given as:

public interface java.awt.peer.ContainerPeer extends java.awt.peer.ComponentPeer{
//Methods
public abstract Insets insets();
//determines insets of the container,which indicates the size of the border of the container.
//A frame, for example has a top inset that corresponds to the height of the frame's title bar.
public abstract void beginValidate();
public abstract void endValidate();
public abstract Insets getInsets();
}

Interface DialogPeer in AWT in Java

The DialogPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with a Dialog window.

The structure of interface DialogPeer is given as:

public interface java.awt.peer.DialogPeer extends java.awt.peer.WindowPeer{
//Methods
public abstract void setResizeable(boolean resizeable);//sets the resizeable flag
public abstract void setTitle(String title);//sets the title of the dialog window
} 

Interface FileDialogPeer in AWT in Java

The FileDialogPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with a Dialog window.

The structure of interface DialogPeer is given as:

public interface java.awt.peer.FileDialogPeer extends java.awt.peer.DialogPeer{
//Methods
public abstract void setDirectory(String dir);
//sets the directory of the file dialog window to be the specified directory.
public abstract void setFileNameFilter(FileNameFilter filter);
//sets the filename filter for this file dialog windows to the specified filter.
public abstract void setFile(String file)
} 

Interface FramePeer in AWT in Java

The FramePeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with frame.

The structure of interface FramePeer is given as:

public interface java.awt.peer.FramePeer extends java.awt.peer.WindowPeer{
//Methods
public abstract void setCursor(int cursorType);
public abstract void setIconImage(Image img);
public abstract void setMenuBar(ManuBar mb);
public abstract void setResizeable(boolean resizeable);
public abstract void setTitle(String title);
} 

Interface LabelPeer in AWT in Java

The LabelPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with the label.

The structure of interface LabelPeer is given as:

public interface java.awt.peer.LabelPeer extends java.awt.peer.ComponentPeer{
//Methods
public abstract void setAlignment(int alignment);
//sets the alignment for this label to the specified alignment.
public abstract void setText(String label);
//sets the text for this label to the specified text.
}

Interface ListPeer in AWT in Java

The scrolling ListPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with lists.

The structure of interface ListPeer is given as:

public interface java.awt.peer.ListPeer extends java.awt.peer.ComponentPeer{
//Methods
public abstract void addItem(String item,int index);
public abstract void clear();
public abstract void delItems(int start,int end);
public abstract void delselect(int index);
public abstract void makeVisible(int index);
public abstract void select(int index);
public abstract void setMultipleselections(boolean v);
public abstract int[] getSelectedIndexes();
public abstract Dimension minimumSize(int v);
public abstract Dimension preferredSize(int v);
public abstract void add (String item, int index);
public abstract Dimension getMinimumSize (int rows);
public abstract Dimension getPreferredSize (int rows);
public abstract void removeAll ();
public abstract void setMultipleMode (boolean b);
} 

Interface LayoutManager in Java

A Container in java is a placeholder that contains different components -GUI attributes(like Frame, Panel, Label, etc). Each container object has its own layout manager to place the child components on the screen.

READ  This-Keyword Simplified in Java

Each container object has a Layout manager which is an instance of any class that implements a LayoutManager interface. Thus each component(Frame, Panel, Label, etc) will have its default layout manager associated with it which may be changed by the developer when an instance of that container is created.

Each layout manager keeps track of its child components. The layout manager is notified each time one adds a component to the container.Java supports five different Layout Managers. They are as follows:

  1. FlowLayout
  2. BorderLayout
  3. GridLayout
  4. GridBagLayout
  5. CardLayout.
  6. GridBagConstraint

The interface LayoutManager specifies the methods that all the above layout manager must implement. A LayoutManager is responsible for laying out components by setting the size and position of each component of a container.

The interface structure of the LayoutManager is given as:

public abstract interface java.awt.LayoutManager {
//methods
public abstract void addLayoutComponent(String name,Component comp);
//When we add a component to the container we call addLayoutComponent() 
public abstract void layoutContainer(Container target);
public abstract Dimension minimumLayoutSize(Container target);
//returns the minimum width and height for the LayoutManager to lay components
public abstract Dimension preferredLayoutSize(Container target);
//returns the optimal width and height for the LayoutManager to lay components
public abstract void removeLayoutComponent(Component comp);
//we call removeLayoutComponent() when a component is removed.
} 

Interface MenuContainer in AWT in Java

The MenuContainer interface specifies the methods that all menu related containers (Menu, Frame, MenuBar, etc)must implement. Note that menu containers are not required to be a full-fledged container object.

The interface structure of MenuContainer is given as:


public interface java.awt.MenuContainer{
//methods:
public abstract Font getFont();
public abstract boolean postEvent(Event evt);
public abstract  void remove(MenuComponent comp);
}
 

Interface WindowPeer in AWT in Java

The WindowPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with Window.

The architecture of the interface WindowPeer is given as :

public interface java.awt.peer.WindowPeer extends java.awt.peer.ContainerePeer{
//methods:
public abstract void toBack();
//sends this window to the back
public abstract void toFront();
//Brings the window to the front.
} 

Interface ButtonPeer in AWT in Java

The ButtonPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with Window.

The architecture of the interface ButtonPeer is given as :


public interface java.awt.peer.ButtonPeer extends java.awt.peer.ContainerePeer{
//methods:
public abstract void setLabel(String label);
//changes the button's label to the String argument
} 

Interface CanvasPeer in AWT in Java

The CanvasPeer interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with Canvas.In general canvas implementations only need to implement methods required of all component peers.

The architecture of the interface CanvasPeer is given as :


public interface java.awt.peer.CanvasPeer extends java.awt.peer.ComponentPeer{
}
 

Interface DataInput In java

The DataInput interface is implemented by streams that can read primitive Java data types from a Stream in a machine-dependent manner. This is a popular Interface example in java.

The interface DataInput is given as:

public interface java.io.DataInput{
//methods:
public abstract boolean readBoolean();
public abstract byte readByte();
public abstract char readChar();
public abstract double readDouble();
public abstract float readFloat();
public abstract void readFully(byte b[])
public abstract void readFully(byte b[],int offSet,int length);
public abstract int readInt();
public abstract String readLine();
public abstract long readLong();
public abstract short readShort();
public abstract int readUnsignedByte();
public abstract int readUnsignedShort();
public abstract String readUTF();
public abstract int skipBytes(int n);
} 

All these methods can throw EOFException if this stream reaches the end before skipping all bytes also can throw IOException if an I/O error occurs.

Interface DataOutput in Java

The DataOutput interface is implemented by streams that can write primitive data types to an output stream in a machine-independent manner. This is a popular Interface example in java.

The structure of the DataOutput interface is given as:


public interface java.io.DataOutput{
//methods
public abstract void write(byte b[]);
public abstract void write(byte b[],int offSet,int length);
public abstract void write(int i);
public abstract void writeBoolean(boolean b);
public abstract void writeByte(int v);
public abstract void writeBytes(String s);
public abstract void writeChar(int b);
public abstract void writeChars(String s);
public abstract void writeDouble(double d);
public abstract void writeFloat(float f);
public abstract void writeInt(int b);
public abstract void writeLong(long l);
public abstract void writeShort(int b);
public abstract void writeUTF(string str);
}
 

In addition, all methods may throw an IOException if an IO error occurs apart from their regular Exceptions.

Interface URLStreamHandlerFactory in Java

Interface URLStreamHandlerFactory defines a factory for URL stream protocol handlers. It is used by URL class to create a URL Stream handler for a specific protocol. This is a popular Interface example in java.

The structure of the class URLStreamHandlerFactory is defined as:


public interface java.net.URLStreamHandlerFactory{
//methods
public abstract URLStreamHandler createURLStreamHandler(String protocol);
//returns a url stream handler for the specific protocol like ftp,http etc
}

Interface Observer in Java

A class can implement the observer interface when it wants to be informed of the observable objects changes.This is popular Interface example in java.

The interface structure is given as


public interface java.util.observer{
//methods
public abstruct void update(Observable obj,Object arg);
this method is called whenever the observed object is changed.An application calls an observable object's notifyObservers() method to have all object's observers notified of the changes.
}
 

Interface Cloneable in Java

A class that implements the Cloneable interface,indicates to the clone() method in the class Object that it is legal for that method to make a field for field copy of instances of that class. Any attempt to clone instances that do not implement the cloneable interface results in the exception- CloneNotSupportedException being thrown.
The structure is given below:


public interface java.lang.Cloneable{
}
 

FontPeer interface in Java:

The structure of the FontPeer interface is given below:


public interface java.awt.peer.FontPeer{}
 

Interface ContentHandlerFactory in Java

ContentHandlerFactory interface defines a factory for content handlers.This interface is used by the URLSTREAMHandler class to create a content handler for a MIME type.An implementation of this interface should map a mime type into an instance of content handler.

The structure of the interface ContentHandlerFactory is given as:


public interface java.net.ContentHandlerFactory{
//methods
public abstract ContentHandler createContentHandler(String mmeType);
//creates a new ContentHandlerFactory instance ti read an object from a URLStreamHandler.
}

Interface FilenameFilter in Java:

Instance of classes which implement this interface are used to filter filenames. These instances are used to filter directory listing in the list method of class File(Class File,Utility) and by the abstract window toolkit’s file dialog components.This method defines the accept() method that needs to be implemented by any object that filters filenames.There is no standard FinenameFilter classes in java but objects that implement this interface are used by FileDialog object or File.list() method.It checks for the file or the extension.
So this object can be passed to File.list(),FileDialog.setFilenameFilter(),FileDialogPeer.setFilenameFilet() these method also this object is returned by FileDialog.getFilenameFilter().

The structure of the Interface FilenameFilter is given as:

public interface java.io.FilenameFilter{
//method
public abstract boolean accept(File dir,String name);
//Determines whether a specified file should be included in a file list.
//Returns true if the name should be included in file list,false otherwise.
} 

Interface ContentHandlerFactory in Java

ContentHandlerFactory interface defines a factory for content handlers.This interface is used by the URLSTREAMHandler class to create a content handler for a MIME type.An implementation of this interface should map a mime type into an instance of content handler.

The structure of the interface ContentHandlerFactory is given as:


public interface java.net.ContentHandlerFactory{
//methods
public abstract ContentHandler createContentHandler(String mmeType);
//creates a new ContentHandlerFactory instance ti read an object from a URLStreamHandler.
}

Interface PopupMenuPeer in AWT in Java:

The PopupMenuPeer Interface specifies the methods that all implementations of Abstract Window Toolkit must define while working with PopupMen
The hierarchy of calling this component is as follows:
[PopupMenuPeer(MenuPeer(MenuItemPeer(MenuComponentPeer)))]

READ  How To Communicate Between Two Machines Using UDP in Java

The architecture of the interface PopupMenuPeer is given as :


public abstract interface java.awt.peer.PopupMenuPeer extends java.awt.peer.MenuPeer{
//methods:
public abstract void show(Event evt);
}

All About the SortedSet Interface in Collection In java:

The SortedSet interface is used to sort elements of a collection in ascending order.The SortedSet interface extends Set interface which in turn extends Collection Interface.The SortedSet interface does not allow duplicate elements in a Set.

The below methods are extra apart from Set Interface:

comparator();// Returns the comparator object.If the elements in the SortedSort are in ascending order
//then it returns null.
first();//Returns the first element of the SortedSet.
headSet(Object toElement);//Returns the number of elements less than that of the elements specified
//using toElement object.The elements are returned from the SortedSet.
last();//returns the last element from the SortedSet.
subSet(Object fromElement,Object toElement);//returns the elements between the range specified.
tailSet(Object fromElement);//returns the elements from a SortedSet that are greater than or equal 
//to fromElement. 

All About Queue Interface in Collection in Java

The Queue interface extends to Collection interface and declares the behavior of a queue. It is often first in first out list. In a queue ,elements can only be removed from head of that queue.

The method available in a Queue interface are:

element();//returns the element at the head of the queue.The element is not removed.
offer(Object obj);//attempts to add an element to the queue.Returns true if added,false otherwise.
peek();//returns the element at the head of the queue.The element is not removed.
poll();//returns the element at the head of the queue after removing the current head.
remove();//returns the element at the head of the queue after removing the element. 

The method element() and peek() are similar. If the queue is empty element() throws NoSuchElementException while peek() returns null.
The method poll() and remove() are also similar. poll() returns null when the queue is empty and remove() throws NoSuchElementException.

Iterator Interface in Java:

The Iterator interface(added in java-2) has the same effect and style as the Enumerated interface.It enables us to sequentially traverse and access the elements contained in a collection.The elements of a collection can be accessed using the method defined by Iterator interface.It proves easy methods like add() and remove() to add and remove items.

The vector,Hashtable and Hashmap classes all have an iterator method which returns an iterator of their contents.

The Iterator interface has the following methods:

hasNext();//Returns true if the collection contains more than one element
next();//returns the next element from the collection.
remove();//removes the current element from the collection.

next() method returns the next element if it is available in the collection else it will throw the NoSuchElementException.
remove() method throws the IllegalStateException when there is no element in the collection.
Using the iterator interface we can insert elements only at the end of the list. If we need to insert the element at any required location of the list, we need to use ListIterator Interface. (It extends Iterator interface).
The ListIterator has a special method called add(int index,Object obj). This nethod add an object at the specified location or index.

An example:

Vector v=new vector();
v.add("Apple");
v.add("Banana");
v.add("Pear");
v.add("Grape");
Iterator itr=v.iterator();
while(itr.hasMore()){
String s=(String)itr.next();
System.out.println(s);
} 

All About SortedMap Interface in Collection in Java

The SortedMap interface extends the Map interface. The SortedMap interface contains elements in ascending order based on keys. The functionality of SortedMap is analogous to SortedSet. This is implemented in the TreeMap class.

The method available in the SortedMap interface are:

comparator()//returns the comparator of the SortedMap.It returns null if the sorted map uses
//natural ordering for their key
firstKey();//Returns the first key of the SortedMap.
headMap(Object end);//Returns the keys of the SortedMap that are less than the specified end key.
lastKey();//returns the last key of the SortedMap.
subMap(Object start,Object end);// returns the keys of the SortedMap that are greater than or equal
//to the specified start object and less than or equal to the specified end object.
tailMap(Object start);//Returns the keys of the SortedMap that are greater than or equal 
//to the start object. 

All About Map Interface in Collection in Java

The Map interface maps unique key elements to their corresponding values.Map interface allows us to view the elements of a collection as set of keys,collection of values and the mapping of key value pair.If we remove a key from the Map, the corresponding value also will be removed.

The method defined in Map interface is given as:


clear();//removes all the mapping from a map.
containsKey(Object key);// returns true if the specified value matches 
//with one or more keys in the Map interface.
containsValue(Object value);// returns true if the specified value 
//matches with one or more values in the Map interface.
entrySet();//returns the key value pair contained in the Map
equals(Object obj);//returns true if the specified object maps with an 
//object of a Map interface.
get(Object key);//returns the value which is mapped to the specified key.
isEmpty();//returns true if a Map contains no key value mapping.
keySet();//returns the keys in a Map.
put(Object key,Object value);Maps the specified key with the value.
putAll();//copies all the specified key value pairs from a specified Map
// to the Map with which we are currently working
remove(Object key);Removes the specified key from the Map, automatically 
//the value will be removed.
size();//returns the number of key value mapping available in a Map.
 

Interface LightweightPeer in AWT in Java


public interface java.awt.peer.LightweightPeer extends java.awt.peer.ComponentPeer{}

ScrollPanePeer in Java

The interface structure of ScrollPanePeer is given as

public abstract interface java.awt.peer.ScrollPanePeer extends  java.awt.peer.ContainerPeer{
// Public Instance Methods
public abstract void childResized(int w, int h);
public abstract int getHScrollbarHeight();
public abstract int getVScrollbarWidth();
public abstract void setScrollPosition(int x, int y);
public abstract void setUnitIncrement(Adjustable adj, int u);
public abstract void setValue(Adjustable adj, int v);
}

Interface Enumeration in Java

Enumeration interface defines the methods necessary to enumerate, or iterate through, a set of values, such as the set of values contained in a hashtable or binary tree. It is particularly useful for data structures, like hashtables, for which elements cannot simply be looked up by index, as they can in arrays. An Enumeration is usually not instantiated directly, but instead is created by the object that is to have its values enumerated. Several classes, such as Vector and Hashtable, have methods that return Enumeration objects.

To use an Enumeration object, you use its two methods in a loop: hasMoreElements() returns true if there are more values to be enumerated, and can be used to determine whether a loop should continue. Within a loop, a call to nextElement() returns a value from the enumeration. An Enumeration makes no guarantees about the order in which the values are returned. The values in an Enumeration may be iterated through only once–there is no way to reset it to the beginning.

The interface structure for Enumeration is given as

public abstract interface java.util.Enumeration{
// Public Instance Methods
public abstract boolean hasMoreElements();
public abstract Object nextElement();
}

CheckboxMenuItemPeer in Java

The interface structure for CheckboxMenuItemPeer is given as

public abstract interface java.awt.peer.CheckboxMenuItemPeer extends  java.awt.peer.MenuItemPeer{
// Public Instance Methods
public abstract void setState(boolean t);
}


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *