我这个在Netbeans里面写的java程序,好多地方报错怎么回事
我这个在Netbeans里面写的java程序,好多地方报错怎么回事importjava.awt.*;importjava.awt.event.*;importjava.s...
我这个在Netbeans里面写的java程序,好多地方报错怎么回事import java.awt.*;
import java.awt.event.*;
import java.swing.*;
public class er_si {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
ButtonFrame frame = new ButtonFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
class_ButtonFrame extends JFrame {
public ButtonFrame(){
setTitle("测试按钮");
}
setSize(DEFAULTWID%TH,DEFAULT_HEIGHT);
ButtonPanel panel=new ButtonPanel();
Container contentPane = getContentPane();
contentPane.add(panel);
}
public static final int DEFAULT_WIDTH=200;
public static final int DEFAULT_HEIGHT=200;
}
class ButtonPanel extends JPanel {
public ButtonPanel(){
JButton yellowButton= new JButton("黄色");
add(yellowButton);
ColorAction yellowAction=new ColorAction(Color.YELLOW);
yellowButton.addActionListener(yellowAction);
private class ColorAction implements ActionListener{
public ColorAction(Color C){
backgroundColor=c;
}
public void ActionPerformed(ActionEvent event){
setBackground(backgroundColor);
}
private Color backgroundColor;
}
} 展开
import java.awt.event.*;
import java.swing.*;
public class er_si {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
ButtonFrame frame = new ButtonFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
class_ButtonFrame extends JFrame {
public ButtonFrame(){
setTitle("测试按钮");
}
setSize(DEFAULTWID%TH,DEFAULT_HEIGHT);
ButtonPanel panel=new ButtonPanel();
Container contentPane = getContentPane();
contentPane.add(panel);
}
public static final int DEFAULT_WIDTH=200;
public static final int DEFAULT_HEIGHT=200;
}
class ButtonPanel extends JPanel {
public ButtonPanel(){
JButton yellowButton= new JButton("黄色");
add(yellowButton);
ColorAction yellowAction=new ColorAction(Color.YELLOW);
yellowButton.addActionListener(yellowAction);
private class ColorAction implements ActionListener{
public ColorAction(Color C){
backgroundColor=c;
}
public void ActionPerformed(ActionEvent event){
setBackground(backgroundColor);
}
private Color backgroundColor;
}
} 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询