src/MainFrame.java:22: muscodgui.MainFrame is not abstract and does not
override abstract method
valueChanged(javax.swing.event.TreeSelectionEvent) in
javax.swing.event.TreeSelectionListener
public class MainFrame extends JFrame implements ActionListener,
TreeSelectionListener {
^
1 error
Mache ich die Klasse abstract, kann ich kein Objekt der Klasse erzeugen, was kann ich dagegen tun?
override abstract method
valueChanged(javax.swing.event.TreeSelectionEvent) in
javax.swing.event.TreeSelectionListener
public class MainFrame extends JFrame implements ActionListener,
TreeSelectionListener {
^
1 error
Mache ich die Klasse abstract, kann ich kein Objekt der Klasse erzeugen, was kann ich dagegen tun?
Code:
package muscodgui;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.JDesktopPane;
import javax.swing.JLabel;
import javax.swing.event.TreeSelectionListener;
import javax.swing.event.TreeSelectionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Event;
import java.awt.Toolkit;
import java.awt.BorderLayout;
public class MainFrame extends JFrame implements ActionListener, TreeSelectionListener {
private MenuBar menuBar;
private SelectTree tree;
private JSplitPane splitPane;
public MainFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void WindowClosing(WindowEvent e) {
System.exit(0);
}
});
/* add menu */
menuBar = new MenuBar(this);
setJMenuBar(menuBar);
/* add tree */
tree = new SelectTree(this);
/* add splitpane */
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
tree, new JDesktopPane().add(new JLabel("Text")));
getContentPane().add(splitPane, BorderLayout.CENTER);
setLocation(
(Toolkit.getDefaultToolkit().getScreenSize().width - 800)/2,
(Toolkit.getDefaultToolkit().getScreenSize().height - 600)/2
);
setSize(800, 600);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
Object obj = e.getSource();
String cmd = e.getActionCommand();
if (obj instanceof JMenuItem) {
System.out.println("Menu: " + cmd);
if (cmd.equals("new")) {
/* create file */
}
if (cmd.equals("open")) {
/* open file */
}
if (cmd.equals("save")) {
/* save file */
}
if (cmd.equals("saveAs")) {
/* save file as */
}
if (cmd.equals("exit")) {
System.exit(0);
}
}
}
}