java - 如何同時繼承 JPanel 同 JFrame

我試過用

public class ABC extends JPanel implements JFrame

但係都唔得

1 Answer

Rating
  • 1 decade ago
    Favorite Answer

    JFrame唔係interface,唔可以implements,JPanel係javax.swing嘅subclass,所以先要import就可以用到JPanel,例子如下。

    import java.awt.*;

    import java.awt.event.*;

    import javax.swing.*;

    import java.io.*;

    import java.util.*;

    public class ABC extends JFrame implements ActionListener {(如果你有用event)

    private static final String NEWLINE = System.getProperty("line.separator");

    private JPanel inputPanel, topPanel, bottomPanel, outputPanel, centerPanel;

    private JPanel hdlPanel1, hdlPanel2, wdlPanel1, wdlPanel2, buttonPanel;

    private JPanel hdlPanel, wdlPanel, nodePanel, textPanel, wavePanel;

    }

Still have questions? Get your answers by asking now.