| |

VerySource

 Forgot password?
 Register
Search
View: 719|Reply: 2

Help !!!!!!!!!!!!!!!!!!!!!!!! 1

[Copy link]

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-17 09:40:01
| Show all posts |Read mode
import java.awt. *;
import java.awt.event. *;
import java.io. *;
import javax.swing. *;
import javax.swing.text. *;

// Simple text editor implements ActionListener
public class edit extends JFrame implements ActionListener {
JTextPane textPane = new JTextPane (); // Text pane, edit window
Ranch
JFileChooser filechooser = new JFileChooser (); // File selector

public edit () {// Constructor
super ("Simple text editor");
JMenuBar menubar = new JMenuBar ();
Container container = getContentPane (); // Get the container
Ranch
container.add (textPane, BorderLayout.CENTER); // Add text pane
container.add (menubar, BorderLayout.NORTH); // Add status bar

setSize (330, 200); // Set window size
setVisible (true); // Set window visible
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); // Exit the program when the window is closed

JMenu menuFile = new JMenu ("File"); // Instantiate the menu
JMenu menuEdit = new JMenu ("Edit");
JMenu menuAbout = new JMenu ("Help");
JMenuItem menu1 = new JMenuItem ("New");
menu1.addActionListener (this);
menuFile.add (menu1);
Ranch
menubar.add (menuFile); // Add menu
menubar.add (menuEdit);
menubar.add (menuAbout);
Ranch
Ranch
}
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
public void actionPerformed (Action e) {
Ranch
Ranch
Ranch
Ranch
Ranch
}
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
Ranch
public static void main (String [] args) {
new edit ();
}
Ranch
}







What's wrong with this code?
The old compiler prompts me to edit shoule bu decelared abstract
Reply

Use magic Report

1

Threads

20

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-1-22 13:09:02
| Show all posts
The type edit must implement the inherited abstract method ActionListener.actionPerformed (ActionEvent)

The corresponding method was changed to:

public void actionPerformed (ActionEvent e)
{

}

By the way, the code format of lz-
Reply

Use magic Report

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-24 15:00:02
| Show all posts
OK
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list