先人求帮助一下,下面的代码为什么会错
前辈求帮助一下,下面的代码为什么会错
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.border.*;
public class Exercise17_10 extends JFrame {
// Declare a panel for displaying message
protected MessagePanel messagePanel = new MessagePanel("Welcome to Java");
这个地方为什么会出现说找不到符号
// Declare two buttons to move the message left and right
private JButton jbtLeft, jbtRight;
private JTextField jtfNewMessage = new JTextField(8);
private JComboBox jcboInterval = new JComboBox();
private JRadioButton jrbRed = new JRadioButton("Red");
private JRadioButton jrbGreen = new JRadioButton("Green");
private JRadioButton jrbBlue = new JRadioButton("Blue");
private JCheckBox jchkCentered = new JCheckBox("Center");
private JCheckBox jchkBold = new JCheckBox("Bold");
private JCheckBox jchkItalic = new JCheckBox("Italic");
// Font name
private String fontName = "SansSerif";
// Font style
private int fontStyle = Font.PLAIN;
// Font Size
private int fontSize = 12;
/** Main method */
public static void main(String[] args) {
Exercise17_10 frame = new Exercise17_10();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 200);
frame.setLocationRelativeTo(null); // Center the frame
frame.setVisible(true);
}
/** Default constructor */
public Exercise17_10() {
setTitle("Exercise17_10");
// Create a MessagePanel instance and set colors
messagePanel.setBackground(Color.white);
// Create Panel jpButtons to hold two Buttons "<=" and "right =>"
JPanel jpButtons = new JPanel();
jpButtons.setLayout(new FlowLayout());
jpButtons.add(jbtLeft = new JButton());
jpButtons.add(jbtRight = new JButton());
// Set button text
jbtLeft.setText("<=");
jbtRight.setText("=>");
// Set keyboard mnemonics
jbtLeft.setMnemonic('L');
jbtRight.setMnemonic('R');
// Set icons
//jbtLeft.setIcon(new ImageIcon("image/left.gif"));
//jbtRight.setIcon(new ImageIcon("image/right.gif"));
// Set toolTipText on the "<=" and "=>" buttons
jbtLeft.setToolTipText("Move message to left");
jbtRight.setToolTipText("Move message to right");
// Place panels in the frame
setLayout(new BorderLayout());
add(messagePanel, BorderLayout.CENTER);
add(jpButtons, BorderLayout.SOUTH);
// Register listeners with the buttons
jbtLeft.addActionListener(new Listener());
jbtRight.addActionListener(new Listener());
/** 1.Add a text field labeled 揘ew Message.\uFFFD
* Upon typing a new message in the text field and pressing the Enter
* key, the new message is displayed in the message panel.
*/
jpButtons.add(new JLabel("Enter a new message"));
jpButtons.add(jtfNewMessage);
jtfNewMessage.addActionListener(new Listener());
/** 2. Add a combo box label 揑nterval\uFFFD that enables the user to select a
* new interval for moving the message. The selection values range from
* 10 to 100 with interval 5. The user can also type a new
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.*;
import javax.swing.border.*;
public class Exercise17_10 extends JFrame {
// Declare a panel for displaying message
protected MessagePanel messagePanel = new MessagePanel("Welcome to Java");
这个地方为什么会出现说找不到符号
// Declare two buttons to move the message left and right
private JButton jbtLeft, jbtRight;
private JTextField jtfNewMessage = new JTextField(8);
private JComboBox jcboInterval = new JComboBox();
private JRadioButton jrbRed = new JRadioButton("Red");
private JRadioButton jrbGreen = new JRadioButton("Green");
private JRadioButton jrbBlue = new JRadioButton("Blue");
private JCheckBox jchkCentered = new JCheckBox("Center");
private JCheckBox jchkBold = new JCheckBox("Bold");
private JCheckBox jchkItalic = new JCheckBox("Italic");
// Font name
private String fontName = "SansSerif";
// Font style
private int fontStyle = Font.PLAIN;
// Font Size
private int fontSize = 12;
/** Main method */
public static void main(String[] args) {
Exercise17_10 frame = new Exercise17_10();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 200);
frame.setLocationRelativeTo(null); // Center the frame
frame.setVisible(true);
}
/** Default constructor */
public Exercise17_10() {
setTitle("Exercise17_10");
// Create a MessagePanel instance and set colors
messagePanel.setBackground(Color.white);
// Create Panel jpButtons to hold two Buttons "<=" and "right =>"
JPanel jpButtons = new JPanel();
jpButtons.setLayout(new FlowLayout());
jpButtons.add(jbtLeft = new JButton());
jpButtons.add(jbtRight = new JButton());
// Set button text
jbtLeft.setText("<=");
jbtRight.setText("=>");
// Set keyboard mnemonics
jbtLeft.setMnemonic('L');
jbtRight.setMnemonic('R');
// Set icons
//jbtLeft.setIcon(new ImageIcon("image/left.gif"));
//jbtRight.setIcon(new ImageIcon("image/right.gif"));
// Set toolTipText on the "<=" and "=>" buttons
jbtLeft.setToolTipText("Move message to left");
jbtRight.setToolTipText("Move message to right");
// Place panels in the frame
setLayout(new BorderLayout());
add(messagePanel, BorderLayout.CENTER);
add(jpButtons, BorderLayout.SOUTH);
// Register listeners with the buttons
jbtLeft.addActionListener(new Listener());
jbtRight.addActionListener(new Listener());
/** 1.Add a text field labeled 揘ew Message.\uFFFD
* Upon typing a new message in the text field and pressing the Enter
* key, the new message is displayed in the message panel.
*/
jpButtons.add(new JLabel("Enter a new message"));
jpButtons.add(jtfNewMessage);
jtfNewMessage.addActionListener(new Listener());
/** 2. Add a combo box label 揑nterval\uFFFD that enables the user to select a
* new interval for moving the message. The selection values range from
* 10 to 100 with interval 5. The user can also type a new