1
1楼 sjx0508 2007-05-18 23:33:18 十万火急!!谢谢!! 在 public void actionPerformed(ActionEvent ae)开始提示:非法的表达式开始 把这个PUBLIC屏蔽后在下面的每个public行都出现:非法的表达式开始 各路高手救命啊 源码: import java.awt.*; import java.awt.event.*; import java.rmi.*; import java.rmi.server.*; public class client extends Frame implements ActionListener,KeyListener,Notfiable{ int flag = 0; String s; String userName; String welcome; String input; TextArea TextArea; TextField inputText; Label hello; RemoteInterface server; public client(){ addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); Panel up = new Panel(); Panel down = new Panel(); this.add(up,BorderLayout.NORTH); this.add(down,BorderLayout.SOUTH); welcome = "hello,stone!! "; hello = new Label(welcome); TextArea = new TextArea(s,15,50,TextArea.SCROLLBARS_BOTH); TextArea.setEditable(false); up.add(hello,BorderLayout.NORTH); up.add(TextArea,BorderLayout.SOUTH); inputText = new TextField(35); Button send = new Button( "send "); down.setBackground(Color.pink); down.add(inputText); down.add(send); send.addActionListener(this); inputText.addKeyListener(this); try{ UnicastRemoteObject.exportObject(this); }catch(RemoteException re){ re.printStackTrace(); } //从这里开始出错,要是把这个public屏蔽了下个public的地方又出现非法表达式的开始 public void actionPerformed(ActionEvent ae){ if(ae.getActionCommand().equals( "send ")){ try{ server.setChatText(userName+ ": "+inputText.getText()); inputText.setText(null); }catch(RemoteException re){ re.printStackTrace(); } } } public void keyPressed(KeyEvent ev){ int keyCode = ev.getKeyCode(); if(keyCode==KeyEvent.VK_ENTER){ try{ server.setChatText(userName+ ": "+inputText.getText()); inputText.setText(null); }catch(RemoteException re){ re.printStackTrace(); } } } public void keyReleased(KeyEvent ev){} public void keyTyped(KeyEvent ev){} public void notify(Integer reason){ if(reason.intValue()==0){ try{ input = server.getChatText(); s = TextArea.getText()+ "\r\n "; TextArea.setText(s+input); }catch(RemoteException re){ re.printStackTrace(); } } } public static void main(String[] args){ if(args.length==0){ System.out.println( "USAGE: java <username> "); System.exit(0); } System.setSecurityManager(new RMISecurityManger()); client f = new client(); f.username = args[0]; try{ f.server = (RemoteInterface)Naming.lookup( "rmi://127.0.0.1/test "); f.server.registerForNotification(f); }catch(Exception e){ e.printStackTrace(); } f.setSize(400,350); f.show(); } } } 2楼 mq612 2007-05-20 01:56:01 //从这里开始出错,要是把这个public屏蔽了下个public的地方又出现非法表达式的开始
这句注释之前应该有个 } main方法后面多了个 }
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源
| |||||