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
icon
Related questions
Question

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

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Developing computer interface
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education