Question

create the java graphics program to write your first name in lines on the screen (...

create the java graphics program to write your first name in lines on the screen ( using jpanel to draw to line )

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import javax.swing.*;

import java.awt.*;

public class LineDemo extends JPanel {

@Override

protected void paintComponent(Graphics g) {

super.paintComponent(g);

drawLines(g);

}

void drawLines(Graphics g) {

        Graphics2D g2d = (Graphics2D) g;

        g2d.drawLine(120, 50, 360, 50);

    g2d.drawLine(120, 90, 360, 90);

g2d.setFont(new Font("Segoe Script", Font.BOLD + Font.ITALIC, 30));

g2d.setPaint(Color.BLUE);

g2d.drawString("Your Name!", 130, 70);

}

public static void main(String[] args) {

JFrame frame = new JFrame();

frame.setTitle("Draw String Demo");

frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

frame.add(new LineDemo());

frame.pack();

frame.setSize(420, 300);

frame.setVisible(true);

}

}

Add a comment
Know the answer?
Add Answer to:
create the java graphics program to write your first name in lines on the screen (...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a java program to create a student file which includes first name, last name, and...

    Write a java program to create a student file which includes first name, last name, and GPA. Write another Java program to open the students file. Display the students list and calculate the average GPA of the class.  

  • Write, compile, and test a class that displays your first name on the screen. Save the...

    Write, compile, and test a class that displays your first name on the screen. Save the class as Name. Write, compile, and test a class that displays your full name, street address and city, on three separate lines on the screen. Save the class as Address. Write a java program which add two numbers and print the result on screen. Save the class as Add2. Write a java program which accepts two numbers from user multiply them and print the...

  • java- Students create your first basic angular project. Print your name on the screen please help!

    java- Students create your first basic angular project. Print your name on the screen please help!

  • Your graphics assignment is to write a program for windows forms in C#. C# Program. That...

    Your graphics assignment is to write a program for windows forms in C#. C# Program. That will draw a red circle in the middle of the screen. I also need to know how to set up the form. Please and thank you.

  • Q Create a program using turtle. The program can be graphics, racing of elements, or writing...

    Q Create a program using turtle. The program can be graphics, racing of elements, or writing names. *This should be done by moving the turtle around the screen, not by using any functions that prints text/graphics on the screen. *

  • Java program GCompound Practice Exercise CS141 Assignment Write a class that represents a digital snowman. Your...

    Java program GCompound Practice Exercise CS141 Assignment Write a class that represents a digital snowman. Your class should follow these guidelines: 1. Store the following private class variables bodyColor of type Color b. int x, int y for the upper left corner Graphics g. a. C. 2. Create two different constructor methods a. A (int x, int y, Graphics myG) parameter constructor that makes the snowman a light gray color by default and makes x and y the upper left...

  • Write a program called draw_shapes.py. In your program, Create a block header with: your name the...

    Write a program called draw_shapes.py. In your program, Create a block header with: your name the date a short description of what the program does: Assignment 5: Draw shapes using turtle Import the turtle module. Create a window and screen (canvas) where your turtle will draw. Make the window 400 pixels wide x 400 pixels high and give it an indigo background and a title of "Shapes". Use this code to create a window object: # a place for the...

  • What to submit: your answers to exercises 2. Write a Java program to perform the following...

    What to submit: your answers to exercises 2. Write a Java program to perform the following tasks: The program should ask the user for the name of an input file and the name of an output file. It should then open the input file as a text file (if the input file does not exist it should throw an exception) and read the contents line by line. It should also open the output file as a text file and write...

  • Write a program in Java that reads the file and does two things: Write to an...

    Write a program in Java that reads the file and does two things: Write to an output file called dataSwitch.txt the same data from the input file, but switch the order of the data entries on each line. For example, if the first line of the input file is “90001 57110”, the first line of the output file would be “57110 90001”. Additionally, print to the screen the number of lines in the file with a label

  • Create the logo as shown in Java in an applet or frame. It should be as...

    Create the logo as shown in Java in an applet or frame. It should be as close as possible, including the Virus Logo. Draw the logo using ovals, lines, rectangles, and strings, changing colors and using draw or fill as necessary. Change to appropriate virus colors (like Blue and Cyan) and fonts for the text in the drawing. Everything should be drawn in paint() with your Graphics object. After creating one virus, usecopyArea() to copy the virus bugs to other...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT