關於JAVA的變量出錯的問題(10分)

Y

yby

Unregistered / Unconfirmed
GUEST, unregistred user!
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.table.*;
class createGUI extends JFrame implements Runnable {
public createGUI() {
setTitle("個人財物管理");
setSize(600,400);
setResizable(false);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
setLocation(100,100);
}
incomePanel.setLayout(new GridLayout(3,2,10,40));
incomePanel.add(incomeRecordButton);
private Font f=new Font("SansSerif",Font.BOLD,16);
private JPanel incomePanel=new JPanel();
private JButton incomeRecordButton=new IncomeRecordButton("中央控制器",f);

}
錯誤提示:incomeRecordButton 變量無效
請問這是甚麼原因,謝謝!
 
private JButton incomeRecordButton=new IncomeRecordButton("中央控制器",f);
這中寫法應該沒有錯吧,請各位幫個忙
 
new IncomeRecordButton(" ???
好像没见过这个类啊!是不是new Button("...") ?
 

private JButton incomeRecordButton=new JButton("中央控制器");
 
incomePanel.setLayout(new GridLayout(3,2,10,40));
incomePanel.add(incomeRecordButton);
这两句有问题吧,他们不在任何方法内啊。
 
顶部