mirror of
https://bitbucket.org/Mattrixwv/javatutorials.git
synced 2025-12-06 18:43:58 -05:00
Added a program that draws some simple shapes
This commit is contained in:
28
ShapesTest.java
Normal file
28
ShapesTest.java
Normal file
@@ -0,0 +1,28 @@
|
||||
//Programs/Java/JavaTutorials/Shapes.java
|
||||
//Matthew Ellison
|
||||
// Created: 02-12-19
|
||||
//Modified: 002-12-19
|
||||
//Demonstration of drawing rectangles and ovals
|
||||
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
|
||||
public class ShapesTest{
|
||||
public static void main(String[] argv){
|
||||
//Get the user's choice
|
||||
String input = JOptionPane.showInputDialog("Enter 1 to draw rectangles\nEnter2 to draw ovals");
|
||||
//Convert the input to an int
|
||||
int choice = Integer.parseInt(input);
|
||||
//Create the panel with the shapes drawn on it
|
||||
Shapes panel = new Shapes(choice);
|
||||
//Create a new frame
|
||||
JFrame application = new JFrame();
|
||||
|
||||
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
application.add(panel);
|
||||
application.setSize(300, 300);
|
||||
application.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user