Introduction to Sing Components
Quiz yourself by thinking what should be in
each of the black spaces below before clicking
on it to display the answer.
Help!
|
|
||||
---|---|---|---|---|---|
show | Buttons, text fields, and other components with which the user can interact. Also called controls or widgets
🗑
|
||||
Swing Components | show 🗑
|
||||
Java Foundation Classes(JFC) | show 🗑
|
||||
show | Almost all Swing components are said to be lightweight components because they are written completely in Java and do not have to rely on the local operating system code
🗑
|
||||
Heavyweight Components | show 🗑
|
||||
Container | show 🗑
|
||||
1. Method Inherited by the JFrame Class | show 🗑
|
||||
2. Method Inherited by the JFrame Class | show 🗑
|
||||
3. Method Inherited by the JFrame Class | show 🗑
|
||||
4. Method Inherited by the JFrame Class | show 🗑
|
||||
show | 8. Method[void setBounds(int, int, int, int)]..Purpose[Overrides the default behavior for the JFrame to be positioned in the upper-left corner or computer screen.
🗑
|
||||
6. Method Inherited by the JFrame Class | show 🗑
|
||||
show | The picture elements, or tiny dots of light, that make up the image on your computer monitor
🗑
|
||||
Look and Feel | show 🗑
|
||||
show | A built-in Java Swing class that holds text you can display
🗑
|
||||
show | You can add JLabel and other object to a JFrame object using this method. Ex: JLabel greeting = new Label("Good day");...
aFrame.add(greeting);...
🗑
|
||||
remove() Method | show 🗑
|
||||
show | Can be used to change the text in a JLabel by using this Component class method with the JLabel object and passing a String to it. Ex: greeting.setText("Howdy");
🗑
|
||||
getText() Method | show 🗑
|
||||
Font Class | show 🗑
|
||||
show | Requires a Font object argument. To construct a Font object, you need three arguments: typeface, style, and point size.
🗑
|
||||
show | The typeface argument to the Font constructor is a String representing a font. Common fonts have names such as Arial, Century, Monospaced, and Times New Roman.
🗑
|
||||
show | Applies an attribute to displayed text and is one of three values: Font.PLAIN, Font.BOLD, or Font.ITALIC
🗑
|
||||
show | An integer that represents about 1/72 of an inch. Printed text is commonly 12 points; a headline might be 30 points
🗑
|
||||
1. Giving a JLabel Object New Font | show 🗑
|
||||
2. Giving a JLabel Object New Font | show 🗑
|
||||
show | To place multiple components at specified positions in a container so they do not hide each other, you must explicitly use a layout manager - a class that controls component positioning. Normal behavior of a JFrame is to use layout format BorderLayout
🗑
|
||||
BorderLayout | show 🗑
|
||||
Flow Layout Manager | show 🗑
|
||||
FlowLayout Class Three Constants | show 🗑
|
||||
setLayout() Method | show 🗑
|
||||
JTextField | show 🗑
|
||||
show | To provide a JTextField that allows enough room for a user to enter approximately 10 characters, you can code the following..
JTextField response = new JTextField(10);...
To add the JTextField response to JFrame frame, you write..
frame.add(response);
🗑
|
||||
Editable JTextFields | show 🗑
|
||||
show | If you do not want the user to be able to enter data in a JTextField, you can send a Boolean value to this method to change the JTextField's editable status
🗑
|
||||
JButton | show 🗑
|
||||
show | Popup windows that can help a user understand the purpose of components in an applications; the tool tip appears when a user hovers the mouse pointer over the component
🗑
|
||||
show | Used to define the text to be displayed in a tool tip by passing an appropriate String to it. Ex: button.setToolTipText("Click this button");
🗑
|
||||
show | Occurs when a user takes action on a component, such as clicking the mouse on a JButton object
🗑
|
||||
show | A program in which the user might initiate any number of events in any order
🗑
|
||||
Source of Event | show 🗑
|
||||
Listener | show 🗑
|
||||
show | Used to tell your class to expectnActionEvents
🗑
|
||||
Preparing Your Class to Accept Event Messages | show 🗑
|
||||
show | Includes event classes with names such as ActionEvent, ComponentEvent, and TextEvent.
🗑
|
||||
ActionListener | show 🗑
|
||||
show | The types of events that occur when a user clicks a button
🗑
|
||||
show | When a class =, such as a JFrame , has a registered as a listener with a Component such as a JButton, and a user clicks the JButton, the actionPerformed() method executes. The ActionLIstener interface contains this method
🗑
|
||||
1. Responding to Events | show 🗑
|
||||
2. Responding to Events | show 🗑
|
||||
setEnabled() Method | show 🗑
|
||||
show | 1. Listener[ActionListener]..TypeOfEvents[Action events]..Ex[Button clicks]...
2. Listener[AdjustmentListener]..TypeOfEvents[Adjustment events]..Ex[Scroll bar moves]...
🗑
|
||||
show | 3. Listener[ChangeListener]..TypeOfEvents[Change events]..Ex[Slider is repositioned]...
4. Listener[FocusListener]..TypeOfEvents[Keyboard focus events]..Ex[Text field grains or loses focus]...
🗑
|
||||
3. Alphabetical List of Some Event Listeners | show 🗑
|
||||
show | 7. Listener[MouseListener]..TypeOfEvents[Mouse events]..Ex[Mouse clicks]...
8. Listener[MouseMotionListener]..TypeOfEvents[Mouse movement events]..Ex[Mouse rolls]...
🗑
|
||||
5. Alphabetical List of Some Event Listeners | show 🗑
|
||||
show | 1. Components[JButton, JCheckBox, JComboBox, JTextField, and JRadioButton]..AssociatedListenerRegisteringMethods[addActionListener()]...
🗑
|
||||
show | 2. Components[JScrollBar]..AssociatedListenerRegisteringMethods[addAdjustmentListener()]...
🗑
|
||||
3. Some Swing Components and Their Associated Listener-Registering Methods | show 🗑
|
||||
show | 4. Components[JButton, JCheckBox, JComboBox, and JRadioButton]..AssociatedListenerRegisteringMethods[addItemListener()]...
🗑
|
||||
show | 5. Components[All JWindow and JFrame components]..AssociatedListenerRegisteringMethods[addWindowListener()]...
6. Components[JSlider and JCheckBox]..AssociatedListenerRegisteringMethods[addChangeListener())]
🗑
|
||||
show | A method that executes because it is called automatically when an appropriate event occurs
🗑
|
||||
show | 1. Listener[ActionListener]..Method[actionPerformed(ActionEvent)]...
2. Listener[AdjustmentListener]..Method[adjustmentValueChanged(AdjustmentsEvent)]...
🗑
|
||||
show | 3. Listener[FocusListener]..Method[focusGained(FocusEvent) and focusLost(FocusEvent)]...
4. Listener[ItemListener]..Method[itemStatedChanged(ItemEvent)]
🗑
|
||||
JCheckBox | show 🗑
|
||||
show | When you create a ButtonGroup, you can group several components, such as JCheckBoxes, so a user can select only one at a time
🗑
|
||||
show | A component that combines two features: a display area showing a default option and list box that contains additional, alternate options
🗑
|
||||
Generic Programming | show 🗑
|
Review the information in the table. When you are ready to quiz yourself you can hide individual columns or the entire table. Then you can click on the empty cells to reveal the answer. Try to recall what will be displayed before clicking the empty cell.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
To hide a column, click on the column name.
To hide the entire table, click on the "Hide All" button.
You may also shuffle the rows of the table by clicking on the "Shuffle" button.
Or sort by any of the columns using the down arrow next to any column heading.
If you know all the data on any row, you can temporarily remove it by tapping the trash can to the right of the row.
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.
Normal Size Small Size show me how
Normal Size Small Size show me how
Created by:
TimJavaProgramming
Popular Engineering sets