Lecture-3.1.6
Lecture-3.1.6
DEPARTMENT : CSE
Bachelor of Engineering (Computer Science & Engineering)
Java Programming (20CST-218)
TOPIC OF PRESENTATION:
2
Java JButton
The JButton class is used to create a labeled button that has platform independent
implementation. The application result in some action when the button is pushed. It inherits
AbstractButton class.
Unlike Frame, JFrame has the option to hide or close the window with the help of
setDefaultCloseOperation(int) method.
JFrame Example
public class JFrameExample {
public static void main(String s[]) {
JFrame frame = new JFrame("JFrame Example");
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
JLabel label = new JLabel("JFrame By Example");
JButton button = new JButton();
button.setText("Button");
panel.add(label);
panel.add(button);
frame.add(panel);
frame.setSize(200, 300);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
MCQ
JButton class inherits
Button
ComboButton
AbstractButton
None
10
Summary:
Video Lectures :
https://youtu.be/FY3g4gGPhio
Reference Links:
https://www.javatpoint.com/java-jframe
https://www.javatpoint.com/java-jbutton
https://www.javatpoint.com/java-swing
http://zetcode.com/javaswing/basicswingcomponents/
THANK YOU