新手问题`找不到符号的问题`
有2个例子,第一个是设计list组件的``可以运行``
但第2个例子是设计JMenuBar,JMenu,JMenuItem组件的`编译时总是说后面那3个f.找不到符号,请帮忙看下``我与第一个例子对应的改了N久`就是不对`````请指点下啊``谢谢谢谢
第1个例子
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//import java.lang.*;
public class ChatSever
{
public ChatSever()
{
JFrame f=new JFrame( "聊天系统 ");
Container contentPane=f.getContentPane();
contentPane.setLayout(new GridLayout(2,1));
JLabel jl=new JLabel( "请选择话题 ");
JPanel jp1=new JPanel();
jp1.add(jl);
//String[] s = { "one ", "two ", "three ", "four "};
String [] s=new String[3];
s[0]= "我爱你啊 ";
s[1]= "我爱啊啊你啊 ";
s[2]= "我爱你的的啊 ";
JComboBox lt=new JComboBox(s);
contentPane.add(jp1);
contentPane.add(lt);
f.pack();
f.setVisible(true);
//f.display();
//f.show();
}
public static void main(String[] args)
{
new ChatSever();
}
}
第2个例子
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Chat
{
public Chat()
{
JFrame f=new JFrame( "聊天系统 ");
Container contentPane=f.getContentPane();
JTextArea jTextArea=new JTextArea(3,10);
JMenuBar MBar=new JMenuBar();
JMenu file=new JMenu( "File ");
JMenuItem restart=new JMenuItem( "Restart ");
JMenuItem exit=new JMenuItem( "Exit ");
file.add(restart);
file.add(exit);
JMenu help=new JMenu( "Help ");
JMenuItem about=new JMenuItem( "About ");
help.add(about);
MBar.add(file);
MBar.add(help);
contentPane.add(jTextArea);
f.setJMunBar(MBar);
f.back();
f.setVisiable(true);
}
public static void main(String[] args)
{
new Chat();
}
}
------解决方案--------------------f.setJMenuBar(MBar); f.setJMunBar(MBar);
f.pack(); f.back();
f.setVisible(true); f.setVisiable(true);
自己比较一下有什么不同
唉`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~`~~~~~