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
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
ADVERTISEMENT