Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 请帮我看一看这段代码! (cannot resolve symbol 大家可以不理)
q_yuan





发贴: 174
积分: 3
于 2004-11-09 19:51 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
请各位高手帮我看一看这段代码,并给出正确的!谢谢!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class StyleChooser extends JPanel{
static JFrame frame;
static String metal="Metal";
static String metalClassName="javax.swing.plaf.metal.MetalLookAnedFeel";
static String motif= "Motif";
static String motifClassName="sun.java.swing.plaf.motif.MotifLookAnedFeel";
static String windows= "Windows";
static String windowsClassName="sun.java.swing.plaf.windows.WindowsLookAnedFeel";
JRadioButton metalButton,motifButton,windowsButton;
public StyleChooser(){
JLabel label= new JLabel("Try the style Swing has");
metalButton = new JRadioButton(metal);
metalButton.setMnemonic('o');
metalButton.setActionCommand(metalClassName);
motifButton = new JRadioButton(motif);
motifButton.setMnemonic('m');
motifButton.setActionCommand(motifClassName);
windowsButton = new JRadioButton(windows);
windowsButton.setMnemonic('w');
windowsButton.setActionCommand(windowsClassName);
ButtonGroup group = new ButtonGroup();
group.add(metalButton);
group.add(motifButton);
group.add(windowsButton);
RadioListener myListener = new RadioListener();
metalButton.addActionListener(myListener);
motifButton.addActionListener(myListener);
windowsButton.addActionListener(myListener);
add(label);
add(metalButton);
add(motifButton);
add(windowsButton);
  }
class RadioListener implements ActionListener{
public void actionPerformed(ActionEvent e){
String lnfName = e.getActionCommand();
try{
IManager.setLookAndFeel(lnfName);
wingUtilities.updateComponentTreeUI(frame);
frame.pack();
  }catch(Exception e){
JRadioButton button =(JRadioButton)e.getSource();
button.setEnabled(false);
updateState();
System.err.println("Could not load LookAndFeel:" + lnfName);
}
}
}
public void updateState(){
String lnfName = UIManager.getLookAndFeel().getClass().getName();
if(lnfName.indexOf(metal)>=0){metalButton.setSelected(true);}
else if (lnfName.indexOf(motif)>=0){motifButton.setSelected(true);}
else if (lnfName.indexOf(windows)>=0){windowsButton.setSelected(true);}
else{System.err.println("StyleChooser is Using an Unkown L&F:" + lnfName);}
}
public static void main(String[] arg){
StyleChooser panel = new StyleChooser();
frame=new JFrame("StyleChooser");
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
frame.getContentPane().add("Center",panel);
frame.pack();
frame.setVisible(true);
panel.updateState();
}
}

我编译的时候出现了错误提示为:
D:\Program Files\Xinox Software\JCreator Pro\MyProjects\FramPanel\StyleChooser.java:41: cannot resolve symbol
symbol : variable IManager
location: class StyleChooser.RadioListener
          IManager.setLookAndFeel(lnfName);
^
D:\Program Files\Xinox Software\JCreator Pro\MyProjects\FramPanel\StyleChooser.java:42: cannot resolve symbol
symbol : variable WingUtilities
location: class StyleChooser.RadioListener
          WingUtilities.updateComponentTreeUI(frame);
^
D:\Program Files\Xinox Software\JCreator Pro\MyProjects\FramPanel\StyleChooser.java:44: e is already defined in actionPerformed(java.awt.event.ActionEvent)
          }catch(Exception e){
^
D:\Program Files\Xinox Software\JCreator Pro\MyProjects\FramPanel\StyleChooser.java:45: cannot resolve symbol
symbol : method getSource ()
location: class java.lang.Exception
            JRadioButton button =(JRadioButton)e.getSource();
^


why edited on 2004-11-10 08:08


关于Jute Forum的长期发展给官方的建议

话题树型展开
人气 标题 作者 字数 发贴时间
10855 请帮我看一看这段代码! (cannot resolve symbol 大家可以不理) q_yuan 3907 2004-11-09 19:51
7738 Re:请帮我看一看这段代码! (cannot resolve symbol) why 382 2004-11-09 23:32
7750 Re:请帮我看一看这段代码! (cannot resolve symbol 大家可以不理) why 163 2004-11-10 08:43

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923