M3 - Swing Components

Cards (60)

  • JOptionPane Class
    It is used to provide standard dialog boxes such as message dialog box, confirm dialog box, and input dialog box.
  • Dialog Boxes
    Used to display information or get input from the user.
  • The JOptionPane class inherits JComponent class.
    The JOptionPane class inherits JComponent class.
  • ShowConfirmDialog
    Asks a confirming question, like yes/no/cancel.
  • ShowInputDialog
    Prompt for some input.
  • ShowMessageDialog
    Tell the user about something that has happened.
  • ShowOptionDialog
    Allows you to display buttons containing the text of your choice.
  • import javax.swing.JOptionPane;

    What is the import statement?
  • Component
    The graphical widgets inside a frame, such as buttons or text input fields, are collectively called components.
  • JComponent Class
    Provides the following functionality to its descendants.
  • Abstract Button
    An abstract base class of button and menu objects.
  • JButtons
    Act as push buttons which invoke some action when clicked. These are not buttons that are toggled on and off.
  • add()
    Method of a content pane puts a JButton in the frame.
  • getContentPane()
    Method of a frame is used to get the reference to the content pane.
  • JText Component Class
    Provides a base class for Swing components that handle editable text.
  • JText Component Class
    It provides the functionalities for entering and editing text information-nearly all the features of a text editor.
  • ·TextComponent
    JTextField,JTextArea, andJEditorPane.TextComponent has three direct subclasses:
  • int getColumns()
    Returns the number of columns in this TextField
  • void setColumns(int columns)
    Sets the number of columns in this TextField, and then invalidate the layout
  • int getHorizontalAlignment()
    Returns the horizontal alignment of the text
  • void setHorizontalAlignment (int Alignment)
    Sets the horizontal alignment of the text
  • void setFont(Font f)
    Sets the current font
  • JTextArea Class
    Displays multiple lines of text in a single font and style and optionally allows the user to edit the text.
  • JTextArea Class
    Uses the rows and columns properties to indicate the preferred size of the viewport when placed inside a JScrollPane to match the functionality provided by java.awt.TextArea.
  • getText()
    Returns the text in the field
  • setBackground(Color BackgroundColor)
    Sets the background color of the TextArea
  • setEditable(boolean Editable)
    Sets the field as being editable or fixed
  • setFont(Font TextFont)
    Sets the font for this component
  • setLineWrap(boolean LineWrap)
    Sets the line-wrapping policy of the text area
  • setText(String text)
    Sets the text for the field
  • Text Fields
    A lightweight component that allows the editing of a single line of text.
  • JLabel Class
    An object can display either text or an image, or both. It cannot react to input events but is instead commonly used to provide a label identifier for a nearby object that does.
  • String getText()
    Returns the text string that the label displays
  • void setText(String text)
    Defines the single line of text this component will display
  • int getHorizontalAlignment()
    Returns the alignment of the label's contents along the X axis
  • int getVerticalAlignment()
    Returns the alignment of the label's contents along the Y axis
  • void setVerticalAlignment (int alignment)
    Sets the alignment of the label's contents along the Y axis
  • Text Fields
    A display area for a short text string or an image or both.
  • JCombo Class
    A component that combines display area showing an option, and a list box containing additional options.
  • JCombo Box Class
    An array of Objects as the constructor argument.