On what specific part of the program were the awt and javax.swing packages used? Explain how.  On what specific part of the program was the awt.event package used? Explain how.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
  1. On what specific part of the program were the awt and javax.swing packages used? Explain how. 
  2. On what specific part of the program was the awt.event package used? Explain how. 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class NewFrame extends JFrame implements ActionListener {
JButton Evaluate;
JTextField txt_enter;
JLabel lbl_enter;
NewFrame() {
setlayout (null);
setsize( width: 300, height: 100);
Evaluate = new JButton( text: "Evaluate");
txt_enter = new JTextField();
lbl_enter = new JLabel( text: "Enter:");
add(Evaluate);
add(txt_enter);
add(lbl_enter);
lbl_enter.setBounds ( x: 30, y: 20, width: 50, height: 30);
txt_enter.setBounds ( x: 80, y: 20, width: 50, height: 30);
Evaluate.setBounds( x: 140, y: 20, width: 100, height: 30);
setVisible(true);
setResizable(false);
Evaluate.addActionListener ( I: this);
this.getContentPane().setBackground(Color.gray);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource () ==Evaluate){
int n;
Integer.parseInt(txt_enter.getText());
if ( n % 2 == 0 )
J0ptionPane.showMessageDialog( parentComponent: nulı, message: "Integer is EVEN");
n
%3D
else
J0ptionPane.showMessageDialog( parentComponent: null, message: "Integer is ODD");
}
Transcribed Image Text:import java.awt.*; import java.awt.event.*; import javax.swing.*; public class NewFrame extends JFrame implements ActionListener { JButton Evaluate; JTextField txt_enter; JLabel lbl_enter; NewFrame() { setlayout (null); setsize( width: 300, height: 100); Evaluate = new JButton( text: "Evaluate"); txt_enter = new JTextField(); lbl_enter = new JLabel( text: "Enter:"); add(Evaluate); add(txt_enter); add(lbl_enter); lbl_enter.setBounds ( x: 30, y: 20, width: 50, height: 30); txt_enter.setBounds ( x: 80, y: 20, width: 50, height: 30); Evaluate.setBounds( x: 140, y: 20, width: 100, height: 30); setVisible(true); setResizable(false); Evaluate.addActionListener ( I: this); this.getContentPane().setBackground(Color.gray); } public void actionPerformed(ActionEvent e) { if(e.getSource () ==Evaluate){ int n; Integer.parseInt(txt_enter.getText()); if ( n % 2 == 0 ) J0ptionPane.showMessageDialog( parentComponent: nulı, message: "Integer is EVEN"); n %3D else J0ptionPane.showMessageDialog( parentComponent: null, message: "Integer is ODD"); }
import javax. swing.*;|
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class GUI1 implements ActionListener {
public GUI1(){
JFrame frame = new JFrame();
JLabel label = new JLabel( text: "Program uses Java GUI message and input dialogs.");
JLabel label2 = new JLabel( text: "Program evaluates integers as even or odd.");
ImageIcon icon = new ImageIcon( filename: "icon.png");
JButton button = new JButton( text: "OK");
button.addActionListener( l: this);
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEmptyBorder( top: 0, left: 30, bottom: 10, right: 30));
panel.setlayout(new GridLayout( rows: 0, cols: 1));
JLabel image = new JLabel(icon);
panel.add(image);
panel.add (label);
panel.add (label2);
panel.add (button);
frame.add(panel);
frame.setDefaultcloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setIconImage(icon.getImage());
frame.setTitle("Message");
frame.pack();
frame.setVisible(true);
}
@0verride
public void actionPerformed (ActionEvent e) {
new NewFrame();
public static void main(String[] args) {
new GUI1();
Transcribed Image Text:import javax. swing.*;| import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class GUI1 implements ActionListener { public GUI1(){ JFrame frame = new JFrame(); JLabel label = new JLabel( text: "Program uses Java GUI message and input dialogs."); JLabel label2 = new JLabel( text: "Program evaluates integers as even or odd."); ImageIcon icon = new ImageIcon( filename: "icon.png"); JButton button = new JButton( text: "OK"); button.addActionListener( l: this); JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder( top: 0, left: 30, bottom: 10, right: 30)); panel.setlayout(new GridLayout( rows: 0, cols: 1)); JLabel image = new JLabel(icon); panel.add(image); panel.add (label); panel.add (label2); panel.add (button); frame.add(panel); frame.setDefaultcloseOperation(JFrame.EXIT_ON_CLOSE); frame.setIconImage(icon.getImage()); frame.setTitle("Message"); frame.pack(); frame.setVisible(true); } @0verride public void actionPerformed (ActionEvent e) { new NewFrame(); public static void main(String[] args) { new GUI1();
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Events
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education