Skip to content

Commit

Permalink
specify parent component in dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
creme332 committed Aug 7, 2024
1 parent fee0976 commit 16f1012
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private int inputRadius() {
}
return radius;
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Invalid input. Please enter a positive integer for the radius.",
JOptionPane.showMessageDialog(canvas, "Invalid input. Please enter a positive integer for the radius.",
"Error", JOptionPane.ERROR_MESSAGE);
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private int[] inputRadii() {
}
return new int[] { rx, ry };
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Invalid input. Please enter positive integers for the radii.",
JOptionPane.showMessageDialog(canvas, "Invalid input. Please enter positive integers for the radii.",
"Error", JOptionPane.ERROR_MESSAGE);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private int inputVertices() {
}
return numSides;
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null,
JOptionPane.showMessageDialog(canvas,
"Invalid input. Please enter an integer greater than or equal to 3 for the number of vertices.",
"Error", JOptionPane.ERROR_MESSAGE);
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private RotationDetails requestRotationDetails() {
boolean isClockwise = clockwiseButton.isSelected();
return new RotationDetails(angle, new Point2D.Double(pivotX, pivotY), isClockwise);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.showMessageDialog(canvas, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.ERROR_MESSAGE);
// Handle invalid input gracefully, return default rotation details
return new RotationDetails(0, new Point2D.Double(0, 0), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private Point2D requestScalingPoint() {
double y = Double.parseDouble(yField.getText());
return new Point2D.Double(x, y);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.showMessageDialog(canvas, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.ERROR_MESSAGE);
return new Point2D.Double(0, 0); // Default value if input is invalid
}
Expand Down Expand Up @@ -100,7 +100,7 @@ private double[] requestScalingFactors() {
double sy = Double.parseDouble(syField.getText());
return new double[] { sx, sy };
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.showMessageDialog(canvas, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.ERROR_MESSAGE);
return new double[] { 1.0, 1.0 }; // Default scaling factors if input is invalid
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private double[] requestShearFactors() {

return shearFactors;
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.showMessageDialog(canvas, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.ERROR_MESSAGE);
return shearFactors;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private Point2D requestTranslationVector() {
double y = Double.parseDouble(ryField.getText());
return new Point2D.Double(x, y);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.showMessageDialog(canvas, "Invalid input! Please enter valid numbers.", "Error",
JOptionPane.ERROR_MESSAGE);
return zeroVector;
}
Expand Down

0 comments on commit 16f1012

Please sign in to comment.