Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Lecture 14

166 views

Published on

Notes on core java

Published in: Technology, Art & Photos
  • Be the first to comment

  • Be the first to like this

Lecture 14

  1. 1. Core Java Debasish Pratihari Button Class Constructor:  public Button () Constructs a Button with no label.  public Button(String caption)  Constructs a Button with label as specified by the caption argument. Methods :  Sets the  public void setLabel(String label)  button lable as specified. public String getLabel() Returns the button label or null if no label is in the button.  public Label(String text)   Label Class  constructs an label with specified string public Label( )  constructs an empty label public Label(String text , int alignment)  constructs a new label with specified string and specified alignment.The alignment constants are Label.LEFT,Label.RIGHT,Label.CENTER Methods :  public void setText(String text)sets the text for the label as specified.  public String getText( ) returns the label of the Label. Choice class (Combo box Control) Constructor  public Choice( )  creates a new Combo box with no item Methods  public s void add(String item)  adds an item to the Combo  public void addItem(String item)  adds an item to the Combo  public int getItemCount( ) returns the no. of  public String getItem(int index)  returns a string at the specified index in the choice menu  public int getSelectedIndex( ) returns the index of the currently selected item in the Choice menu.  public synchronized String getSelectedItem( )  returns a String representation of currently selected item from the choice menu Lecture/core/awt2/14 Page #1 feel the Technology…
  2. 2. Core Java Debasish Pratihari TextField class Constructor     public TextField()  creates public TextField(String text) a TextField creates a new text field initialized with specifies text public TextField (int columns) constructs a new empty text field with specified no. of columns public TextField(String text , int columns) constructs a new text field initialized with the specified string and wide enough to hold the specified string Methods      public void setEchoChar(char c)  sets the echo character for this text field public char getEchoChar()  gets the echo character for the text field public void setColumns(int col)  sets the no. of columns for the text field public int getColumns( )  returns the no of columns in the text field public void setEditable(boolean b)  Sets the component to be editable or not if b is true then editable otherwise not editable. TextArea class Constructor :  public TextArea( )  constructs a new text area  public TextArea(String text)  constructs a new text area with specified text row ,int col)  constructs a text area with specified no. of rows and columns  public TextArea( int  public TextArea(String  public TextArea(String text, int row , int col,, int scrollbar)  constructs a text area with specified text ,int rows ,int cols)  constructs a text area with specified no. of rows and columns initializes the text specified. text & with cols & rows and scroll bar visibility as specified the constant for scrollbars argument are o o o o SCROLLBARS_BOTH SCROLLBARS_VERTICAL_ONLY SCROLLBARS_HORIZONTAL_ONLY SCROLLBARS_NONE Lecture/core/awt2/14 Page #2 feel the Technology…
  3. 3. Core Java Debasish Pratihari Checkbox class Constructors  public Checkbox()  creates a checkbox with no  public Checkbox( String   label and state is set to “off” label)  creates a checkbox with the specified label as specified and state is set to “off” public Checkbox( String label , boolean state) creates a checkbox with a specified label and the state of checkbox Is as specified in the Boolean argument, true for on state & table For “off” state. public Checkbox(String label , boolean state , CheckboxGroup g) creates a checkbox with specified label,and State as specified and combined to a checkbox Group class  public Checkbox(String label ,CheckboxGroup boolean state)- Same use as above. g , Methods     label)  sets a label for the check box specified public String getLabel( )  gets the label of this checkbox as specified public void setState(boolean state) sets the state of this checkbox true for “on” & false for “off” public Boolean getState( )  returns Boolean that represent the state of this checkbox returns true if “on” & false is “off” public void setLabel(String Container class Methods:        public Component add(Component comp)  adds the specified component to the container. public Component add(Component comp, int alignment)  adds the component and follows the alignment as specified. public void remove(Component comp)  removes the specified component form the container. public int getComponentCount() returns the no of components in the container. public Component[ ] getComponents() returns an array containing the components in the container. public void removeAll() removes all the components from the container. public void setLayout(LayoutManager mgr)  sets the layout for this container. Lecture/core/awt2/14 Page #3 feel the Technology…
  4. 4. Core Java Debasish Pratihari Component class  public setVisible (boolean b)  if b is true then shows the component otherwise hide it.  public void setSize(int width, int height)  resizes the component to the specified size.  public void setBounds(int x, int y, int width, int height)  moves the component to the corresponding width and height.  public void setLocation(int x, int y)  Moves this component to new location.  public void setName (String name)  Sets the name of the component to the specified string.  public String getName() Returns a String object representing the component name.  public void setForeground(Color c)  Sets the foreground color to the component.  public Color getForeground () Returns the Color object specifying the color of the component.  public void setFont (Font f) Sets the font for the component name.  public Font getFont() Returns the font of this component.  publilc void setEnable(boolean b)  Enables/disables the component if b is true/false.  public boolean isEnable() Returns true if the component is enable otherwise false.  public void setCursor(Cursor c)  Sets the cursor to the component.  public Cursor getCursor() Returns the cursor set for this component.  public void setBackground(Color c)  Sets the background color for component.  public Color getBackground() Returns the color object specifying the color set for the component.  public void repaint() Repaints the component.  public void add(PopupMenu popup)  adds a popup menu for the component.  public void remove(PopupMenu popup)  Removes the particular popup menu from the component.  public void Paint(Graphics g)  paints the component to use this we need to override the method. Lecture/core/awt2/14 Page #4 feel the Technology…
  5. 5. Core Java Debasish Pratihari Frame class Constructor  public Frame( )creates a new invisible frame .  public Frame(String title)creates a new frame with title as specified. Methods  public void setTitle(String title) sets the title of the frame  public String getTitle( )returns the title of the frame.  public void setResizable(boolean resize)sets the resizeable flag which determines whether this frame is resizable or not.  public boolean isResizable()returns true if the frame is resizable or not.  public void setMenuBar(MenuBar mb)sets the menu bar for this frame.  public MenuBar getMenuBar( )returns the menu bar for this frame or null if frame doesnot have any menu bar.  public void remove(MenuComponent m)removes the specified menu bar from this frame.  public setCursor(int cursoe_type)sets the cursor for the frame Dialog class Constuctors:  public Dialog(Frame parent)creates an invisible dialog with empty title.  public Dialog(Frame parent ,boolean modal)creates an invisible dialog with an empty title and modal depending on modal=true/false.  public Dialog(Frame parent , String title)constructs an invisible dialog with specified title.  public Dialog(Frame parent , String title , boolean modal)constructs an invisible dialog with specified title and modal state with specified mode=true/false value. Methods:  public void setModal(boolean b)sets the dialog as modalif bis true otherwise not.  public boolean isModal()returns true if the dialog is modal dialog.  public void setTitle(String title)sets the title of the dialog.  public void setResizable(boolean b)if b=true then the dialog box is set to resizable otherwise not.  public boolean isResizable( )returns true if it is resizable.  public String getTitle( )returns the title of the dialog. Lecture/core/awt2/14 Page #5 feel the Technology…
  6. 6. Core Java Debasish Pratihari FileDialog class Constructors:  public FileDialog(Frame parent)creates a file dialog for loading a file with an empty title.  public FileDialog(Frame parent , String title)creates a file dialog with a specified title for loading a file ,the files are shown in the current directory  public FileDialog(Frame parent,String title,int mode)create a file dialog with specified title for loading and saving a file if the value of mode=LOAD the file dialog is finding a file to read, if mode=SAVE then file dialog is finding a place to write a file. Methods:  public String getDirectory( )gets the directory for this file dialog  public void setDirectory(String dir)sets the directory of this file dialog to be the specified directory.  public String getFile( )returns the currently selected file of the file dialog or null if no file is selected.  public void setFile(String file)sets the selected file for the file dialog to be the specified file.  public int getMode()indicates whether the file dialog is for loading or saving.  public void setMode(int mode)sets the mode mode=FileDialog.LOAD or FileDialog.SAVE Panel class Constructors:  public Panel()creates a new panel using default layout manager.the default layout is FlowLayout.  public Panel(LayoutManager mgr)creates a new panel with specified layout manager. Lecture/core/awt2/14 Page #6 feel the Technology…

×