为什么会拒绝访问呢?

aodzl 2003-08-22 10:16:23
java.security.AccessControlException: access denied (java.awt.AWTPermission createRobot)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.awt.Robot.checkRobotAllowed(Unknown Source)
at java.awt.Robot.init(Unknown Source)
at java.awt.Robot.<init>(Unknown Source)
at com.hyi.cake.applet.OrderReport.panelInit(OrderReport.java:415)
at com.hyi.cake.applet.OrderReport.init(OrderReport.java:870)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


出错的代码段为:

415处:
//move mouse out of the applet and back
try {
Robot rb = new Robot();//415
rb.mouseMove(0, 0);
rb.mouseMove(mouseX, mouseY);
} catch(AWTException e){
e.printStackTrace();
}


870处:
public void init() {
goodsPanelInit();
tableInit();
scrollPanelInit();
panelInit();//870

}

大哥大姐帮我看看,这个是怎么回是啊?
...全文
120 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
aodzl 2003-08-22
  • 打赏
  • 举报
回复
Label lab5 = new Label("进货量");
lab5.setFont(font);
lab5.setAlignment(Label.CENTER);
lab5.setBackground(new Color(74, 121, 108));
lab5.setForeground(Color.white);
c.gridx = 4;
c.gridy = 1;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab5, c);
goodsPanel.add(lab5);

Label lab6 = new Label("销货量");
lab6.setFont(font);
lab6.setAlignment(Label.CENTER);
lab6.setBackground(new Color(74, 121, 108));
lab6.setForeground(Color.white);
c.gridx = 5;
c.gridy = 1;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab6, c);
goodsPanel.add(lab6);

Label lab7 = new Label("报废量");
lab7.setFont(font);
lab7.setAlignment(Label.CENTER);
lab7.setBackground(new Color(74, 121, 108));
lab7.setForeground(Color.white);
c.gridx = 6;
c.gridy = 1;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab7, c);
goodsPanel.add(lab7);

Label lab8 = new Label("订货量");
lab8.setFont(font);
lab8.setAlignment(Label.CENTER);
lab8.setBackground(new Color(74, 121, 108));
lab8.setForeground(Color.white);
c.gridx = 7;
c.gridy = 1;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab8, c);
goodsPanel.add(lab8);

Label lab9 = new Label("进货量");
lab9.setFont(font);
lab9.setAlignment(Label.CENTER);
lab9.setBackground(new Color(74, 121, 108));
lab9.setForeground(Color.white);
c.gridx = 8;
c.gridy = 1;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab9, c);
goodsPanel.add(lab9);

Label lab10 = new Label("销货量");
lab10.setFont(font);
lab10.setAlignment(Label.CENTER);
lab10.setBackground(new Color(74, 121, 108));
lab10.setForeground(Color.white);
c.gridx = 9;
c.gridy = 1;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab10, c);
goodsPanel.add(lab10);

Label lab11 = new Label("报废量");
lab11.setFont(font);
lab11.setAlignment(Label.CENTER);
lab11.setBackground(new Color(74, 121, 108));
lab11.setForeground(Color.white);
c.gridx = 10;
c.gridy = 1;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab11, c);
goodsPanel.add(lab11);

Label lab12 = new Label("周数");
lab12.setFont(font);
lab12.setAlignment(Label.CENTER);
lab12.setBackground(new Color(74, 121, 108));
lab12.setForeground(Color.white);
c.gridx = 11;
c.gridy = 1;
c.insets = new Insets(1, 1, 1, 1);
c.gridwidth = 1;
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab12, c);
goodsPanel.add(lab12);

goodsData[0] = new Label();
goodsData[0].setFont(font);
goodsData[0].setAlignment(Label.RIGHT);
goodsData[0].setBackground(new Color(238, 255, 238));
goodsData[0].setForeground(Color.red);
c.gridx = 0;
c.gridy = 2;
c.gridwidth = 3;
layout.setConstraints(goodsData[0], c);
goodsPanel.add(goodsData[0]);

for (int i = 1; i < 10; i++) {
goodsData[i] = new Label();
goodsData[i].setFont(font);
goodsData[i].setAlignment(Label.RIGHT);
goodsData[i].setBackground(new Color(238, 255, 238));
c.gridx = i + 2;
c.gridy = 2;
c.gridwidth = 1;
layout.setConstraints(goodsData[i], c);
goodsPanel.add(goodsData[i]);
}

goodsPanel.show();
}

aodzl 2003-08-22
  • 打赏
  • 举报
