NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//7.25

package kazilab;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

public class DrawRainbow extends JPanel {

private final static Color VIOLET = new Color(128, 0, 128);
private final static Color INDIGO = new Color(75, 0, 130);


private Color[] colors = {Color.WHITE, Color.WHITE, VIOLET, INDIGO, Color.BLUE,
Color.GREEN, Color.YELLOW, Color.ORANGE, Color.RED};

public DrawRainbow() {
setBackground(Color.WHITE);
}

public void paintComponent(Graphics g) {
super.paintComponent(g);
int radius = 20;

int centerX = getWidth() / 2;
int centerY = getHeight() - 10;

for (int counter = colors.length; counter > 0; counter--) {
g.setColor(colors[counter - 1]);
g.fillArc(centerX - counter * radius,
centerY - counter * radius,
counter * radius * 2,
counter * radius * 2,
0,
180);
}
}
}

//7.26

package kazilab;

import javax.swing.JFrame;

public class DrawRainbowTest {

public static void main(String[] args) {
DrawRainbow panel = new DrawRainbow();
JFrame application = new JFrame();

application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
application.add(panel);
application.setSize(400, 250);
application.setVisible(true);
}
}

//8.17

package kazilab;

import java.awt.Color;
import java.awt.Graphics;

public class MyLine {

private int x1;
private int y1;
private int x2;
private int y2;
private Color color;

public MyLine(int x1, int y1, int x2, int y2, Color color) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.color = color;
}

public void draw(Graphics g) {
g.setColor(color);
g.drawLine(x1, y1, x2, y2);
}
}

/ /8.18

package kazilab;

import java.awt.Color;
import java.awt.Graphics;
import java.security.SecureRandom;
import javax.swing.JPanel;

public class DrawPanel extends JPanel {

private SecureRandom randomNumbers = new SecureRandom();
private MyLine[] lines;

public DrawPanel() {
setBackground(Color.WHITE);
lines = new MyLine[5 + randomNumbers.nextInt(5)];

for (int count = 0; count < lines.length; count++) {
int x1 = randomNumbers.nextInt(300);
int y1 = randomNumbers.nextInt(300);
int x2 = randomNumbers.nextInt(300);
int y2 = randomNumbers.nextInt(300);

Color color = new Color(randomNumbers.nextInt(256),
randomNumbers.nextInt(256),
randomNumbers.nextInt(256));

lines[count] = new MyLine(x1, y1, x2, y2, color);
}
}

@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);

for (MyLine line : lines) {
line.draw(g);
}
}
}

/ /8.19

package kazilab;

import javax.swing.JFrame;

public class TestDraw {
public static void main(String[] args) {
DrawPanel panel = new DrawPanel();
JFrame app = new JFrame();

app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
app.add(panel);
app.setSize(300, 300);
app.setVisible(true);
}
}

/ / 9.13

package kazilab;

import java.awt.BorderLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JFrame;

public class LabelDemo {

public static void main(String[] args) {
JLabel northLabel = new JLabel("North");
ImageIcon labelIcon = new ImageIcon("GUItip.gif");
JLabel centerLabel = new JLabel(labelIcon);
JLabel southLabel = new JLabel(labelIcon);
southLabel.setText("South");
JFrame application = new JFrame();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
application.add(northLabel, BorderLayout.NORTH);
application.add(centerLabel, BorderLayout.CENTER);
application.add(southLabel, BorderLayout.SOUTH);

application.setSize(300, 300);
application.setVisible(true);

}
}

****change******
1.

package kazilab;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

public class DrawAngry extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);

// Face
g.setColor(Color.RED);
g.fillOval(10, 10, 200, 200);

// Eyes
g.setColor(Color.BLACK);
// Left eye
g.fillOval(55, 65, 30, 30);
// Right eye
g.fillOval(135, 65, 30, 30);

// Angry eyebrows
g.setColor(Color.BLACK);
g.drawLine(40, 50, 85, 65); // Left eyebrow
g.drawLine(160, 65, 205, 50); // Right eyebrow

// Mouth
g.fillArc(75, 130, 70, 50, 0, -180);

// Convert smile to frown
g.setColor(Color.RED);
g.fillRect(75, 130, 70, 25);
}
}

02.

package kazilab;
import javax.swing.JFrame;

public class DrawAngryTest {
public static void main(String[] args) {

JFrame frame = new JFrame("Angry Emoji");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(230, 250); // Set the size of the frame

// Create an instance of the DrawAngryEmoji class
DrawAngry angryPanel = new DrawAngry();

// Add the DrawAngryEmoji panel to the frame
frame.add(angryPanel);

// Make the frame visible
frame.setVisible(true);
}
}

03.

package kazilab;

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

public class DrawCrying extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);

// Face
g.setColor(Color.YELLOW);
g.fillOval(10, 10, 200, 200);

// Eyes
g.setColor(Color.BLACK);
// Left eye
g.fillOval(55, 65, 30, 30);
// Right eye
g.fillOval(135, 65, 30, 30);

// Tears
g.setColor(Color.BLUE);
// Left tear
g.fillOval(45, 95, 15, 15);
g.fillOval(50, 110, 10, 10);
// Right tear
g.fillOval(140, 95, 15, 15);
g.fillOval(145, 110, 10, 10);

// Mouth (sad)
g.setColor(Color.BLACK);
g.drawArc(75, 150, 70, 50, 0, -180);
}
}

0.4.
package kazilab;

import javax.swing.JFrame;

public class DrawCryingTest {
public static void main(String[] args) {
// Create a JFrame to hold the DrawCrying panel
JFrame frame = new JFrame("Crying Emoji");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(230, 250); // Set the size of the frame

// Create an instance of the DrawCrying class
DrawCrying cryingEmojiPanel = new DrawCrying();

// Add the DrawCrying panel to the frame
frame.add(cryingEmojiPanel);

// Make the frame visible
frame.setVisible(true);
}
}


05.

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.