標題:
java - 如何同時繼承 JPanel 同 JFrame
發問:
我試過用 public class ABC extends JPanel implements JFrame 但係都唔得
最佳解答:
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; }
此文章來自奇摩知識+如有不便請留言告知
其他解答: