About 55,700,000 results
Open links in new tab
  1. Create the square, rectangle, triangle of java in jframe

    Jan 30, 2017 · To draw a square we need to know that: A square has a width and a height, both are equal size; The way to draw a square in Swing is with drawRect(x, y, width, height) …

  2. How To Draw A Square In Java: A Step-By-Step Guide

    Jul 6, 2023 · Drawing a square in Java involves creating a square class that stores the side length and provides methods to calculate the area and display the characteristics. By understanding …

  3. Java Lesson 21: Drawing and Coloring Shapes on the JFrame

    Dec 16, 2021 · If you wanted to draw a square, use the .drawRect() method. After all, when you think about it, a square is basically a modified rectangle.

  4. Java programming, create your own square class, which allows ... - YouTube

    package ch3cw_2;import java.awt.Graphics2D;import java.awt.Rectangle;public class Square { private int sideLength; private int xLeft; private int yTop; publ...

  5. How to draw a square in java? - Stack Overflow

    Feb 4, 2015 · You are to write a program that draws a square composed of # signs onto a grid. The user will enter the size (in the length of the sides), the x-coordinate, and the y-coordinate …

  6. draw - Drawing a "Square" in Java - Stack Overflow

    Apr 19, 2016 · I am trying to draw a "square" in Java using asterisks. I have a square class with an input parameter, I am trying to get the method to output lines of " " so that there are as …

  7. java - how to create a square using for loops - Stack Overflow

    Nov 19, 2013 · Based on your example, you want a square box of characters enclosing some whitespace, correct? This fundamentally breaks down into two different lines. These are the …

  8. java - How to create a square with numbers? - Stack Overflow

    Apr 18, 2018 · Modulus is the ideal option to handle cases like this. Modulus (%) gives the remainder of one number divided by another, so (i+j) % 4 always gives a result between 0 and …

  9. java - nested for loops making square - Stack Overflow

    May 7, 2025 · You are printing a full square in the second loop. The first one is producing multiple squares. Try this code:

  10. Java: How to square a number - alvinalexander.com

    Jul 30, 2024 · You can square a number in Java in at least two different ways: Multiply the number by itself; Call the Math.pow function; The following examples demonstrate these …

Refresh