回复
这是源码:
//package com.hyi.cake.applet;
package com.hyi.cake.applet;
import java.io.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.math.BigDecimal;
import java.net.*;
import java.util.*;

public class OrderReport extends Applet implements ActionListener, MouseListener, AdjustmentListener, ItemListener {
Connection con = null;
Statement st = null;
ResultSet rs = null;
String storeID = null;
java.sql.Date orderDate = null;
java.sql.Date currentShopDate = null;
// Panel panel = new Panel();
Panel tablePanel = new Panel();
Label chevalLabel = new Label("货架:");
Choice chevalID = new Choice();
Label[] title = new Label[9];
Label[][] table = new Label[8][9];
Scrollbar bar = new Scrollbar(Scrollbar.VERTICAL);
Panel scrollPanel = new Panel();
Panel goodsPanel = new Panel();
Label[] goodsData = new Label[10];
Button in = new Button("登 录");
Label totalName = new Label("本货架可订品项数:");
Label totalName2 = new Label("本货架已订品项数:");
Label total = new Label();
Label total2 = new Label();
Label error = new Label();
int mouseX=500;
int mouseY=400;

Font font = new Font("SERIF", Font.PLAIN, 10);
Vector tableData = new Vector();
Vector list = new Vector();

int oldId = 0;
int oldValue = 0;
int newValue = 0;
/*
制作一个scrollpanel
*/
public void scrollPanelInit() {
GridBagLayout layout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
scrollPanel.setLayout(layout);
c.weightx = 100;
c.weighty = 100;

c.gridwidth = 15;
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy = 0;
layout.setConstraints(tablePanel, c);
scrollPanel.add(tablePanel);

// bar.setValues(0, 8, 0, 0);
bar.setVisibleAmount(8);
bar.setBlockIncrement(8);
bar.addAdjustmentListener(this);
c.weightx = 0;
c.gridwidth = 1;
c.fill = GridBagConstraints.BOTH;
c.gridx = 15;
c.gridy = 0;
layout.setConstraints(bar, c);
scrollPanel.add(bar);
scrollPanel.show();
}


public void goodsPanelInit() {
GridBagLayout layout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
goodsPanel.setLayout(layout);
c.weightx = 100;
c.weighty = 100;

Label lab1 = new Label("本品目前库存数");
lab1.setAlignment(Label.CENTER);
lab1.setFont(font);
lab1.setBackground(new Color(74, 121, 108));
lab1.setForeground(Color.white);
c.gridheight = 2;
c.gridwidth = 3;
c.gridx = 0;
c.gridy = 0;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab1, c);
goodsPanel.add(lab1);

Label lab2 = new Label("前周");
lab2.setFont(font);
lab2.setAlignment(Label.CENTER);
lab2.setBackground(new Color(74, 121, 108));
lab2.setForeground(Color.white);
c.gridwidth = 4;
c.gridheight = 1;
c.gridx = 3;
c.gridy = 0;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab2, c);
goodsPanel.add(lab2);

Label lab3 = new Label("四周平均");
lab3.setFont(font);
lab3.setAlignment(Label.CENTER);
lab3.setBackground(new Color(74, 121, 108));
lab3.setForeground(Color.white);
c.gridx = 7;
c.gridy = 0;
c.gridwidth = 5;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab3, c);
goodsPanel.add(lab3);

Label lab4 = new Label("订货量");
lab4.setFont(font);
lab4.setAlignment(Label.CENTER);
lab4.setBackground(new Color(74, 121, 108));
lab4.setForeground(Color.white);
c.gridx = 3;
c.gridy = 1;
c.gridwidth = 1;
c.gridheight = 1;
c.insets = new Insets(1, 1, 1, 1);
c.fill = GridBagConstraints.BOTH;
layout.setConstraints(lab4, c);
goodsPanel.add(lab4);




aodzl 2003-08-22
  • 打赏
  • 举报
回复
不好意思,是这个样子的。
服务起端是jboss+linux+mysql
客户端是win2000的。

上面是个applet,然后在jsp中调用。
我在本机浏览时,applet报上面的错误。

由于程序太长,所以没贴出来。
大家可以帮我分析一下是什么原因出着这个错的吗?


刚才我在本机,用eclipse调试了这个applet,没有报错,可以运行。
不知道这是什么回事?
zeros 2003-08-22
  • 打赏
  • 举报
回复
写清楚点,这谁能看懂啊!
问问题也要有点诚意啊!
langjianjun 2003-08-22
  • 打赏
  • 举报
回复
没太看明白,你是在哪执行的,JB,还是命令行。

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