Class Notes (1,100,000)
US (490,000)
Cornell (1,000)
CS (100)
CS 2110 (30)
Gries (30)
Lecture 14

CS 2110 Lecture Notes - Lecture 14: Graphical User Interface, Reactive Programming, Javafx


Department
Computer Science
Course Code
CS 2110
Professor
Gries
Lecture
14

This preview shows half of the first page. to view the full 2 pages of the document.
Lecture 14 - GUIs
oGUI - Graphical User Interface
Allows event-driven or reactive programming
Reacting to keyboard, mouse, etc.
Lots of different threads of execution essentially simultaneously
Nice interface between user and program
oTwo aspects
Placing components
Listening/responding to events
oThree GUI packages
AWT - Abstract Window Toolkit
Swing - builds on AWT, but is “lightweight”
JavaFX - New and powerful, but hella, and I mean HELLA, complicated
oGRIES IS A GOD
Just a reminder
Don’t question his omnipotence
oLet’s go back to JFrame Class
How do we place components?
public class C extends JFrame {
public C() {
Container cp = getContentPane();
JButton jb = new JButton(“Click here”);
Creates a button
JLabel jl = ….
Makes a label
Just like, text, for example
cp.add(jb, BorderLayout.EAST);
Puts our button object on the east side of the pane
cp.add(jl, BorderLayout.West);
Puts our label on the west side of the pane
pack();
This says, “hey, we’ve placed everything where we
want it, pack it all together!
setVisible(true);
Makes everything visible
}
}
When you make a new GUI, DON’T MAKE IT ALL ON YOUR OWN
THAT’S JUST STUPID
Copy and paste, they all kinda look pretty similar
What are some more things we can add to a JFrame object?
(Components)
JCheckBox
A, you guessed it, check box
JTextField
Can type in here
find more resources at oneclass.com
find more resources at oneclass.com
You're Reading a Preview

Unlock to view full version