Advertisement
dramaquinn

Lab1_Intro

Jan 26th, 2022
1,359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. /**************************
  2.  *Program Name: Lab1'
  3.  
  4.  *
  5.  *Student Name: Alvie Thai
  6.  *Semester: Fall 2021
  7.  *Class & Section: COSC 10403-080
  8.  *Instructor: Dr. Bo Mei
  9.  *Due Date: Sep 2,2021
  10.  *
  11.  *Program Overview:
  12.  *  This program creates a simple window with one label and
  13.  *  two buttons
  14.  *
  15.  *Input: There is no user input to this program
  16.  *
  17.  *Output:
  18.  *   A window with 1 label and 2 buttons
  19.  *
  20.  *Program Limitations:
  21.  *      The buttons are clickable, but are not functional.
  22.  *
  23.  *Significant Program Variables (Component Names):
  24.  *    myLabel--variable  that carries Two-Button Frame message
  25.  *    startButton--variable that carries the Start button
  26.  *    haltButton-variable that carries the Halt button
  27.  **************************/
  28. import java.awt.*;
  29.  
  30.  
  31.  
  32. import javax.swing.*;
  33. public class Lab1 extends JFrame{
  34.     // name the components
  35.     JLabel myLabel;
  36.     JButton startButton;
  37.     JButton haltButton;
  38.     // Connect this program with the computer
  39.     public static void main (String args[]) {
  40.         new Lab1();
  41.     }
  42. public Lab1() {
  43.     //Setup a window
  44.     setSize(300,100);
  45.     //Set the title for the window
  46.     setTitle ("Pop-Up Window");
  47.     setLayout(new FlowLayout());
  48.     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  49.     // Setup a label
  50.     myLabel= new JLabel("Two-Button Frame");
  51.     //Create a component for the Start Button
  52.     startButton= new JButton("Hi");
  53.     //Create a component for the Halt Button
  54.     haltButton= new JButton("Halt");
  55.     //Add the components into the pop-up window
  56.     add(startButton);
  57.     add(myLabel);
  58.     add(haltButton);
  59.     //Show the window
  60.     setVisible(true);
  61. }
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement