Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

North South University

Department of Electrical and Computer Engineering


CSE 215L: Programming Language II Lab
Lab – GUI

Objective:
● To understand GUI basics

GUI stands for Graphical User Interface, a term used not only in Java but in all programming
languages that support the development of GUIs.
A program's graphical user interface presents an easy-to-use visual display to the user.
It is made up of graphical components (e.g., buttons, labels, windows) through which the user can
interact with the page or application.
To make graphical user interfaces in Java, use either Swing (older applications) or JavaFX.
JavaFX features an entirely different set of graphic components as well as a new terminology and
has many features that interface with web programming, such as support for Cascading Style
Sheets (CSS), a web component for embedding a web page inside an FX application, and the
functionality to play web multimedia content.
A GUI includes a range of user interface elements — which just means all the elements that display
when you are working in an application. These can include:
• Input controls such as buttons, dropdown lists, checkboxes, and text fields.
• Informational elements such as labels, banners, icons, or notification dialogs.
• Navigational elements, including sidebars, breadcrumbs, and menus.
Simple Login page using java Swing
Login.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Login extends JFrame {
JPanel pane = new JPanel();
JButton pressme = new JButton("Login");
Login() // the frame constructor
{
super("Project Demo"); setBounds(100,100,300,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container con = this.getContentPane(); // inherit main frame
con.add(pane); // JPanel containers default to FlowLayout
pressme.setMnemonic('P'); // associate hotkey to button
pane.add(pressme); pressme.requestFocus();
setVisible(true); // make frame visible
}
public static void main(String args[]) {
new Login();
}
}
To learn more you can follow the following link
1. https://www.cs.utexas.edu/~mitra/csSpring2009/cs313/lectures/GUIComponents.html
2. https://www.codeproject.com/Articles/33536/An-Introduction-to-Java-GUI-
Programming
3. https://www3.ntu.edu.sg/home/ehchua/programming/java/Javafx1_intro.html#:~:text=Ja
vaFX%20is%20a%20set%20of,Microsoft%20Silverlight%20and%20Java%20Applets).
4. https://www3.cs.stonybrook.edu/~pfodor/courses/CSE114/L14-JavaFXBasics.pdf

For more detailed learning about JavaFX you can follow the chapter of 14, 15 and 16 from the
book- Introduction_to_java_programming_by_Y_Daniel_Liang_10th_edition.
You can get the book from the following Link:
https://eduguidehome.files.wordpress.com/2019/02/introduction-to-java-programming-by-y-daniel-liang-
10th-edition.pdf

You might also like