how to create a Rectangle in java
import javax.swing.JFrame;
import java.awt.Rectangle;
import javax.swing.JComponent;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.Color;
public class ChrismasTree {
public static void main(String[] args) {
JFrame window = new JFrame();
window.setTitle("Christmas Tree");
window.setSize(800, 1000);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
DrawingComponent DC = new DrawingComponent();
window.add(DC);
}
}
class DrawingComponent extends JComponent{
public void paint(Graphics graph0){
Graphics2D graph = (Graphics2D) graph0;
graph.setColor(Color.LIGHT_GRAY);
graph.draw(new Rectangle(0, 710, 70, 60));
graph.setColor(Color.BLUE);
graph.draw(new Rectangle(70, 600, 50, 100));
graph.setColor(Color.BLACK);
}
}
Also in Java:
- java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.security.MessageDigest$Delegate
- switch case java
- creating a program about user asked to enter a number and enters 0 to stop, then calculates the sum of numbers entered, the average, the length of positive numbers and negative numbers entered by the user in java
- java string to boolean
- read csv java android
- print arraylist java
- binary to int java
- how to convert string to double in android studio
- array methods in java
- java bucket sort
- imagesbutton how to set background
- how to initiate a queue in java
- funzione random in java
- how to print hello world in java
- java how to get current date
- java get input
- java file class
- primitive data types in java
- how to extract data from delimited text file in java
- java output length of each line in a text document
- even or odd in java
- java obtain list string from list object
- alfred workflow
- java for loop add multiple declarations