From bdd459335064391b198aa11ffb8a906b787bcbdf Mon Sep 17 00:00:00 2001 From: sowgro Date: Mon, 1 May 2023 09:24:55 -0400 Subject: add test button --- apcs/Driver.java | 2 +- apcs/Gui.java | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) (limited to 'apcs') diff --git a/apcs/Driver.java b/apcs/Driver.java index eba7238..a3b4c6c 100644 --- a/apcs/Driver.java +++ b/apcs/Driver.java @@ -12,7 +12,7 @@ public class Driver public static void main(String[] args) { - + new Gui(); } } diff --git a/apcs/Gui.java b/apcs/Gui.java index 1fca6bc..934c371 100644 --- a/apcs/Gui.java +++ b/apcs/Gui.java @@ -6,8 +6,36 @@ */ package apcs; - -public class Gui -{ - +import javax.swing.JButton; +import javax.swing.JFrame; +public class Gui { + public Gui() + { + /* JFrame is a top level container (window) + * where we would be adding our button + */ + JFrame frame=new JFrame(); + + // Creating Button + JButton b=new JButton("Click Me.."); + /* This method specifies the location and size + * of button. In method setBounds(x, y, width, height) + * x,y) are cordinates from the top left + * corner and remaining two arguments are the width + * and height of the button. + */ + b.setBounds(50,50,200, 50); + + //Adding button onto the frame + frame.add(b); + + // Setting Frame size. This is the window size + frame.setSize(600,500); + + frame.setLayout(null); + frame.setVisible(true); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + } } -- cgit v1.2.3