还是不行啊
/Frame for the Sketcher application
import javax.swing.*;
import java.lang.String;
import java.awt.*;
public class SketchFrame extends JFrame{
//Constructor
public SketchFrame(String title) {
setTitle(title); //set the window title
setDefaultCloseOperation(EXIT_ON_CLOSE);
setJMenuBar(menuBar); //Add the menu bar to the window
JMenu fileMenu = new JMenu("File"); //Creat File menu
JMenu elementMenu = new JMenu("Elements"); //Create Elements menu
menuBar.add(fileMenu); //Add the element menu
menuBar.add(elementMenu); //Add the element menu
//pane.add(text);
//pane.setLayout(new BorderLayout());
pane = this.getContentPane();
text = new JTextArea(20,50); //Add the test area
pane.setLayout(new BorderLayout());
pane.add(text);
}
private JMenuBar menuBar = new JMenuBar(); //Window menu bar
private MainFrame text =new MainFrame();
private Container pane;
}
提示::
C:\java\HomeWork\SketchFrame.java:18: incompatible types
found : javax.swing.JTextArea
required: MainFrame
text = new JTextArea(20,50); //Add the test area
^
1 error
import javax.swing.*;
import java.lang.String;
import java.awt.*;
public class SketchFrame extends JFrame{
//Constructor
public SketchFrame(String title) {
setTitle(title); //set the window title
setDefaultCloseOperation(EXIT_ON_CLOSE);
setJMenuBar(menuBar); //Add the menu bar to the window
JMenu fileMenu = new JMenu("File"); //Creat File menu
JMenu elementMenu = new JMenu("Elements"); //Create Elements menu
menuBar.add(fileMenu); //Add the element menu
menuBar.add(elementMenu); //Add the element menu
}
private JMenuBar menuBar = new JMenuBar(); //Window menu bar
private Container pane;
private JTextArea text;
pane = this.getContentPane();
text = new JTextArea(20,50);
this.cardlist = cardlist;
pane.setLayout(new BorderLayout());
pane.add(text);