package xTestx;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JSlider;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.Action;
import javax.swing.AbstractButton;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import java.awt.Font;
import java.awt.Point;
import java.awt.Dimension;
import java.awt.Label;
import java.awt.Container;
import java.awt.event.KeyEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.AbstractAction;
import preDefinedClassesSamples.DrawingBoard;
import preDefinedClassesSamples.DrawableShape;
public class Properties implements ChangeListener {
DrawableShape shape;
DrawingBoard drawingBoard;
// type of the shape
DrawableShape.Type shapeType;
// movement of the shape;
DrawingBoard.Movement shapeMovement;
// main window
JFrame propertiesWindow;
// sliders for the geometrical properties of the shape
JSlider widthSlider;
JSlider heightSlider;
JSlider pointXSlider;
JSlider pointYSlider;
// sliders for the color of the shape
JSlider redSlider;
JSlider greenSlider;
JSlider blueSlider;
// radio button options for the type of the shape
JRadioButton ellipse;
JRadioButton rectangle;
JRadioButton roundRect;
// radio button options for the movement of the shape
JRadioButton smooth;
JRadioButton random; // NOT USED
JRadioButton stationary;
// button for the confirmation that will set all the properties of the shape
JButton confirmation;
// labels for the sliders
JLabel widthLabel;
JLabel heightLabel;
JLabel pointXLabel;
JLabel pointYLabel;
JLabel redSliderLabel;
JLabel greenSliderLabel;
JLabel blueSliderLabel;
/**
* label which will be the representaion of the value that will be generated
* by the sliders
*/
JLabel widthFrequency;
JLabel heightFrequency;
JLabel pointXFrequency;
JLabel pointYFrequency;
JLabel redSliderFrequency;
JLabel greenSliderFrequency;
JLabel blueSliderFrequency;
// shape group's label
JLabel shapeGroupLabel;
// shape movements group's label
JLabel movementGroupLabel;
// button group for the shape selection radio buttons
ButtonGroup shapeGroup;
// button group for the shapes movement radio buttons
ButtonGroup shapeMovementGroup; // not used
// the spot where the slider color combination will be displayed
Label colorSpot;
// color spot label name
Label colorSpotName;
// color spot for each of the RGB sliders
Label redSpot;
Label greenSpot;
Label blueSpot;
// center point of the chape
Point shapeCenterPoint;
// dimension of the shape
Dimension shapeDimension;
// color of the shape
Color shapeColor;
// contant color for the RGB slider (Red)
private static final Color RED = new Color(180, 0, 0);
// contant color for the RGB slider (green)
private static final Color GREEN = new Color(0, 180, 0);
// contant color for the RGB slider (Blue)
private static final Color BLUE = new Color(0, 0, 180);
/**
* minimum value for the width of the shape, and the initialized value
* where the slider is pointing
*/
private static final int WIDTH_MIN_VALUE = 100;
// maximum value for width of the shape
private static final int WIDTH_MAX_VALUE = 500;
/**
* minimum value for the height of the shape, and the initialized value
* where the slider is pointing
*/
private static final int HEIGHT_MIN_VALUE = 100;
// maximum value for the height of the shape
private static final int HEIGHT_MAX_VALUE = 500;
/**
* minimum value for the center point (point x) of the shape, and the
* initialized value where the slider is pointing
*/
private static final int MIN_POINT_X = 200;
// maximum value for the center point (point x) of the shape
private static final int MAX_POINT_X = 800;
/**
* minimum value for the center point (point y) of the shape, and the
* initialized value where the slider is pointing
*/
private static final int MIN_POINT_Y = 100;
// maximum value for the center point (point y) of the shape
private static final int MAX_POINT_Y = 500;
// constant value for color scheme slider's minor tick
private static final int COLOR_SLIDER_MINOR_TICK = 5;
// constant value for color scheme slider's major tick
private static final int COLOR_SLIDER_MAJOR_TICK = 10;
// constant value of minor tick for the geometric pattern sliders
private static final int MINOR_TICK = 10;
// constant value of major tick for the geometric pattern sliders
private static final int MAJOR_TICK = 100;
// temporary placeholder for the shape selection
private String tempShape;
// constructs the components of this window
public Properties() {
drawingBoard = new DrawingBoard();
propertiesWindow = new JFrame("Screensaver Properties");
widthSlider = new JSlider(WIDTH_MIN_VALUE, WIDTH_MAX_VALUE, WIDTH_MIN_VALUE);
heightSlider = new JSlider(HEIGHT_MIN_VALUE, HEIGHT_MAX_VALUE, HEIGHT_MIN_VALUE);
pointXSlider = new JSlider(MIN_POINT_X, MAX_POINT_X, MIN_POINT_X);
pointYSlider = new JSlider(MIN_POINT_Y, MAX_POINT_Y, MIN_POINT_Y);
redSlider = new JSlider(SwingConstants.VERTICAL, 0, 255, 0);
greenSlider = new JSlider(SwingConstants.VERTICAL, 0, 255, 0);
blueSlider = new JSlider(SwingConstants.VERTICAL, 0, 255, 0);
ellipse = new JRadioButton();
rectangle = new JRadioButton();
roundRect = new JRadioButton();
smooth = new JRadioButton();
random = new JRadioButton();
stationary = new JRadioButton();
widthLabel = new JLabel("Width : ");
heightLabel = new JLabel("Height : ");
pointXLabel = new JLabel("Center Point (point x) : ");
pointYLabel = new JLabel("Center Point (point y) : ");
redSliderLabel = new JLabel("Red : ");
greenSliderLabel = new JLabel("Green : ");
blueSliderLabel = new JLabel("Blue : ");
colorSpot = new Label();
widthFrequency = new JLabel("" + WIDTH_MIN_VALUE);
heightFrequency = new JLabel("" + HEIGHT_MIN_VALUE);
pointXFrequency = new JLabel("" + MIN_POINT_X);
pointYFrequency = new JLabel("" + MIN_POINT_Y);
redSliderFrequency = new JLabel("0");
greenSliderFrequency = new JLabel("0");
greenSliderFrequency = new JLabel("0");
blueSliderFrequency = new JLabel("0");
shapeGroupLabel = new JLabel();
movementGroupLabel = new JLabel(); // not used
shapeGroup = new ButtonGroup();
shapeMovementGroup = new ButtonGroup(); // not used
redSpot = new Label();
greenSpot = new Label();
blueSpot = new Label();
}
public void setTheShapeProperties(Container cont) {
// set the slider labels properties and location
widthLabel.setBounds(15, 10, 50, 50);
heightLabel.setBounds(15, 130, 70, 50);
pointXLabel.setBounds(15, 260, 200, 50);
pointYLabel.setBounds(15, 385, 200, 50);
redSliderLabel.setBounds(400, 20, 50, 30);
greenSliderLabel.setBounds(580, 20, 50, 30);
blueSliderLabel.setBounds(760, 20, 50, 30);
// set the Red slider's color spot properties
redSpot.setBounds(380, 30, 13, 11);
redSpot.setBackground(Color.BLACK);
// set the Green slider's color spot properties
greenSpot.setBounds(560, 30, 13, 11);
greenSpot.setBackground(Color.BLACK);
// set the Blue slider's color spot properties
blueSpot.setBounds(740, 30, 13, 11);
blueSpot.setBackground(Color.BLACK);
// set the sliders frequencies' location and dimension
widthFrequency.setBounds(60, 10, 50, 50);
heightFrequency.setBounds(60, 120, 70, 50);
pointXFrequency.setBounds(145, 240, 40, 50);
pointYFrequency.setBounds(145, 365, 40, 50);
redSliderFrequency.setBounds(450, 10, 50, 50);
greenSliderFrequency.setBounds(640, 10, 50, 50);
blueSliderFrequency.setBounds(810, 10, 50, 50);
// set the width slider properties
widthSlider.setBounds(15, 60, 320, 50);
widthSlider.setMinorTickSpacing(MINOR_TICK);
widthSlider.setMajorTickSpacing(MAJOR_TICK);
widthSlider.setPaintTicks(true);
widthSlider.setPaintLabels(true);
widthSlider.setToolTipText("Width");
widthSlider.addChangeListener(this);
// set the height slider properties
heightSlider.setBounds(15, 170, 320, 50);
heightSlider.setMinorTickSpacing(MINOR_TICK);
heightSlider.setMajorTickSpacing(MAJOR_TICK);
heightSlider.setPaintTicks(true);
heightSlider.setPaintLabels(true);
heightSlider.setToolTipText("Height");
heightSlider.addChangeListener(this);
// set the point x slider (center point x) properties
pointXSlider.setBounds(15, 295, 320, 50);
pointXSlider.setMinorTickSpacing(MINOR_TICK);
pointXSlider.setMajorTickSpacing(MAJOR_TICK);
pointXSlider.setPaintTicks(true);
pointXSlider.setPaintLabels(true);
pointXSlider.setToolTipText("Center Point (x)");
pointXSlider.addChangeListener(this);
// set the point y slider (centern point y) properties
pointYSlider.setBounds(15, 420, 320, 50);
pointYSlider.setMinorTickSpacing(MINOR_TICK);
pointYSlider.setMajorTickSpacing(MAJOR_TICK);
pointYSlider.setPaintTicks(true);
pointYSlider.setPaintLabels(true);
pointYSlider.setToolTipText("Center Point (y)");
pointYSlider.addChangeListener(this);
// set the red slider properties
redSlider.setBounds(400, 50, 30, 420);
redSlider.setForeground(RED);
redSlider.setMinorTickSpacing(COLOR_SLIDER_MINOR_TICK);
redSlider.setMajorTickSpacing(COLOR_SLIDER_MAJOR_TICK);
redSlider.setPaintTicks(true);
redSlider.setToolTipText("Red");
redSlider.addChangeListener(this);
// set the green slider properties
greenSlider.setBounds(580, 50, 30, 420);
greenSlider.setForeground(GREEN);
greenSlider.setMinorTickSpacing(COLOR_SLIDER_MINOR_TICK);
greenSlider.setMajorTickSpacing(COLOR_SLIDER_MAJOR_TICK);
greenSlider.setPaintTicks(true);
greenSlider.setToolTipText("Green");
greenSlider.addChangeListener(this);
// set the blue slider properties
blueSlider.setBounds(760, 50, 30, 420);
blueSlider.setForeground(BLUE);
blueSlider.setMinorTickSpacing(COLOR_SLIDER_MINOR_TICK);
blueSlider.setMajorTickSpacing(COLOR_SLIDER_MAJOR_TICK);
blueSlider.setPaintTicks(true);
blueSlider.setToolTipText("Blue");
blueSlider.addChangeListener(this);
// set the properties of the color spot
colorSpot.setText("Shape's Color.");
colorSpot.setFont(new Font("Monospaced",Font.CENTER_BASELINE ,30));
colorSpot.setAlignment(Label.CENTER);
colorSpot.setForeground(Color.WHITE);
colorSpot.setBounds(400, 490, 400, 90);
colorSpot.setBackground(Color.BLACK);
// set the confirmation button's properties and actions
Action action = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
shapeProperties();
}
};
action.putValue(AbstractAction.NAME, "Procced To Screensaver");
confirmation = new JButton(action);
confirmation.setBounds(900, 570, 175, 30);
confirmation.setMnemonic(KeyEvent.VK_ENTER);
// set the action for the radio buttons
ActionListener shapeSelectionAction = new ActionListener() {
public void actionPerformed(ActionEvent event) {
AbstractButton actionButton = (AbstractButton) event.getSource();
String tempShape = actionButton.getText();
/**
* lets make sure that whatever the string format that the
* button will return, it will still match the condition to
* set the proper shape type of the shape.
*
* So just in case, the string label of the radio button
* accidentally or intentionally changed, this condition will still
* generate matching string format.
*
* And a default shape will be generated, just in case.
*/
if (tempShape.equalsIgnoreCase("Ellipse")) {
shapeType = DrawableShape.Type.ELLIPSE;
}
else if (tempShape.equalsIgnoreCase("Rectangle")) {
shapeType = DrawableShape.Type.RECTANGLE;
}
else if (tempShape.equalsIgnoreCase("Rounded Rectangle")) {
shapeType = DrawableShape.Type.ROUNDED_RECTANGLE;
}
else {
shapeType = DrawableShape.Type.ELLIPSE;
}
}
};
ellipse.addActionListener(shapeSelectionAction);
rectangle.addActionListener(shapeSelectionAction);
roundRect.addActionListener(shapeSelectionAction);
// set the shape group's label's properties
shapeGroupLabel.setText("Select A Shape :");
shapeGroupLabel.setBounds(880, 80, 100, 15);
// set the properties of the ellipse radio button
ellipse.setText("Ellipse");
ellipse.setToolTipText("Ellise");
ellipse.setBounds(890, 105, 65, 20);
// set the properties of the rectangle radio button
rectangle.setText("Rectangle");
rectangle.setToolTipText("Rectangle");
rectangle.setBounds(890, 135, 85, 20);
// set the properties of the rounded rectangle radio button
roundRect.setText("Rounded Rectangle");
roundRect.setToolTipText("Rounded Rectangle");
roundRect.setBounds(890, 165, 135, 20);
// make the group for the shapes' radio buttons
shapeGroup.add(ellipse);
shapeGroup.add(rectangle);
shapeGroup.add(roundRect);
// set the action and properties of the shape movement radio buttons
ActionListener movementSelectionAction = new ActionListener() {
public void actionPerformed(ActionEvent event) {
AbstractButton actionButton = (AbstractButton) event.getSource();
String tempMovement = actionButton.getText();
/**
* same style done in shape's type radio buttons
*/
if (tempMovement.equalsIgnoreCase("Smooth")) {
shapeMovement = DrawingBoard.Movement.SMOOTH;
}
else if (tempMovement.equalsIgnoreCase("Random")) {
shapeMovement = DrawingBoard.Movement.RANDOM;
}
else if (tempMovement.equalsIgnoreCase("Stationary")) {
shapeMovement = DrawingBoard.Movement.STATIONARY;
}
// default shape will be generated just in case
else {
shapeMovement = DrawingBoard.Movement.SMOOTH;
}
}
};
smooth.addActionListener(movementSelectionAction);
random.addActionListener(movementSelectionAction);
stationary.addActionListener(movementSelectionAction);
// set the movement group's label's properties
movementGroupLabel.setText("Select A Movement :");
movementGroupLabel.setBounds(880, 250, 120, 15);
movementGroupLabel.setBackground(Color.RED);
// set the properties of the "smooth" radio button
smooth.setText("Smooth");
smooth.setBounds(890, 280, 100, 20);
// set the properties of the "random" radio button
random.setText("Random");
random.setBounds(890, 310, 100, 20);
// set the properties of the "staionary" radio button
stationary.setText("Stationary");
stationary.setBounds(890, 340, 100, 20);
// make the group for the shape's movement radio buttons
shapeMovementGroup.add(smooth);
shapeMovementGroup.add(random);
shapeMovementGroup.add(stationary);
/**
* sets the layout to null, no layout will be used,
* this is an absolute positioning of the components
*/
cont.setLayout(null);
// add the sliders
cont.add(widthSlider);
cont.add(heightSlider);
cont.add(pointXSlider);
cont.add(pointYSlider);
cont.add(redSlider);
cont.add(greenSlider);
cont.add(blueSlider);
// add the slider labels as well as their frequencies
cont.add(widthLabel);
cont.add(widthFrequency);
cont.add(heightLabel);
cont.add(heightFrequency);
cont.add(pointXLabel);
cont.add(pointXFrequency);
cont.add(pointYLabel);
cont.add(pointYFrequency);
cont.add(redSliderLabel);
cont.add(redSpot);
cont.add(redSliderFrequency);
cont.add(greenSliderLabel);
cont.add(greenSpot);
cont.add(greenSliderFrequency);
cont.add(blueSliderLabel);
cont.add(blueSpot);
cont.add(blueSliderFrequency);
cont.add(colorSpot);
// add the confirmation button
cont.add(confirmation);
// add the label of the shape radio buttons group
cont.add(shapeGroupLabel);
// add the shape type radio buttons
cont.add(ellipse);
cont.add(rectangle);
cont.add(roundRect);
//add the label of the shape's movement radio button group
cont.add(movementGroupLabel);
// add the shape's movement type radio buttons
cont.add(smooth);
cont.add(random);
cont.add(stationary);
}
public void stateChanged(ChangeEvent event) {
if (event.getSource() == redSlider || event.getSource() == greenSlider ||
event.getSource() == blueSlider) {
int tempRed = redSlider.getValue();
int tempGreen = greenSlider.getValue();
int tempBlue = blueSlider.getValue();
redSliderFrequency.setText("" + tempRed);
greenSliderFrequency.setText("" + tempGreen);
blueSliderFrequency.setText("" + tempBlue);
/**
* check if the color combination on the color spot is too light,
* then the colorSpot's text must be black for the user to see the text
*/
if ((tempRed >= 200) && (tempRed <= 255)) {
if ((tempGreen >= 200) && (tempGreen <= 255)) {
if ((tempBlue >= 200) && (tempBlue <= 255)) {
colorSpot.setForeground(Color.BLACK);
}
}
}
// else make it white
else if ((tempRed <= 60) && (tempRed >= 0)) {
if ((tempGreen <= 60) && (tempGreen >= 0)) {
if ((tempBlue <= 60) && (tempBlue >= 0)) {
colorSpot.setForeground(Color.WHITE);
}
}
}
// sets the color of the shape
shapeColor = new Color(tempRed, tempGreen, tempBlue);
/** sets the color of the frequency,text labels and the color spot
* for each of the color sliders
*/
// for red:
redSliderLabel.setForeground(new Color(tempRed, 0, 0));
redSliderFrequency.setForeground(new Color(tempRed, 0, 0));
redSpot.setBackground(new Color(tempRed, 0, 0));
// for green:
greenSliderLabel.setForeground(new Color(0, tempGreen, 0));
greenSliderFrequency.setForeground(new Color(0, tempGreen, 0));
greenSpot.setBackground(new Color(0, tempGreen, 0));
// for blue:
blueSliderLabel.setForeground(new Color(0, 0, tempBlue));
blueSliderFrequency.setForeground(new Color(0, 0, tempBlue));
blueSpot.setBackground(new Color(0, 0, tempBlue));
/**
* set the color of the color spot corresponding to the color combination
* generated by the RGB color sliders.
*/
colorSpot.setBackground(shapeColor);
}
if (event.getSource() == widthSlider || event.getSource() == heightSlider) {
int shapeWidth = widthSlider.getValue();
int shapeHeight = heightSlider.getValue();
widthFrequency.setText("" + shapeWidth);
heightFrequency.setText("" + shapeHeight);
/**
* set the dimension of the shape, the default dimension as well,
* if the width and heigh sliders hasn't moved
*/
shapeDimension = new Dimension(shapeWidth, shapeHeight);
}
if (event.getSource() == pointXSlider || event.getSource() == pointYSlider) {
int shapePointX = pointXSlider.getValue();
int shapePointY = pointYSlider.getValue();
pointXFrequency.setText("" + shapePointX);
pointYFrequency.setText("" + shapePointY);
/**
* set the center point of the shape, the deafult centerpoint as well,
* if the centerpoint (x,y) sliders has'nt moved
*/
shapeCenterPoint = new Point(shapePointX, shapePointY);
}
}
/**
* set the properties of the shape, and use default properties if there will
* be any error occured.
*/
private void shapeProperties() {
// count for the properties that will be selected
int selectedCount = 0;
/**
* temporary place holder for string representaion of any properties
* that will be selected
*/
String tempSelected[];
/**
* temporary place holder for the string representaion of the properties
* that will not be selected
*/
String tempNull[];
int count = 0;
tempSelected = new String[5];
tempNull = new String[5];
/**
* check if the shape's type is selected, then add a string representaion
* that will correspond to this selected property
*/
if (shapeType != null) {
for (int x = 0; x < 5; x++) {
if (tempSelected[x] == null) {
count++;
if (count == 1) {
tempSelected[x] = "type";
}
}
}
selectedCount++;
}
/**
* else if the shape type is null, then use a default shape type, and
* add a string representaion that will correspond to this unselected
* property
*/
else {
for (int x = 0; x < 5; x++) {
if (tempNull[x] == null) {
count++;
if (count == 1) {
tempNull[x] = "type";
}
}
}
shapeType = DrawableShape.Type.ELLIPSE;
}
/**
* check if the shape's movement is selected, add a string representaion
* that will correspond to this selected property
*/
if (shapeMovement != null) {
count = 0;
for (int x = 0; x < 5; x++) {
if (tempSelected[x] == null) {
count++;
if (count == 1) {
tempSelected[x] = "movement";
}
}
}
selectedCount++;
}
/**
* else if shape's movement is null, use a default instead and add a string
* representaion that will represent this unselected property
*/
else {
count = 0;
for (int x = 0; x < 5; x++) {
if (tempNull[x] == null) {
count++;
if (count == 1) {
tempNull[x] = "movement";
}
}
}
shapeMovement = DrawingBoard.Movement.SMOOTH;
}
/**
* check if the shape's dimension has been selected, add a string
* representaion that will represent this selected property
*/
if (shapeDimension != null) {
count = 0;
for (int x = 0; x < 5; x++) {
if (tempSelected[x] == null) {
count++;
if (count == 1) {
tempSelected[x] = "dimension";
}
}
}
selectedCount++;
}
/**
* else if shape's dimension is null, use a default instead and add
* a string representaion that will represent this unselected property
*/
else {
count = 0;
for (int x = 0; x < 5; x++) {
if (tempNull[x] == null) {
count++;
if (count == 1) {
tempNull[x] = "dimension";
}
}
}
shapeDimension = new Dimension(WIDTH_MIN_VALUE, HEIGHT_MIN_VALUE);
}
/**
* check if this property has been selected, add a string representation
* that will represent this selected property;
*/
if (shapeCenterPoint != null) {
count = 0;
for (int x = 0; x < 5; x++) {
if (tempSelected[x] == null) {
count++;
if (count == 1) {
tempSelected[x] = "center point";
}
}
}
selectedCount++;
}
/**
* else if this property is null, use a default instead, then add a
* string representaion that will represent this unselected property
*/
else {
count = 0;
for (int x = 0; x < 5; x++) {
if (tempNull[x] == null) {
count++;
if (count == 1) {
tempNull[x] = "center point";
}
}
}
shapeCenterPoint = new Point(MIN_POINT_X, MIN_POINT_Y);
}
/**
* check if this property has been selected, add a string representaion
* that will represent this selected property
*/
if (shapeColor != null) {
count = 0;
for (int x = 0; x < 5; x++) {
if (tempSelected[x] == null) {
count++;
if (count == 1) {
tempSelected[x] = "color";
}
}
}
selectedCount++;
}
/**
* else if this property is null, add a string representation that
* will represent this unselected property
*/
else {
count = 0;
for (int x = 0; x < 5; x++) {
if(tempNull[x] == null) {
count++;
if (count == 1) {
tempNull[x] = "color";
}
}
}
shapeColor = Color.WHITE;
}
System.out.println(tempSelected[0]);
System.out.println(tempSelected[1]);
System.out.println(tempSelected[2]);
System.out.println(tempSelected[3]);
System.out.println(tempSelected[4]);
System.out.println("\n\n\n\n\n");
System.out.println(tempNull[0]);
System.out.println(tempNull[1]);
System.out.println(tempNull[2]);
System.out.println(tempNull[3]);
System.out.println(tempNull[4]);
/**
* this will serve as the count for the indexes in the array that holds
* the string value that will be displayed
*/
int value = 0;
if (selectedCount == 1) {
JOptionPane.showMessageDialog(null, "You only selected the shape's " + tempSelected[value],
"Message", JOptionPane.WARNING_MESSAGE);
int response = JOptionPane.showConfirmDialog(null, "Use Default " + tempNull[value++] + ", " + tempNull[value++] + ", " +
tempNull[value++] + " and " + tempNull[value++] + " ?", "Default",
JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
shape = new DrawableShape(shapeType, shapeDimension, shapeCenterPoint, shapeColor);
proceedToScreensaver();
}
else if (response == JOptionPane.NO_OPTION) {
// NOT YET IMPLEMENTED
}
}
else if (selectedCount == 2) {
JOptionPane.showMessageDialog(null, "You only selected the shape's " + tempSelected[value++] +
" and " + tempSelected[value++]);
}
else if (selectedCount == 3) {
JOptionPane.showMessageDialog(null, "You only selected the shape's " + tempSelected[value++] + ", " +
tempSelected[value++] + " and " + tempSelected[value++]);
}
else if (selectedCount == 4) {
JOptionPane.showMessageDialog(null, "You only selected the shape's " + tempSelected[value++] + ", " +
tempSelected[value++] + ", " + tempSelected[value++] + " and " + tempSelected[value++]);
}
else if (selectedCount == 5) {
JOptionPane.showMessageDialog(null, "You did not select anything", "Message",
JOptionPane.WARNING_MESSAGE);
}
}
private void proceedToScreensaver() {
drawingBoard.setDelayTime(0.000000009);
drawingBoard.addShape(shape);
drawingBoard.setMovement(shapeMovement);
drawingBoard.setVisible(true);
drawingBoard.start();
}
/**
* just to lessen the coding time if the there is an error occured
* when modifying the properties of the shape
*/
private void noOption() {
JOptionPane.showMessageDialog(null, "Unable to proceed due to inconsistency of the properties.",
"Error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
public void showTheScreensaverWindow() {
setTheShapeProperties(propertiesWindow.getContentPane());
propertiesWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
propertiesWindow.setSize(1100, 650);
propertiesWindow.setLocation(275, 100);
propertiesWindow.setResizable(true);
propertiesWindow.setVisible(true);
}
// main
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
Properties screenSaver = new Properties();
public void run() {
screenSaver.showTheScreensaverWindow();
}
});
}
}