Hi I want to create a JAVA program that will allow me to create a canvas (specifically in eclipse). Can someone straighten my code import java.awt.*; import javax.swing.*; class Main extends JFrame { // constructor Main() { super("canvas"); // create a empty canvas Main c = new Main() { // paint the canvas public void paint(Graphics g) { // set color to red g.setColor(Color.red); // set Font g.setFont(new Font("Bold", 1, 20)); // draw a string g.drawString("This is a canvas", 100, 100); } }; // set background c.setBackground(Color.black); add(c); setSize(400, 300); show(); } // Main Method public static void main(String args[]) { Main c = new Main(); } } ReplyForward
Hi I want to create a JAVA program that will allow me to create a canvas (specifically in eclipse). Can someone straighten my code import java.awt.*; import javax.swing.*; class Main extends JFrame { // constructor Main() { super("canvas"); // create a empty canvas Main c = new Main() { // paint the canvas public void paint(Graphics g) { // set color to red g.setColor(Color.red); // set Font g.setFont(new Font("Bold", 1, 20)); // draw a string g.drawString("This is a canvas", 100, 100); } }; // set background c.setBackground(Color.black); add(c); setSize(400, 300); show(); } // Main Method public static void main(String args[]) { Main c = new Main(); } } ReplyForward
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Hi I want to create a JAVA
import java.awt.*;
import javax.swing.*; class Main extends JFrame { // constructor Main() { super("canvas"); // create a empty canvas Main c = new Main() { // paint the canvas public void paint(Graphics g) { // set color to red g.setColor(Color.red); // set Font g.setFont(new Font("Bold", 1, 20)); // draw a string g.drawString("This is a canvas", 100, 100); } }; // set background c.setBackground(Color.black); add(c); setSize(400, 300); show(); } // Main Method public static void main(String args[]) { Main c = new Main(); } }
|
|
![E Projects - Canvas test/src/myDelete/Myclass.java - Eclipse IDE
File Edit Source Refactor Navigate Search Project Run Window Help
母G
E Package Explorer 8
9 Myclass.java 3
a 10 įmport java.awt.*;
2 import javax. swing.*;
3 class Myclass extends JFrame {
E Outli. 3
v E Canvas test
> EA JRE System Library [JavaSE-16]
v 2, Myclass
va° Myclas
v src
// constructor
Myclass ()
{
super ("canvas");
5
v A myDelete
60
> A Myclass.java
7.
va new
8
9
// create a empty canvas
Myclass c = new Myclass() {
10
• main(S
O110
12
13
140
// paint the canvas
public void paint(Graphics g)
{
// set color to red
g.setColor (Color.red);
16
17
18
19
// set Font
g.setFont (new Font ("Bold", 1, 20));
// draw a string
g.drawstring("This is a canvas", 100, 100);
}
};
// set background
c.setBackground (Color.black);
27
28
29
add(c);
setSize(400, 300);
shew();
}
30
31
32
33
34
// Main Method
public static void main(String args[])
{
Myclass c = new Myclass();
}
35
36e
37
38
39
40 }
41](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7daa69d8-205a-4b72-abf5-96966d755823%2Fac7fd144-d909-4aac-80ef-725f2d75a8dd%2F6bnfcrs_processed.png&w=3840&q=75)
Transcribed Image Text:E Projects - Canvas test/src/myDelete/Myclass.java - Eclipse IDE
File Edit Source Refactor Navigate Search Project Run Window Help
母G
E Package Explorer 8
9 Myclass.java 3
a 10 įmport java.awt.*;
2 import javax. swing.*;
3 class Myclass extends JFrame {
E Outli. 3
v E Canvas test
> EA JRE System Library [JavaSE-16]
v 2, Myclass
va° Myclas
v src
// constructor
Myclass ()
{
super ("canvas");
5
v A myDelete
60
> A Myclass.java
7.
va new
8
9
// create a empty canvas
Myclass c = new Myclass() {
10
• main(S
O110
12
13
140
// paint the canvas
public void paint(Graphics g)
{
// set color to red
g.setColor (Color.red);
16
17
18
19
// set Font
g.setFont (new Font ("Bold", 1, 20));
// draw a string
g.drawstring("This is a canvas", 100, 100);
}
};
// set background
c.setBackground (Color.black);
27
28
29
add(c);
setSize(400, 300);
shew();
}
30
31
32
33
34
// Main Method
public static void main(String args[])
{
Myclass c = new Myclass();
}
35
36e
37
38
39
40 }
41
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education