Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**************************
- *Program Name: Lab1
- *
- *Student Name: Alvie Thai
- *Semester: Fall 2021
- *Class & Section: COSC 10403-080
- *Instructor: Dr. Bo Mei
- *Due Date: Sep 2,2021
- *
- *Program Overview:
- * This program creates a simple window with one label and
- * two buttons
- *
- *Input: There is no user input to this program
- *
- *Output:
- * A window with 1 label and 2 buttons
- *
- *Program Limitations:
- * The buttons are clickable, but are not functional.
- *
- *Significant Program Variables (Component Names):
- * myLabel--Label that carries :"Pop-up window" message
- * startButton--variable that carries the Start button
- * haltButton-variable that carries the Halt button
- **************************/
- import java.awt.*;
- import javax.swing.*;
- public class Lab1 extends JFrame{
- // name the components
- JLabel myLabel;
- JButton startButton;
- JButton haltButton;
- // Connect this program with the computer
- public static void main (String args[]) {
- new Lab1();
- }
- public Lab1() {
- //Setup a window
- setSize(300,100);
- //Set the title for the pop-up window
- setTitle ("Pop-Up Window");
- setLayout(new FlowLayout());
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- // Setup a label
- myLabel= new JLabel("Two-Button Frame");
- //Create a component for the Start Button
- startButton= new JButton("Start");
- //Create a component for the Halt Button
- haltButton= new JButton("Halt");
- //Add the components into the pop-up window
- add(startButton);
- add(myLabel);
- add(haltButton);
- //Show the window
- setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement