Common Interfaces in Java

0
852
Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

Common Interfaces in Java
Common Interfaces in Java

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

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.This 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 Shape in Java:

We get generic information about all geometrical shapes in AWT from Shape interface . Shape provides a bounding box-a rectangle in which the shape is enclosed.This is one of the Inbuilt Interfaces of java.

The interface structure of Shape :

public abstract interface java.awt.Shape{
//method
public abstract Rectangle getBounds();
} 

Adjustable interface :

Adjustable interface are applicable to the application which maintain an user adjustable numeric value by implementing several methods defined here.
The user specific value should have a maximum  and a minimum value. These value can be incremented at a time or a block at a time. A simple example of Adjustable interface is the ScrollBar of an application.
An Adjustable object generates an AdjustmentEvent that is adjusted and it maintains a list of adjustmentListener objects which may be notified when such an event occurs. Like Scollbar up and down and displays the values.This is one of the Inbuilt Interfaces of java.

The interface Adjustable is defined as:

public abstract interface java.awt.Adjustable {
// Constants
public static final int HORIZONTAL;
public static final int VERTICAL;
//Methods
public abstract void addAdjustmentListener(AdjustmentListener l);
public abstract int getBlockIncrement();
public abstract int getMaximum();
public abstract int getMinimum();
public abstract int getOrientation();
public abstract int getUnitIncrement();
public abstract int getValue();
public abstract int getVisibleAmount();
public abstract void removeAdjustmentListener(AdjustmentListener l);
public abstract void setBlockIncrement(int b);
public abstract void setMaximum(int max);
public abstract void setMinimum(int min);
public abstract void setUnitIncrement(int u);
public abstract void setValue(int v);
public abstract void setVisibleAmount(int v);
} 

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.
} 

MenuComponentPeer in Java:

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 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.
} 

Interface MenuPeer in java:

The MenuPeer interface specifies the 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 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 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.

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 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 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.
} 

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 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 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 prepareImage(Image img,int w,int h,ImageObserver o);
public abstract int checkImage(Image img,int w,int h,ImageObserver o);
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 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 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.
} 

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 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);
} 

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.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

LEAVE A REPLY

Please enter your comment!
Please enter your name here