GUI Flashcards

(25 cards)

1
Q

AWT

A

Abstract Window Toolkit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Swing packages

A

improved version of AWT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

event driven programming

A

programming style based on a
signal-and-response approach.
● Flow of the program determined by events - user actions (mouse clicks, key presses).
● Dominant paradigm used in GUIs and many web applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

listener

A

listener object performs some action in response to the event
GUI components fire events to listeners

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

event handler

A

Methods of the listener object that specify what happens when events are received.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

end GUI program

A

System.exit(0)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

action listeners

A

Buttons fire events known as action events, which are handled by listeners known as action listeners.
ActionListener is an interface:
public class className implements ActionListener
public void actionPerformed (ActionEvent e)

action listener receives the action event as the parameter e to its
actionPerformed method (automatically invoked)

When the user fires a button, an action event is sent to the action listener(s) for that button

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

buttons

A

Buttons fire events known as action events, which are handled by
listeners known as action listeners
action event includes a String instance variable called the action command for the button or menu item.
String can be retrieved with e.getActionCommand( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

action command

A

default value for action command string is the button text.
setActionCommand is used to change the action command for a
component (useful when multiple components have the same default
action command).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

components

A

basic elements of GUI. Each component represents a specific way for the user to interact with the GUI

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

containers

A

holding space for GUI components. They can have components added to them.
Container class descendents - JFrame, Jpanel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

3 objects to make Swing GUI

A
  1. Containers
  2. Components
  3. Layout manager to position the components in the container.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

layout manager

A

describe how multiple components are to be arranged
position components inside the container
BorderLayout (default)
* FlowLayout
* GridLayout
* To add a layout manager to a JFrame named window:
window.setLayout(new BorderLayout());

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

border layout

A

has regions -
eg. BorderLayout.NORTH
window.add(label12, BorderLayout.CENTER) ;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

flow layout

A

It arranges components one after the other, going from left to
right, in the order in which they are added.
* If it runs out of space, it wraps to the next line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

grid layout

A

arranges components in a 2D grid with some number
of rows and columns.
setLayout(new GridLayout(rows, columns));
Each entry is the same size.
● Each component is stretched so that it fills its grid position.
● Items are placed in the grid from left to right, top to bottom

(rows, 0): specified number of rows, as many columns as required!

(rows, columns) : specified number of rows, as many columns as required!

new GridLayout(0, columns) :
specified number of columns , as many rows as required

17
Q

colours

A

object of the class Color from the java.awt
constants for basic colours
can be defined w/ diff RGB components
integers must be in range 0-255 inclusive
float values must be in range 0.0f -1.0f inclusive
JColorChooser.showDialog(frame, “title”, initColor);

18
Q

typography

A

The art of arranging letters and text to make it legible, clear, and visually appealing to the reader

19
Q

font

A

object of the Font class (from java.awt).
The constructor creates a font in a given style and size
Font font1 = new Font(“SansSerif”, Font.PLAIN, SIZE);
new Font(“SansSerif”, Font.BOLD|Font.ITALIC, SIZE);
w/text field- JTextFiled in ; in.setFont(new …)

20
Q

window listeners

A

handle window-related events
opening, closing, minimising, maximising, deactivating
activating
interface : public class ClassName implements WindowListener

21
Q

icons

A

small picture
object of the ImageIcon class
based on a digital picture file such as .gif or .jpg
used to convert a picture file to a Swing icon.
picture file must be in same directory as the class in which this code appears.

22
Q

insets

A

used to specify the size of the
margin in a button or menu item.
arguments given are in pixels

23
Q

scroll bars

A

dont have firm limit on the
number of lines or the number of characters per line
text is viewed through a view port that shows only part of the text at a time
JScrollPane
text area to be viewed is given as an argument
JTextArea area = new JTextArea(15, 30);
JScrollPane scrolled = new JScrollPane(area)

24
Q

Graphics

A

Every container and component that can be drawn on screen has an associated Graphics object.
object has data specifying the area of the screen covered by the component/container

25
paint
method that draws the component or container on the screen. is already defined and is called automatically when the component is displayed on the screen takes in graphics object public void paint (Graphics g) arguments specify location, width, and height of the smallest rectangle that can enclose the oval.