JFrameWindow
- It is a subclass of Frame class.
- When a JFrame is created its size is(0,0) and is invisible.
- A JFrameWindow is created by using the following constructor.
• JFrame()
• JFrame(String title)
JApplet
- It extends Applet class.
- JApplet has several functionalities which are not found in Applet class.
JPanel
- It can exactly use the same way as a Panel.
- We can place components to JPanel and then add the JPanel to some container.
- JPanel also act as a replacement for canvas.
- When using JPanel as a drawing area we should first, set the preffered size via setPrefferedSize.
- Secondly, we should use paintComponent for drawing.
JComponent
- It is a subclass of Container.
- This class contain a large number of subclasses which define component like JButton, JLabel, JComboBox etc.
- Which acts as user interface component.
JLabel
- Labels are instances of the JLabel class.
- JLabel is a subclass of JComponent. It can display text and/or icon.
- Some constructors are as follow:
• JLabel(Icon i)
• Label(String s)
• JLabel(String s,Icon I,int align)
- Here, s and I are the string and icon used for the label.The align argument is either LEFT,RIGHT,CENTER.
JTextField
- The swing text field is encapsulated by the JText Component class which extends JComponent.
- JTextField allows you to edit or enter one line of text.
- Its constructors are as follow:
• JTextField()
• JTextField(int cols)
• JTextField(String s, int cols)
• JTextField(String s)
- Here s is the string to be presented, and cols is the number of columns in the text field.
JTextArea
- It is a subclass of JText Component.
- It displays multiple lines of text.
- There is no scroll to view the text if the text is large, then a JScrollPane has to be created using the text area Component.
• JTextArea()
• JTextArea(int row,int column)
• JTextArea(String text,int row,int column)
JButton
- It provides the functionality of push button.
- It allows an icon, a string with the push button.
• JButton(Icon i)
• JButton(int row,int col)
• JButton(String s,Icon i)
JPasswordField
- It creates the textfield same as the JTextField but the difference is when text is displayed the actual characters are replaced by * characters.
• JPasswordField()
• JPasswordField(int size)
• JPasswordField(String str)
• JPasswordField(String str,int size)
JCheckBox
- This class provides the functionality of checkbox.
• JCheckBox(Icon i)
• JCheckBox(Icon i,boolean state)
• JCheckBox(string s)
• JCheckBox(string s,boolean state)
• JCheckBox(string s,Icon i)
• JCheckBox(string s,Icon i,boolean state)
JRadioButton
- This class provides the functionality of a radio button, which is concrete implementation of AbstractButton.
• JRadioButton(Icon i)
• JRadioButton(Icon I,boolean state)
• JRadioButton(String s)
• JRadioButton(String s,boolean state)
• JRadioButton(String s,Icon i)
• JRadioButton(String s,Icon I,boolean state)
JcomboBox
- It normally displays one entry.
- It can also display a drop down list that allows a user to select a different entry.
- You can also type your selection into the text field.
• JComboBox()
• JComboBox(Vector v)
JList
- It create a list of items and allow the user to select one or more items from the list.
- A list is used when the number of items for selection is large.
• JList()
• JList(Vector v)
JToogleButton
- A JToggleButton is a two-state button. The two states are selected and unselected. The JRadioButton and JCheckBox classes are subclasses of this class. When the user presses the toggle button, it toggles between being pressed or unpressed. JToggleButton is used to select a choice from a list of possible choices.Constructors
- JToggleButton(): Creates an initially unselected toggle button without setting the text or image.
- JToggleButton(Action a): Creates a toggle button where properties are taken from the Action supplied.
- JToggleButton(Icon icon): Creates an initially unselected toggle button with the specified image but no text.
- JToggleButton(Icon icon, boolean selected): Creates a toggle button with the specified image and selection state, but no text.
- JToggleButton(String text): Creates an unselected toggle button with the specified text.
- JToggleButton(String text, boolean selected): Creates a toggle button with the specified text and selection state.
- JToggleButton(String text, Icon icon): Creates a toggle button that has the specified text and image, and that is initially unselected.
- JToggleButton(String text, Icon icon, boolean selected): Creates a toggle button with the specified text, image, and selection state.
JScrollBar
- It is a visual component that can be used ti bring a section of large area of text or image to view by scrolling.
- The scrollbar are vertical or horizontal.
• JScrollBar()
• JScrollBar(int orientation,int scrollpos,int vosible,int min,int max)
JMenuBar
- It holds many menus in its bar.
- A menubar has to be attached to a JFrame window or to a JApplet window.
• JMenuBar()
JMenu
- It is a container for JMenuItem.
- A menu can be attached with several menuitems.
• JMenu()
• JMenu(String str)
JMenuItem
- It is a part of JMenu and displayed in a window.
• JMenuItem()
• JMenuITem(Icon i)
• JMenuItem(String str)
DialogBox
- They are used to obtain user input.
- They don’t have a menubar.
- When a modal dialog box is active, all input is directed to it until it is closed.
- This means that you can not access other parts of your program until you have closed the dialog box.
• Dialog(Frame parentWindow,boolean mode)
• Dialog(Frame parentWindow,string title,boolean mode)
- Here parentwindow is the owner of the dialog box.
FileDialog
- This class extends Dialog and provides a dialog that allows a user to select a file for reading or writing.
- This is very useful for applications that need to save data to a file and later retrieve that data.
- This class defines two consatans FileDialog.LOAD and FileDialog.SAVE
- These determine if the file dialog is being used to select file for reading and writing.
• FileDialog(Frame Parent)
• FileDIalog(Frame Parent,String str)
• FileDialog(Frame Parent,String str,int rw)
No comments:
Post a Comment