Advertisement
dramaquinn

Untitled

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