Preventing "Paste" into java applets
First of all, I am sorry that I was not able to search these forums. I searched but the "Sun Search" did not seem to allow a specific forum search and threw more than a page of non-forum hits.
I would like to know whether it is possible to prevent paste (as in copy and paste) into the text field of a java applet as run on a browser as part of an online application.
I know that there are javascript applications for preventing "right click" the use of the control keys and also (the best or most annoying in my experience) flushing the system clipboard.
However, all these measures can be circumvented and I thin that the Opera browser in is good at circumventing them.
When it comes to a java applet however, without interferting with the system, I would have thought it would be possible to control
1) Connections to the system clipboard
2) Which keys can be used to enter into a text field.
So I would have though that preventing paste into a java text field would be possible.
But today I was asked "Do you understand computers"? And made a fool of when I suggested that such a thing may be possible, by a Java programmer. I am surprised.
Is it possible to prevent paste (ctrl v, or using the mouse) into a java text field?
Tim
cleaner way to do it (cleaner meaning not so many inner classes!) is to just add a key adapter to whatever text component you want (textfields, textareas, anything that takes KeyListener)
example..
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class NoPaste extends KeyAdapter {
public void keyPressed(KeyEvent e) {
if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_V) {
e.consume();
public class Test extends JFrame {
public Test() {
super("Test");
setDefaultCloseOperation(EXIT_ON_CLOSE);
addKeyListener(new NoPaste());
JTextField jf = new JTextField(20);
Container c = getContentPane();
c.setLayout(new FlowLayout(FlowLayout.CENTER));
c.add(new JLabel("Paste: "));
c.add(new JTextField(20));
c.add(new JLabel("No Paste: "));
c.add(jf);
jf.addKeyListener(new NoPaste());
pack();
show();
public static void main(String[] args) {
new Test();
}by calling addKeyListener(new NoPaste()); with each component you want, you can disable the ctrl+v key function. the negative side is that a context menu (or any other 3rd party component) could still call paste(), but then again they could call setText anyway, so its not much difference. not to mention Swing does not feature context menus by default..
Similar Messages
-
Copy and Paste into Java Applet
I know there have been some posts like this in the paste, but could not find a reasonable explanation.
JVM 1.4.2_08
For an unsigned java applet (Swing) I could not copy from a notepad document into my applets JTextField and JTextArea fields.
JVM 1.5
For this same applet (Swing) running under 1.5, I could copy and paste from the notepad document into my applets JTextField and JTextArea fields.
Does anybody know why the difference?
Is there a way to copy and paste for applets running in the 1.4.2 jvm?
Thanks.I think it must be some security restriction.
Set a policy for the applet or sign it:
Set a policy (windows):
C:\Program Files\Java\j2re****\lib\security\java.policy
under grant {
permission java.security.AllPermission;
this means that you give all permission to all code, if you only want to give permissions for applets
comming from google you can add the following:
grant codeBase "http://google.com/-" {
permission java.security.AllPermission;
to sign
http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
second post -
How to Debug Java Applet called in a BSP Component
Hi All,
In CRM Marketing->Segments->Graphical Modeler
A click on settings button will load a Java Applet window.
The settings window displays some elements. I want to translate a text displayed in that Java Applet window.
Please let me know the ways to debug a Java applet loaded from BSP Component or ways the data is loaded into Java applet from SAP.
Your help would be appreciated and points will be rewarded.
Thanks a lot in advance.For the newbies, like me:
Instruction to setup and debug an applet in Eclipse IDE via your Browser
Java Console Setup for Applet debugging:
1. Open up the Java Console Application by double clicking on it at C:\Program Files (x86)\Java\jre1.6.0_03\bin\javacpl.exe
2. Select the Java Tab
3. View Applet Runtime Settings button
4. Enter in the Java Runtime Parameters the following: -Xdebug -Xrunjdwp:transport=dt_socket,address=5555,server=y,suspend=y
5. Note: the port address 5555 can be anytime you want. You will need to enter whatever number you select into Eclipse IDE.
6. Note: if you don�t need to debug code in the Applet�s init() method, then use....suspend=n (Not tested yet.)
Eclipse setup for Applet debugging:
1. Open up Eclipse and create your Applet. Once you are ready to debug go to the next step.
2. Select the top level Run menu
3. Pick the Open Debug Dialog� option
4. In the left column select Remote Java Application
5. Then select the �New� button to create a debug configuration for the remote session (the new button looks like a page with a yellow plus in the upper right hand corner)
6. Give your session a name. I used the class name followed with the work remote for example: mainclassnameRemote
7. Set connection type to Standard (Socket Attached)
8. Host to localhost
9. Port to 5555, or whatever you used in Java Console Setup step 5.
10. Due not check the �Allow termination of remote VM�
11. Due not close this window.
Start debugging:
1. Go to your Applet html launch file and launch in a browser
2. Then go back to eclipse and select the debug button
3. Eclipse should now throw you into the debugger mode.
4. If it hangs, just retry again. It seems to work ok most of the time. A few time I need to close the browser and start over and then it seems to work. -
Java Script - Java Applet Communication help me
hi
In my website i used html form to get the input from user. the user press the button the value are passed into java applet. The result will display in applet.
my HTML coding for calling applet is
<SCRIPT LANGUAGE="JavaScript"><!--
var info = navigator.userAgent; var ns = false;
var ie = (info.indexOf("MSIE") > 0 && info.indexOf("Win") > 0 && info.indexOf("Windows 3.1") < 0);
//--></SCRIPT>
<SCRIPT LANGUAGE="JavaScript"><!--
if (_ie == true) document.writeln('<Center><OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" width="360" height="350" codebase="http://java.sun.com/products/plugin/1.1.2/jinstall-112-win32.cab#Vers ion=1,1,2,0"><NOEMBED><XMP>');
else if (_ns == true) document.writeln('<EMBED type="application/x-java-applet;version=1.1.2" java_CODE = "suddhi.class" name=SuddhiPanchang width="360" height="350" pluginspage="http://java.sun.com/products/plugin/1.1.2/plugin-install.html"> <NOEMBED><XMP>');
//--></SCRIPT>
<APPLET mayscript="true" CODE = "suddhi.class" width="450" height="200" name=SuddhiPanchang ></XMP>
<PARAM NAME = CODE VALUE = "suddhi.class" >
</APPLET></NOEMBED></EMBED></OBJECT>
java script code
function calculate()
if(checkEntries(document.forms[0]))return;
with(Math){
var day1 = floor(document.forms[0].Day1.value);
var mon1 = floor(document.forms[0].Month1.selectedIndex) +1;
var year1 = floor(document.forms[0].Year1.value);
var day2 = floor(document.forms[0].Day2.value);
var mon2 = floor(document.forms[0].Month2.selectedIndex) +1;
var year2 = floor(document.forms[0].Year2.value);
var tzone = abs(floor(document.forms[0].ZoneHour.value));
tzone += floor(document.forms[0].ZoneMin.value)/60;
if(Math.floor(document.forms[0].ZoneHour.value)<0.0) tzone *= -1;
document.SuddhiPanchang.setStart(day1,mon1,year1,day2,mon2,year2,tzone);}
i have error in the above line
'document.SuddhiPanchang' is null or not an object
url: http:\\rafik.cheyon.com\panch\msuddhi.htm check this
please help me
thanxYou need to access it as document.formname.objectname
-
Problem converting a (working) Java program into an applet
When I'm trying to access an Image through a call to :
mediaTracker = new MediaTracker(this);
backGroundImage = getImage(getDocumentBase(), "background.gif");
mediaTracker.addImage(backGroundImage, 0);
I'm getting a nullPointerException as a result of the call to getDocumentBase() :
C:\Chantier\Java\BallsApplet
AppletViewer testBallsApplet.htmljava.lang.NullPointerException
at java.applet.Applet.getDocumentBase(Applet.java:125)
at Balls.<init>(Balls.java:84)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:296)
at java.lang.Class.newInstance(Class.java:249)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:548)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:477)
at sun.applet.AppletPanel.run(AppletPanel.java:290)
at java.lang.Thread.run(Thread.java:536)
It seems very weird to me... :-/
(all the .gif files are in the same directory than the .class files)
The problem appears with AppletViewer trying to open an HTML file
containing :
<HTML>
<APPLET CODE="Balls.class" WIDTH=300 HEIGHT=211>
</APPLET>
</HTML>
(I tried unsuccessfully the CODEBASE and ARCHIVE attributes, with and without putting the .gif and .class into a .jar file)
I can't find the solution by myself, so, I'd be very glad if someone could help
me with this... Thank you very much in advance ! :-)
You'll find below the source of a small game that I wrote and debugged (without
problem) and that I'm now (unsuccessfully) trying to convert into an Applet :
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.net.URL;
public class Balls extends java.applet.Applet implements Runnable, KeyListener
private Image offScreenImage;
private Image backGroundImage;
private Image[] gifImages = new Image[6];
private Image PressStart ;
private Sprite pressStartSprite = null ;
private Image YouLose ;
private Sprite YouLoseSprite = null ;
private Image NextStage ;
private Sprite NextStageSprite = null ;
private Image GamePaused ;
private Sprite GamePausedSprite = null ;
//offscreen graphics context
private Graphics offScreenGraphicsCtx;
private Thread animationThread;
private MediaTracker mediaTracker;
private SpriteManager spriteManager;
//Animation display rate, 12fps
private int animationDelay = 83;
private Random rand = new Random(System.currentTimeMillis());
private int message = 0 ; // 0 = no message (normal playing phase)
// 1 = press space to start
// 2 = press space for next level
// 3 = game PAUSED, press space to unpause
// 4 = You LOSE
public static void main(String[] args)
try
new Balls() ;
catch (java.net.MalformedURLException e)
System.out.println(e);
}//end main
public void start()
//Create and start animation thread
animationThread = new Thread(this);
animationThread.start();
public void init()
try
new Balls() ;
catch (java.net.MalformedURLException e)
System.out.println(e);
public Balls() throws java.net.MalformedURLException
{//constructor
// Load and track the images
mediaTracker = new MediaTracker(this);
backGroundImage = getImage(getDocumentBase(), "background.gif");
mediaTracker.addImage(backGroundImage, 0);
PressStart = getImage(getDocumentBase(), "press_start.gif");
mediaTracker.addImage(PressStart, 0);
NextStage = getImage(getDocumentBase(), "stage_complete.gif");
mediaTracker.addImage(NextStage, 0);
GamePaused = getImage(getDocumentBase(), "game_paused.gif");
mediaTracker.addImage(GamePaused, 0);
YouLose = getImage(getDocumentBase(), "you_lose.gif");
mediaTracker.addImage(YouLose, 0);
//Get and track 6 images to use
// for sprites
gifImages[0] = getImage(getDocumentBase(), "blueball.gif");
mediaTracker.addImage(gifImages[0], 0);
gifImages[1] = getImage(getDocumentBase(), "redball.gif");
mediaTracker.addImage(gifImages[1], 0);
gifImages[2] = getImage(getDocumentBase(), "greenball.gif");
mediaTracker.addImage(gifImages[2], 0);
gifImages[3] = getImage(getDocumentBase(), "yellowball.gif");
mediaTracker.addImage(gifImages[3], 0);
gifImages[4] = getImage(getDocumentBase(), "purpleball.gif");
mediaTracker.addImage(gifImages[4], 0);
gifImages[5] = getImage(getDocumentBase(), "orangeball.gif");
mediaTracker.addImage(gifImages[5], 0);
//Block and wait for all images to
// be loaded
try {
mediaTracker.waitForID(0);
}catch (InterruptedException e) {
System.out.println(e);
}//end catch
//Base the Frame size on the size
// of the background image.
//These getter methods return -1 if
// the size is not yet known.
//Insets will be used later to
// limit the graphics area to the
// client area of the Frame.
int width = backGroundImage.getWidth(this);
int height = backGroundImage.getHeight(this);
//While not likely, it may be
// possible that the size isn't
// known yet. Do the following
// just in case.
//Wait until size is known
while(width == -1 || height == -1)
System.out.println("Waiting for image");
width = backGroundImage.getWidth(this);
height = backGroundImage.getHeight(this);
}//end while loop
//Display the frame
setSize(width,height);
setVisible(true);
//setTitle("Balls");
//Anonymous inner class window
// listener to terminate the
// program.
this.addWindowListener
(new WindowAdapter()
{public void windowClosing(WindowEvent e){System.exit(0);}});
// Add a key listener for keyboard management
this.addKeyListener(this);
}//end constructor
public void run()
Point center_place = new Point(
backGroundImage.getWidth(this)/2-PressStart.getWidth(this)/2,
backGroundImage.getHeight(this)/2-PressStart.getHeight(this)/2) ;
pressStartSprite = new Sprite(this, PressStart, center_place, new Point(0, 0),true);
center_place = new Point(
backGroundImage.getWidth(this)/2-NextStage.getWidth(this)/2,
backGroundImage.getHeight(this)/2-NextStage.getHeight(this)/2) ;
NextStageSprite = new Sprite(this, NextStage, center_place, new Point(0, 0),true);
center_place = new Point(
backGroundImage.getWidth(this)/2-GamePaused.getWidth(this)/2,
backGroundImage.getHeight(this)/2-GamePaused.getHeight(this)/2) ;
GamePausedSprite = new Sprite(this, GamePaused, center_place, new Point(0, 0),true);
center_place = new Point(
backGroundImage.getWidth(this)/2-YouLose.getWidth(this)/2,
backGroundImage.getHeight(this)/2-YouLose.getHeight(this)/2) ;
YouLoseSprite = new Sprite(this, YouLose, center_place, new Point(0, 0),true);
BackgroundImage bgimage = new BackgroundImage(this, backGroundImage) ;
for (;;) // infinite loop
long time = System.currentTimeMillis();
message = 1 ; // "press start to begin"
while (message != 0)
repaint() ;
try
time += animationDelay;
Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
catch (InterruptedException e)
System.out.println(e);
}//end catch
boolean you_lose = false ;
for (int max_speed = 7 ; !you_lose && max_speed < 15 ; max_speed++)
for (int difficulty = 2 ; !you_lose && difficulty < 14 ; difficulty++)
boolean unfinished_stage = true ;
spriteManager = new SpriteManager(bgimage);
spriteManager.setParameters(difficulty, max_speed) ;
//Create 15 sprites from 6 gif
// files.
for (int cnt = 0; cnt < 15; cnt++)
if (cnt == 0)
Point position = new Point(
backGroundImage.getWidth(this)/2-gifImages[0].getWidth(this)/2,
backGroundImage.getHeight(this)/2-gifImages[0].getHeight(this)/2) ;
spriteManager.addSprite(makeSprite(position, 0, false));
else
Point position = spriteManager.
getEmptyPosition(new Dimension(gifImages[0].getWidth(this),
gifImages[0].getHeight(this)));
if (cnt < difficulty)
spriteManager.addSprite(makeSprite(position, 1, true));
else
spriteManager.addSprite(makeSprite(position, 2, true));
}//end for loop
time = System.currentTimeMillis();
while (!spriteManager.getFinishedStage() && !spriteManager.getGameOver())
// Loop, sleep, and update sprite
// positions once each 83
// milliseconds
spriteManager.update();
repaint();
try
time += animationDelay;
Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
catch (InterruptedException e)
System.out.println(e);
}//end catch
}//end while loop
if (spriteManager.getGameOver())
message = 4 ;
while (message != 0)
spriteManager.update();
repaint();
try
time += animationDelay;
Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
catch (InterruptedException e)
System.out.println(e);
}//end catch
you_lose = true ;
if (spriteManager.getFinishedStage())
message = 2 ;
while (message != 0)
spriteManager.update();
repaint();
try
time += animationDelay;
Thread.sleep(Math.max(0,time - System.currentTimeMillis()));
catch (InterruptedException e)
System.out.println(e);
}//end catch
} // end for difficulty loop
} // end for max_speed
} // end infinite loop
}//end run method
private Sprite makeSprite(Point position, int imageIndex, boolean wind)
return new Sprite(
this,
gifImages[imageIndex],
position,
new Point(rand.nextInt() % 5,
rand.nextInt() % 5),
wind);
}//end makeSprite()
//Overridden graphics update method
// on the Frame
public void update(Graphics g)
//Create the offscreen graphics
// context
if (offScreenGraphicsCtx == null)
offScreenImage = createImage(getSize().width,
getSize().height);
offScreenGraphicsCtx = offScreenImage.getGraphics();
}//end if
if (message == 0)
// Draw the sprites offscreen
spriteManager.drawScene(offScreenGraphicsCtx);
else if (message == 1)
pressStartSprite.drawSpriteImage(offScreenGraphicsCtx);
else if (message == 2)
NextStageSprite.drawSpriteImage(offScreenGraphicsCtx);
else if (message == 3)
GamePausedSprite.drawSpriteImage(offScreenGraphicsCtx);
else if (message == 4)
YouLoseSprite.drawSpriteImage(offScreenGraphicsCtx);
// Draw the scene onto the screen
if(offScreenImage != null)
g.drawImage(offScreenImage, 0, 0, this);
}//end if
}//end overridden update method
//Overridden paint method on the
// Frame
public void paint(Graphics g)
//Nothing required here. All
// drawing is done in the update
// method above.
}//end overridden paint method
// Methods to handle Keyboard event
public void keyPressed(KeyEvent evt)
int key = evt.getKeyCode(); // Keyboard code for the pressed key.
if (key == KeyEvent.VK_SPACE)
if (message != 0)
message = 0 ;
else
message = 3 ;
if (key == KeyEvent.VK_LEFT)
if (spriteManager != null)
spriteManager.goLeft() ;
else if (key == KeyEvent.VK_RIGHT)
if (spriteManager != null)
spriteManager.goRight() ;
else if (key == KeyEvent.VK_UP)
if (spriteManager != null)
spriteManager.goUp() ;
else if (key == KeyEvent.VK_DOWN)
if (spriteManager != null)
spriteManager.goDown() ;
if (spriteManager != null)
spriteManager.setMessage(message) ;
public void keyReleased(KeyEvent evt)
public void keyTyped(KeyEvent e)
char key = e.getKeyChar() ;
//~ if (key == 's')
//~ stop = true ;
//~ else if (key == 'c')
//~ stop = false ;
//~ spriteManager.setStop(stop) ;
}//end class Balls
//===================================//
class BackgroundImage
private Image image;
private Component component;
private Dimension size;
public BackgroundImage(
Component component,
Image image)
this.component = component;
size = component.getSize();
this.image = image;
}//end construtor
public Dimension getSize(){
return size;
}//end getSize()
public Image getImage(){
return image;
}//end getImage()
public void setImage(Image image){
this.image = image;
}//end setImage()
public void drawBackgroundImage(Graphics g)
g.drawImage(image, 0, 0, component);
}//end drawBackgroundImage()
}//end class BackgroundImage
//===========================
class SpriteManager extends Vector
private BackgroundImage backgroundImage;
private boolean finished_stage = false ;
private boolean game_over = false ;
private int difficulty ;
private int max_speed ;
public boolean getFinishedStage()
finished_stage = true ;
for (int cnt = difficulty ; cnt < size(); cnt++)
Sprite sprite = (Sprite)elementAt(cnt);
if (!sprite.getEaten())
finished_stage = false ;
return finished_stage ;
public boolean getGameOver() {return game_over ;}
public void setParameters(int diff, int speed)
difficulty = diff ;
max_speed = speed ;
finished_stage = false ;
game_over = false ;
Sprite sprite;
for (int cnt = 0;cnt < size(); cnt++)
sprite = (Sprite)elementAt(cnt);
sprite.setSpeed(max_speed) ;
public SpriteManager(BackgroundImage backgroundImage)
this.backgroundImage = backgroundImage ;
}//end constructor
public Point getEmptyPosition(Dimension spriteSize)
Rectangle trialSpaceOccupied = new Rectangle(0, 0,
spriteSize.width,
spriteSize.height);
Random rand = new Random(System.currentTimeMillis());
boolean empty = false;
int numTries = 0;
// Search for an empty position
while (!empty && numTries++ < 100)
// Get a trial position
trialSpaceOccupied.x =
Math.abs(rand.nextInt() %
backgroundImage.
getSize().width);
trialSpaceOccupied.y =
Math.abs(rand.nextInt() %
backgroundImage.
getSize().height);
// Iterate through existing
// sprites, checking if position
// is empty
boolean collision = false;
for(int cnt = 0;cnt < size(); cnt++)
Rectangle testSpaceOccupied = ((Sprite)elementAt(cnt)).getSpaceOccupied();
if (trialSpaceOccupied.intersects(testSpaceOccupied))
collision = true;
}//end if
}//end for loop
empty = !collision;
}//end while loop
return new Point(trialSpaceOccupied.x, trialSpaceOccupied.y);
}//end getEmptyPosition()
public void update()
Sprite sprite;
// treat special case of sprite #0 (the player)
sprite = (Sprite)elementAt(0);
sprite.updatePosition() ;
int hitIndex = testForCollision(sprite);
if (hitIndex != -1)
if (hitIndex < difficulty)
{ // if player collides with an hunter (red ball), he loose
sprite.setEaten() ;
game_over = true ;
else
// if player collides with an hunted (green ball), he eats the green
((Sprite)elementAt(hitIndex)).setEaten() ;
//Iterate through sprite list
for (int cnt = 1;cnt < size(); cnt++)
sprite = (Sprite)elementAt(cnt);
//Update a sprite's position
sprite.updatePosition();
//Test for collision. Positive
// result indicates a collision
hitIndex = testForCollision(sprite);
if (hitIndex >= 0)
//a collision has occurred
bounceOffSprite(cnt,hitIndex);
}//end if
}//end for loop
}//end update
public void setMessage(int message)
Sprite sprite;
//Iterate through sprite list
for (int cnt = 0;cnt < size(); cnt++)
sprite = (Sprite)elementAt(cnt);
//Update a sprite's stop status
sprite.setMessage(message);
}//end for loop
}//end update
public void goLeft()
Sprite sprite = (Sprite)elementAt(0);
sprite.goLeft() ;
public void goRight()
Sprite sprite = (Sprite)elementAt(0);
sprite.goRight() ;
public void goUp()
Sprite sprite = (Sprite)elementAt(0);
sprite.goUp() ;
public void goDown()
Sprite sprite = (Sprite)elementAt(0);
sprite.goDown() ;
private int testForCollision(Sprite testSprite)
//Check for collision with other
// sprites
Sprite sprite;
for (int cnt = 0;cnt < size(); cnt++)
sprite = (Sprite)elementAt(cnt);
if (sprite == testSprite)
//don't check self
continue;
//Invoke testCollision method
// of Sprite class to perform
// the actual test.
if (testSprite.testCollision(sprite))
//Return index of colliding
// sprite
return cnt;
}//end for loop
return -1;//No collision detected
}//end testForCollision()
private void bounceOffSprite(int oneHitIndex, int otherHitIndex)
//Swap motion vectors for
// bounce algorithm
Sprite oneSprite = (Sprite)elementAt(oneHitIndex);
Sprite otherSprite = (Sprite)elementAt(otherHitIndex);
Point swap = oneSprite.getMotionVector();
oneSprite.setMotionVector(otherSprite.getMotionVector());
otherSprite.setMotionVector(swap);
}//end bounceOffSprite()
public void drawScene(Graphics g)
//Draw the background and erase
// sprites from graphics area
//Disable the following statement
// for an interesting effect.
backgroundImage.drawBackgroundImage(g);
//Iterate through sprites, drawing
// each sprite
for (int cnt = 0;cnt < size(); cnt++)
((Sprite)elementAt(cnt)).drawSpriteImage(g);
}//end drawScene()
public void addSprite(Sprite sprite)
addElement(sprite);
}//end addSprite()
}//end class SpriteManager
//===================================//
class Sprite
private Component component;
private Image image;
private Rectangle spaceOccupied;
private Point motionVector;
private Rectangle bounds;
private Random rand;
private int message = 0 ; // number of message currently displayed (0 means "no message" = normal game)
private int max_speed = 7 ;
private boolean eaten = false ; // when a green sprite is eaten, it is no longer displayed on screen
private boolean wind = true ;
private boolean go_left = false ;
private boolean go_right = false ;
private boolean go_up = false ;
private boolean go_down = false ;
public Sprite(Component component,
Image image,
Point position,
Point motionVector,
boolean Wind
//Seed a random number generator
// for this sprite with the sprite
// position.
rand = new Random(position.x);
this.component = component;
this.image = image;
setSpaceOccupied(new Rectangle(
position.x,
position.y,
image.getWidth(component),
image.getHeight(component)));
this.motionVector = motionVector;
this.wind = Wind ;
//Compute edges of usable graphics
// area in the Frame.
int topBanner = ((Container)component).getInsets().top;
int bottomBorder = ((Container)component).getInsets().bottom;
int leftBorder = ((Container)component).getInsets().left;
int rightBorder = ((Container)component).getInsets().right;
bounds = new Rectangle( 0 + leftBorder, 0 + topBanner
, component.getSize().width - (leftBorder + rightBorder)
, component.getSize().height - (topBanner + bottomBorder));
}//end constructor
public void setMessage(int message_number)
message = message_number ;
public void setSpeed(int speed)
max_speed = speed ;
public void goLeft()
go_left = true ;
public void goRight()
go_right = true ;
public void goUp()
go_up = true ;
public void goDown()
go_down = true ;
public void setEaten()
eaten = true ;
setSpaceOccupied(new Rectangle(4000,4000,0,0)) ;
public boolean getEaten()
return eaten ;
public Rectangle getSpaceOccupied()
return spaceOccupied;
}//end getSpaceOccupied()
void setSpaceOccupied(Rectangle spaceOccupied)
this.spaceOccupied = spaceOccupied;
}//setSpaceOccupied()
public void setSpaceOccupied(
Point position){
spaceOccupied.setLocation(
position.x, position.y);
}//setSpaceOccupied()
public Point getMotionVector(){
return motionVector;
}//end getMotionVector()
public void setMotionVector(
Point motionVector){
this.motionVector = motionVector;
}//end setMotionVector()
public void setBounds(Rectangle bounds)
this.bounds = bounds;
}//end setBounds()
public void updatePosition()
Point position = new Point(spaceOccupied.x, spaceOccupied.y);
if (message != 0)
return ;
//Insert random behavior. During
// each update, a sprite has about
// one chance in 10 of making a
// random change to its
// motionVector. When a change
// occurs, the motionVector
// coordinate values are forced to
// fall between -7 and 7. This
// puts a cap on the maximum speed
// for a sprite.
if (!wind)
if (go_left)
motionVector.x -= 2 ;
if (motionVector.x < -15)
motionVector.x = -14 ;
go_left = false ;
if (go_right)
motionVector.x += 2 ;
if (motionVector.x > 15)
motionVector.x = 14 ;
go_right = false ;
if (go_up)
motionVector.y -= 2 ;
if (motionVector.y < -15)
motionVector.y = -14 ;
go_up = false ;
if (go_down)
motionVector.y += 2 ;
if (motionVector.y > 15)
motionVector.y = 14 ;
go_down = false ;
else if(rand.nextInt() % 7 == 0)
Point randomOffset =
new Point(rand.nextInt() % 3,
rand.nextInt() % 3);
motionVector.x += randomOffset.x;
if(motionVector.x >= max_speed)
motionVector.x -= max_speed;
if(motionVector.x <= -max_speed)
motionVector.x += max_speed ;
motionVector.y += randomOffset.y;
if(motionVector.y >= max_speed)
motionVector.y -= max_speed;
if(motionVector.y <= -max_speed)
motionVector.y += max_speed;
}//end if
//Move the sprite on the screen
position.translate(motionVector.x, motionVector.y);
//Bounce off the walls
boolean bounceRequired = false;
Point tempMotionVector = new Point(
motionVector.x,
motionVector.y);
//Handle walls in x-dimension
if (position.x < bounds.x)
bounceRequired = true;
position.x = bounds.x;
//reverse direction in x
tempMotionVector.x = -tempMotionVector.x;
else if ((position.x + spaceOccupied.width) > (bounds.x + bounds.width))
bounceRequired = true;
position.x = bounds.x +
bounds.width -
spaceOccupied.width;
//reverse direction in x
tempMotionVector.x =
-tempMotionVector.x;
}//end else if
//Handle walls in y-dimension
if (position.y < bounds.y)
bounceRequired = true;
position.y = bounds.y;
tempMotionVector.y = -tempMotionVector.y;
else if ((position.y + spaceOccupied.height)
> (bounds.y + bounds.height))
bounceRequired = true;
position.y = bounds.y +
bounds.height -
spaceOccupied.height;
tempMotionVector.y =
-tempMotionVector.y;
}//end else if
if(bounceRequired)
//save new motionVector
setMotionVector(
tempMotionVector);
//update spaceOccupied
setSpaceOccupied(position);
}//end updatePosition()
public void drawSpriteImage(Graphics g)
if (!eaten)
g.drawImage(image,
spaceOccupied.x,
spaceOccupied.y,
component);
}//end drawSpriteImage()
public boolean testCollision(Sprite testSprite)
//Check for collision with
// another sprite
if (testSprite != this)
return spaceOccupied.intersects(
testSprite.getSpaceOccupied());
}//end if
return false;
}//end testCollision
}//end Sprite class
//===================================//
Thanks for your help...Sorry,
Can you tell me how do you solve it because I have got the same problem.
Can you indicate me the topic where did you find solution.
Thank in advance. -
Java Applet Wont Load Past 80%
Someone is running a java based paint chat off of their home system, so far all of us have been able to load it all the way, except for one person who can't seem to get the applet to load past 80%.
She says she's got the latest update for OS X and she's gotten it to load before. She's tried updating Java and restarting her system. We don't think it's a firewall, seeing as other people can access it and she doesn't think she's running one.
Any thoughts on what the issue could be would be greatly appreciated.Have her go to this Sun page and test her Java installation.
http://java.com/en/download/help/testvm.jsp
If there's no problem, she should look for a cause other than Java/applets.
If there is a problem, the page has troubleshooting information. -
On certain web sites(with java applets embedded or rich content),sometimes browser hotkeys are beeing used with other functionality (eg.: youtube uses ctrl + tab for sliding between player controls).How can I prevent this ?
Thanks for posting this!
I would only mention that your definition is incomplete for this -
Contextual selector A type of Style Sheet Selector that
and that it's most often referred to now as a Descendent selector, not a contextual selector. It's basically the same as the Compound selector that you have already defined.... -
Cut and Paste into JTextPane of Applet
I am just a JTextPane in an Applet. I want to allow the user to cut and paste text from word into my applet but it seems like it will not transfer. When I transfer the applet to a application it works or if I run the applet in an applet viewer , it works also. When I run the applet over the net into IE, I cannot cut and paste???
There seems to be two different clip boards. One in the applet and one on the desktop. Any suggestions out there??? Help!Bingo! It is applet security at work. You can not access the system clipboard from an applet. You must sign the applet and then accept the signature when you run the applet or change your policy file (doing the second has many security risks and is not recommended).
If the applet is signed you will not have to add a key listener, just focus on the text field and type ctrl+v and it will paste for you.
DeltaCoder -
Turning a Java applett into a *.exe
How do you turn a Java applett into an *.exe?
Have a look at http://gcc.gnu.org/java/. Its not complete, and I've never tried it on Windows, but it kinda works for linux.
The other thing you could do is create a C/C++ wrapper that starts a JVM and runs your main class. http://www.kcmultimedia.com/javaserv/ has some GPL code for doing this for an NT service, but the principle is the same for non-service apps. -
We have about 1,800 workstations running Windows 7 (both 32-bit and 64-bit) running various versions of the Java JRE from 6 update 32 through 7 update 51. Most are on 6 update 45. We would like to standardize on Java 7 update 51 (32-bit) and get everyone updated to that version for security reasons.
For the past two weeks, we have been having trouble with our installation pre-pilot. What we are seeing is that our procedure successfully closes any open Internet Explorer windows and Java-related processes, uninstalls all old versions of the Java JRE, and then claims to have successfully installed Java 7 update 51. The Java Control panel works. We can even take Internet Explorer to Verify Java Version or Java Tester - What Version of Java Are You Running? and confirm that the Java applets on those sites are loading (though the latter only works after adding the site to the exceptions site list); however, when testers try to access our Kronos Workforce Central 6.3.10 system, the Java applets used by that system do not load.
We have tried the following things, none of which worked:
Clear Internet Explorer browser cache and cookies.
Clear the local Java cache.
Reboot the computer.
Reset Internet Explorer settings, including personal settings.
The one thing which does work is going into the Java Control Panel, going to the Security tab, unchecking "Enable Java content in the browser", pressing Apply, pressing OK on the pop-up window, checking the "Enable Java content in the browser" box again, pressing OK, pressing OK on the pop-up window, and then restarting Internet Explorer. It is only after this point that all Java applets, including the ones used by Kronos Workforce Central 6.3.10, work.
What I need to know is how I can automate the procedure of reinitializing the "Enable Java content in the browser" checkbox after installation or am I doing something wrong or missing a step in the automated installation that is causing this to happen?
We are using Microsoft SCCM 2007 R3 to accomplish this upgrade, and everything is being run on the client machine using the SYSTEM account. First, the PowerShell script "javaclean.ps1" is run, with part of the command-line process changing the PowerShell script execution policy to Bypass. This script handles the closing of Java-dependent applications and Java processes and uninstalls old Java versions.
javaclean.ps1:
#Find all Java products excluding the auto updater which actually gets uninstalled when the main install is removed.
write-host "Searching for all installed Java versions" -ForegroundColor Yellow
[array]$javas=Get-WmiObject -query "select * from win32_Product where (Name like 'Java %' or Name like 'Java(TM)%' or Name like 'J2SE%') and Name <> 'Java Auto Updater'"
if ($javas.count -gt 0)
write-host "Java is already Installed" -ForegroundColor Yellow
#Get all the Java processes and kill them. If java is running and the processes aren't killed then this script will invoke a sudden reboot.
[array]$processes=Get-Process -Name "Java*" #-erroraction silentlycontinue
$processes += Get-Process -Name "iexplore" #-erroraction silentlycontinue
$processes += Get-Process -Name "firefox" #-erroraction silentlycontinue
$processes += Get-Process -Name "chrome" #-erroraction silentlycontinue
$processes += Get-Process -Name "jqs" #-erroraction silentlycontinue
$processes += Get-Process -Name "jusched" #-erroraction silentlycontinue
$processes += Get-Process -Name "jp2launcher" #-erroraction silentlycontinue
if ($processes.Count -gt 0)
foreach ($myprocess in $processes)
$myprocess.kill()
#Loop through the installed Java products.
foreach($java in $javas){
write-host "Uninstalling "$java.name -ForegroundColor Yellow
$java.Uninstall()
After this script is complete, SCCM calls a the VBS script "install.vbs" to perform the actual installation of Java JRE 7 update 51.
install.vbs
'* Script: Install JRE 7 routine
'* Date: 3/14/14
'* Author: [REDACTED]
'* Rev: 1.0
'* Notes:
'/// Common
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWshShell = CreateObject("WScript.Shell")
' Get system architecture
Dim colSys : Set colSys = GetObject("WinMGMTS://").ExecQuery("SELECT AddressWidth FROM Win32_Processor",, 48)
Dim objSys
For Each objSys In colSys
If objSys.AddressWidth = 64 Then bolIs64Bit = True
Next
' Get operating system
Dim colOS : Set colOS = GetObject("WinMGMTS://").ExecQuery ("Select * from Win32_OperatingSystem",,48)
Dim objOS
For Each objOS In colOS
If Left(objOS.caption, 20) = "Microsoft Windows 8 " Then
bolIsWin8 = True
WScript.Echo "win8"
End If
If Left(objOS.caption, 22) = "Microsoft Windows 8.1 " Then
bolIsWin81 = True
WScript.Echo "win81"
End If
Next
' Set 32 bit program files directory
If bolIs64Bit = True Then
strPFILES = "Program Files (x86)"
strSYSDIR = "SysWOW64"
Else strPFILES = "Program Files"
strSYSDIR = "System32"
End If
' Set windows directory
strWIN = objWshShell.ExpandEnvironmentStrings("%windir%")
' Set the current directory
strCurrentDir = objFSO.GetParentFolderName(Wscript.ScriptFullName)
' Set computer name
strCompName = objWshShell.ExpandEnvironmentStrings("%computername%")
'/// Main script
'/// Install via .msi & capture exit code
'intExitCode = objWshShell.Run("msiexec.exe /i """ & strCurrentDir & "\package.msi""" & " TRANSFORMS=""" & strCurrentDir & _
' "\transform.mst"" ALLUSERS=1 Reboot=ReallySuppress /qn", 8, True)
'wscript.quit(intExitCode)
'****RUN COMMANDS HERE****
' Create folder structure if it doesn't exist already
strFullPath = "c:\Windows\Sun\Java\Deployment" '
' How many levels are there in the path?
nLevel = 0
strParentPath = strFullPath
Do Until strParentPath = ""
strParentPath = objFSO.GetParentFolderName(strParentPath)
nLevel = nLevel + 1
Loop
For iLevel = 1 To nLevel
' Figure out path for directory at level iLevel
strParentPath = strFullPath
For j = 1 To nLevel - iLevel
strParentPath = objFSO.GetParentFolderName(strParentPath)
Next
' Does this directory exist? If not, create it.
If objFSO.FolderExists(strParentPath) = False Then
Set newFolder = objFSO.CreateFolder(strParentPath)
End If
Next
' Kill running processes
objWshShell.Run "taskkill /F /IM iexplore.exe", 8, True
objWshShell.Run "taskkill /F /IM firefox.exe", 8, True
objWshShell.Run "taskkill /F /IM chrome.exe", 8, True
objWshShell.Run "taskkill /F /IM javaw.exe", 8, True
objWshShell.Run "taskkill /F /IM java.exe", 8, True
objWshShell.Run "taskkill /F /IM jqs.exe", 8, True
objWshShell.Run "taskkill /F /IM jusched.exe", 8, True
' Copy deployment files
objFSO.CopyFile strCurrentDir & "\deployment.config", "c:\Windows\Sun\Java\Deployment\", True
objFSO.CopyFile strCurrentDir & "\deployment.properties", "c:\Windows\Sun\Java\Deployment\", True
' Disable UAC
' If bolIsWin8 Or bolIsWin81 = True Then
' objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 0 /f", 8, True
' objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f", 8, True
' objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f", 8, True
' End If
' Install application
intExitCode = objWshShell.Run("msiexec.exe /i """ & strCurrentDir & "\jre1.7.0_51.msi"" IEXPLORER=1 AUTOUPDATECHECK=0 JAVAUPDATE=0 JU=0 WEB_JAVA=1 ALLUSERS=1 Reboot=ReallySuppress /qn", 8, True)
' Enable UAC
' If bolIsWin8 Or bolIsWin81 = True Then
' objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 1 /f", 8, True
' objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f", 8, True
' objWshShell.Run "reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 5 /f", 8, True
' End If
wscript.quit(intExitCode)
'/// Install via .exe on network
'objWshShell.Run """" & strCurrentDir & "\Setup.exe"" -s -sms -f1""" & strCurrentDir & _
' "\setup.iss"" -f2""" & strWIN & "\Temp\Install-app.txt""", 8, True
' Need to turn off the open file security warning first
Set objEnv = objWshShell.Environment("PROCESS")
objEnv("SEE_MASK_NOZONECHECKS") = 1
' intExitCode = objWshShell.Run("""" & strCurrentDir & "\jre-7u45-windows-i586.exe"" /s /v""/norestart " & _
' "TRANSFORMS=""" & strCurrentDir & "\Tribe-jre7.mst""""", 8, True)
' WScript.Quit(intExitCode)
'****RUN COMMANDS HERE****
' Then turn it back on
objEnv.Remove("SEE_MASK_NOZONECHECKS")
'/// Additional functions
Help on this issue would be much appreciated!It turns out that this is actually a problem with Kronos Workforce Central. We had the "site.java.plugin.CLSID.familyVersion" setting in that application set to "clsid:CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA", which is the Java CLSID for Java 6. After updating this value to "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" (the Java universal CLSID), this problem did not occur upon the automatic upgrade of Java.
We have both Java 6 and Java 7 in our environment, and did during our Kronos implementation, so I don't know why we were using the Java 6 CLSID in the first place.
Case closed! -
How to activate Java Applets?
Hi,
I got some Java Applets that i try to run (again). Since Javas own security and firefox itself forbids to run Java without being activated by the user i thought i would be asked whether to activate java on my own site (local on the PC) or not. Although java is activated inside in the plugins-option menu and the correct installation of java is confirmed by java.com (test after the installation) my Java applets dont show up, not even a message saying "Applets are being blocked" or so.
In chrome i can simply activate the NPAPI in the settings and enable the flag and the applets work. Isnt there a function similar to this?
I would like to run Firefox portable on a CD to give to students. As the Java applets are being blocked i hoped to simply enable the corrosponding flag so prevent rewriting all the java applets.
Is there another developer plugin of some sort that i can pre-install into Firefox portable that does the job?
See blow for Versions of Windows, Firefox. Java Version 8 Update 45 (Build 1.8.0_45-b14) latest version.
Kind regards,
Marcel Klinge
"application": {
"name": "Firefox",
"version": "37.0.2",
"buildID": "20150415140819",
"userAgent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0",
"updateChannel": "release",
"supportURL": "https://support.mozilla.org/1/firefox/37.0.2/WINNT/de/",
"numTotalWindows": 1,
"numRemoteWindows": 0
"crashes": {
"submitted": [],
"pending": 0
"modifiedPreferences": {
"accessibility.typeaheadfind.flashBar": 0,
"browser.cache.disk.smart_size.first_run": false,
"browser.cache.disk.smart_size.enabled": false,
"browser.cache.disk.capacity": 0,
"browser.cache.frecency_experiment": 4,
"browser.places.importBookmarksHTML": false,
"browser.places.smartBookmarksVersion": 7,
"browser.search.useDBForOrder": true,
"browser.sessionstore.upgradeBackup.latestBuildID": "20150415140819",
"browser.startup.homepage_override.mstone": "37.0.2",
"browser.startup.homepage": "file:///C:/Users/Klinge/Desktop/Sign%C3%BC%20I+II%20-%20Neu/sueb1/html/index.html",
"browser.startup.homepage_override.buildID": "20150415140819",
"dom.ipc.plugins.sandbox.default": true,
"dom.mozApps.used": true,
"extensions.lastAppVersion": "37.0.2",
"gfx.direct3d.last_used_feature_level_idx": 0,
"media.gmp-gmpopenh264.lastUpdate": 1430384919,
"media.gmp-gmpopenh264.version": "1.3",
"media.gmp-manager.lastCheck": 1430384919,
"network.cookie.prefsMigrated": true,
"places.database.lastMaintenance": 1430385666,
"places.history.expiration.transient_current_max_pages": 104858,
"plugin.importedState": true,
"plugin.disable_full_page_plugin_for_types": "application/pdf",
"plugin.state.java": 2,
"privacy.sanitize.migrateFx3Prefs": true,
"storage.vacuum.last.places.sqlite": 1430385666,
"storage.vacuum.last.index": 0
"lockedPreferences": {},
"graphics": {
"numTotalWindows": 1,
"numAcceleratedWindows": 1,
"windowLayerManagerType": "Direct3D 11",
"windowLayerManagerRemote": true,
"adapterDescription": "ATI Radeon HD 4650",
"adapterVendorID": "0x1002",
"adapterDeviceID": "0x9498",
"adapterSubsysID": "22691787",
"adapterRAM": "512",
"adapterDrivers": "atiumd64 atidxx64 atiumdag atidxx32 atiumdva atiumd6a atitmm64",
"driverVersion": "8.632.1.2000",
"driverDate": "8-17-2009",
"adapterDescription2": "",
"adapterVendorID2": "",
"adapterDeviceID2": "",
"adapterSubsysID2": "",
"adapterRAM2": "",
"adapterDrivers2": "",
"driverVersion2": "",
"driverDate2": "",
"isGPU2Active": false,
"direct2DEnabled": true,
"directWriteEnabled": true,
"directWriteVersion": "6.2.9200.16571",
"webglRenderer": "Google Inc. -- ANGLE (ATI Radeon HD 4650 Direct3D11 vs_4_1 ps_4_1)",
"info": {
"AzureCanvasBackend": "direct2d 1.1",
"AzureSkiaAccelerated": 0,
"AzureFallbackCanvasBackend": "cairo",
"AzureContentBackend": "direct2d 1.1"
"javaScript": {
"incrementalGCEnabled": true
"accessibility": {
"isActive": false,
"forceDisabled": 0
"libraryVersions": {
"NSPR": {
"minVersion": "4.10.8",
"version": "4.10.8"
"NSS": {
"minVersion": "3.17.4 Basic ECC",
"version": "3.17.4 Basic ECC"
"NSSUTIL": {
"minVersion": "3.17.4",
"version": "3.17.4"
"NSSSSL": {
"minVersion": "3.17.4 Basic ECC",
"version": "3.17.4 Basic ECC"
"NSSSMIME": {
"minVersion": "3.17.4 Basic ECC",
"version": "3.17.4 Basic ECC"
"userJS": {
"exists": false
"extensions": [],
"experiments": []
}use Robot Class
java.awt.Robot since jdk1.3 -
Print- Save as PDF from Java applet on a webpage in Safari
I am on a Mac running OS X version 10.8.5 and Safari version 6.1.2. I am using the website www.wordle.net, which uses a Java applet to create a Wordle. The applet has a print button. The website FAQ says I should be able to save a Wordle as a PDF on a Mac. When I try to do this I get a small dialog that simply says "Error whilte printing."
Here is some of the system.log:
Mar 4 16:57:54 Kroghs-iMac.local sandboxd[602] ([557]): java(557) deny file-write-create /private/var/folders/f0/c8r_ry6d4131x95phl6fv7kr0000gn/T/WebKitPlugin-f12Pu6/53 164c620f81b
Mar 4 16:57:54 Kroghs-iMac.local java[557]: spawn_via_launchd() failed, errno=1 label=[0x0-0x96096].com.apple.ImageCaptureExtension2 path=/System/Library/Image Capture/Support/Image Capture Extension.app/Contents/MacOS/Image Capture Extension flags=0
Mar 4 16:57:54 --- last message repeated 1 time ---
Mar 4 16:57:54 Kroghs-iMac.local java[557]: ERROR: [ICCommandCenter launchAgent] - Failed to launch agent[1], status: -10810, url: 'file://localhost/System/Library/Image%20Capture/Support/Image%20Capture%20Exte nsion.app/'
Mar 4 16:57:54 Kroghs-iMac.local java[557]:
***** Failed to launch Image Capture Extension.
Mar 4 16:57:54 Kroghs-iMac.local java[557]: spawn_via_launchd() failed, errno=1 label=[0x0-0x97097].com.apple.ImageCaptureExtension2 path=/System/Library/Image Capture/Support/Image Capture Extension.app/Contents/MacOS/Image Capture Extension flags=0
Mar 4 16:57:54 --- last message repeated 1 time ---
Mar 4 16:57:54 Kroghs-iMac.local java[557]: ERROR: [ICCommandCenter launchAgent] - Failed to launch agent[1], status: -10810, url: 'file://localhost/System/Library/Image%20Capture/Support/Image%20Capture%20Exte nsion.app/'
Mar 4 16:57:54 Kroghs-iMac.local java[557]:
***** Failed to launch Image Capture Extension.
Mar 4 16:57:54 Kroghs-iMac.local java[557]: spawn_via_launchd() failed, errno=1 label=[0x0-0x98098].com.apple.ImageCaptureExtension2 path=/System/Library/Image Capture/Support/Image Capture Extension.app/Contents/MacOS/Image Capture Extension flags=0
Mar 4 16:57:54 --- last message repeated 1 time ---
Mar 4 16:57:54 Kroghs-iMac.local java[557]: ERROR: [ICCommandCenter launchAgent] - Failed to launch agent[1], status: -10810, url: 'file://localhost/System/Library/Image%20Capture/Support/Image%20Capture%20Exte nsion.app/'
Mar 4 16:57:54 Kroghs-iMac.local java[557]:
***** Failed to launch Image Capture Extension.
Mar 4 16:57:54 Kroghs-iMac.local java[557]: spawn_via_launchd() failed, errno=1 label=[0x0-0x99099].com.apple.ImageCaptureExtension2 path=/System/Library/Image Capture/Support/Image Capture Extension.app/Contents/MacOS/Image Capture Extension flags=0
Mar 4 16:57:54 --- last message repeated 1 time ---
Mar 4 16:57:54 Kroghs-iMac.local java[557]: ERROR: [ICCommandCenter launchAgent] - Failed to launch agent[1], status: -10810, url: 'file://localhost/System/Library/Image%20Capture/Support/Image%20Capture%20Exte nsion.app/'
Mar 4 16:57:54 Kroghs-iMac.local java[557]:
***** Failed to launch Image Capture Extension.
Mar 4 16:57:54 Kroghs-iMac.local java[557]: spawn_via_launchd() failed, errno=1 label=[0x0-0x9a09a].com.apple.ImageCaptureExtension2 path=/System/Library/Image Capture/Support/Image Capture Extension.app/Contents/MacOS/Image Capture Extension flags=0
Mar 4 16:57:54 --- last message repeated 1 time ---
Mar 4 16:57:54 Kroghs-iMac.local java[557]: ERROR: [ICCommandCenter launchAgent] - Failed to launch agent[1], status: -10810, url: 'file://localhost/System/Library/Image%20Capture/Support/Image%20Capture%20Exte nsion.app/'
Mar 4 16:57:54 Kroghs-iMac.local java[557]:
***** Failed to launch Image Capture Extension.
Mar 4 16:57:55 Kroghs-iMac.local java[557]: Printing failed because PMSessionBeginCGDocumentNoDialog() returned -108.
I've removed the Adobe plug-ins from /Library/Plug-Ins
Print->Save to PDF works from Safari when I am on a regular webpage.
Print->Save to PDF works from Pages
Help! I want to make Wordles for the teachers at my kids school for Teacher Appreciation Week.YES!!!!!!!
I was pulling my hair out last night over this. I noticed the Find function was not working properly. I KNEW there was something in the PDF and Preview was not showing it. I spent 2 hours trying to find someone with a similar Find function problem, but could not find much. Also, it could not copy and paste text. I KNOW it worked before because I had taken notes on this particular PDF and had copy and pasted whole paragraphs for myself into Pages. Which is what got me searching online tonight.
I re-downloaded the same PDF. When first opened in Preview, the Find and copy/paste functions worked. Same thing in Acrobat reader and Acrobat Pro. After confirming this, I re-opened it in Preview, highlighted some text and closed. It asked to Save Changes and I did. I immediately re-opened it, and guess what? Find no longer works and neither does copy/paste. Just to be sure, I tried re-opening in Acrobat reader and Pro; same thing. No copy/paste, corrupted Find feature. Well, copy/paste sort of functions, its just that it pastes a square with an alien head in it that says "Private Use 100000 Plane 16".
And finally, on some PDFs that have not even been saved in Preview, the Find function is not working properly also. It happened on the re-downloaded PDF I just talked about. It finds many instances of the word, bit the left and right arrows next to "Found on X# Pages are greyed out and do not move through the document. Once I go to the left pane that displays page thumbnails and click on a few different ones, THEN it starts working.
So yes, Apple, Preview is corrupting PDF files upon save, AND it is not working properly on other files. Please fix this. PLEASE.
And my specs are the same as Gary; iMac 27 inch Late 2009, Yosemite 10.10.1. Is ANYONE else having this issue with a different Mac? -
I have a station that will not display a particular java applet.
It has had 1.4, then 6.0 and when attempting to click on the applet of a calendar, a box pops up, then waits a second, then shows a red x.
So I uninstalled all Java, rebooted, and installed 5.0.12 etc.
It still does it and if you hit cancel, it puts undefined in the box where the date should belong on the form.
I turned on through the console the logging and this is what appears if I look at the calendar after looking at a working java applet off of Sun's webpage. I only cut and pasted what appeared after I typed the address into the address bar and entered through it.
(ok. starting below...)
basic: Stopping applet ...
basic: Finding information ...
basic: Releasing classloader: sun.plugin.ClassLoaderInfo@1a082e2, refcount=0
basic: Caching classloader: sun.plugin.ClassLoaderInfo@1a082e2
basic: Current classloader cache size: 1
basic: Done ...
basic: Joining applet thread ...
basic: Destroying applet ...
basic: Disposing applet ...
basic: Joined applet thread ...
basic: Unregistered modality listener
basic: Quiting applet ...
(ok thats it)I think any version below version 1.6 doesn't have
javax.swingThat's 1.1.6, not 1.6 ;) -
This is a modified version of a tutorial I've been working with. Code for Main.java:
import javax.swing.*;
public class Main {
* @param args the command line arguments
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame f = new JFrame("Swing Paint Demo");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(300,300);
f.setVisible(true);
Problem is that when I try to load the applet into an html file:
<html>
<APPLET code="Main.class"></APPLET>
</html>
It doesn't load.
The file compiles and executes as a stand alone .jar, but when I try to run it as an applet it won't work.
I know I'm probably missing an easy step. I have already checked my IE7 settings and java is enabled. I have no problem with any other java applets, just the ones I make. haha. Thank you ahead of time.I did some research, and got a new tutorial because the old one was inappropriate like you pointed out previously. This one I copy pasted into my editor, it compiled fine. I run it through my browser and it doesn't work still. Same issue, coincidentally, what do you make of it?import javax.swing.JApplet;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
//Since we're adding a Swing component, we now need to
//extend JApplet. We need to be careful to access
//components only on the event-dispatching thread.
public class Main extends JApplet {
JTextField field;
public void init() {
//Execute a job on the event-dispatching thread:
//creating this applet's GUI.
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGUI();
} catch (Exception e) {
System.err.println("createGUI didn't successfully complete");
addItem(false, "initializing... ");
private void createGUI() {
//Create the text field and make it uneditable.
field = new JTextField();
field.setEditable(false);
//Set the layout manager so that the text field will be
//as wide as possible.
setLayout(new java.awt.GridLayout(1,0));
//Add the text field to the applet.
add(field);
public void start() {
addItem(false, "starting... ");
public void stop() {
addItem(false, "stopping... ");
public void destroy() {
addItem(false, "preparing for unloading...");
cleanUp();
private void cleanUp() {
//Execute a job on the event-dispatching thread:
//taking the text field out of this applet.
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
remove(field);
} catch (Exception e) {
System.err.println("cleanUp didn't successfully complete");
field = null;
private void addItem(boolean alreadyInEDT, String newWord) {
if (alreadyInEDT) {
addItem(newWord);
} else {
final String word = newWord;
//Execute a job on the event-dispatching thread:
//invoking addItem(newWord).
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
addItem(word);
} catch (Exception e) {
System.err.println("addItem didn't successfully complete");
//Invoke this method ONLY from the event-dispatching thread.
private void addItem(String newWord) {
String t = field.getText();
System.out.println(newWord);
field.setText(t + newWord);
} -
Need help with Java applet, might need NetBeans URL
I posted the below question. It was never answered, only I was told to post to the NetBeans help forum. Yet I don't see any such forum on this site. Can someone tell me where the NetBeans help forum is located (URL).
Here is my original question:
I have some Java source code from a book that I want to compile. The name of the file is HashTest.java. In order to compile and run this Java program I created a project in the NetBeans IDE named javaapplication16, and I created a class named HashTest. Once the project was created, I cut and pasted the below source code into my java file that was default created for HashTest.java.
Now I can compile and build the project with no errors, but when I try and run it, I get a dialog box that says the following below (Ignore the [...])
[..................Dialog Box......................................]
Hash Test class wasn't found in JavaApplication16 project
Select the main class:
<No main classes found>
[..................Dialog Box......................................]
Does anyone know what the problem is here? Why won't the project run?
// Here is the source code: *****************************************************************************************************
import java.applet.*;
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.util.*;
public class HashTest extends Applet implements ItemListener
// public static void main(String[] args) {
// Hashtable to add tile images
private Hashtable imageTable;
// a Choice of the various tile images
private Choice selections;
// assume tiles will have the same width and height; this represents
// both a tile's width and height
private int imageSize;
// filename description of our images
private final String[] filenames = { "cement.gif", "dirt.gif", "grass.gif",
"pebbles.gif", "stone.gif", "water.gif" };
// initializes the Applet
public void init()
int n = filenames.length;
// create a new Hashtable with n members
imageTable = new Hashtable(n);
// create the Choice
selections = new Choice();
// create a Panel to add our choice at the bottom of the window
Panel p = new Panel();
p.add(selections, BorderLayout.SOUTH);
p.setBackground(Color.RED);
// add the Choice to the applet and register the ItemListener
setLayout(new BorderLayout());
add(p, BorderLayout.SOUTH);
selections.addItemListener(this);
// allocate memory for the images and load 'em in
for(int i = 0; i < n; i++)
Image img = getImage(getCodeBase(), filenames);
while(img.getWidth(this) < 0);
// add the image to the Hashtable and the Choice
imageTable.put(filenames[i], img);
selections.add(filenames[i]);
// set the imageSize field
if(i == 0)
imageSize = img.getWidth(this);
} // init
// tiles the currently selected tile image within the Applet
public void paint(Graphics g)
// cast the sent Graphics context to get a usable Graphics2D object
Graphics2D g2d = (Graphics2D)g;
// save the Applet's width and height
int width = getSize().width;
int height = getSize().height;
// create an AffineTransform to place tile images
AffineTransform at = new AffineTransform();
// get the currently selected tile image
Image currImage = (Image)imageTable.get(selections.getSelectedItem());
// tile the image throughout the Applet
int y = 0;
while(y < height)
int x = 0;
while(x < width)
at.setToTranslation(x, y);
// draw the image
g2d.drawImage(currImage, at, this);
x += imageSize;
y += imageSize;
} // paint
// called when the tile image Choice is changed
public void itemStateChanged(ItemEvent e)
// our drop box has changed-- redraw the scene
repaint();
} // HashTestBigDaddyLoveHandles wrote:
h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
That wasn't attention-grabbing enough apparantly. Let's try it again.
h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
h1. {color:red}MULTIPOST: [http://forums.sun.com/thread.jspa?threadID=5358840&messageID=10564025]{color}
Maybe you are looking for
-
Macbook pro mid 2009 - beach ball spinning after one hour
Hi, I have a problem with my macbook pro mid 2009. After one hour of working the beach ball starts spinning and you cannot work anylonger. You have to force shut down the macbook pro and restart it. The same problem appears once I wanna do a back-up
-
When i open itunes, you just see the outline and then it says an error occured and closes. Have tried uninstalling and reinstalling about 20 times. Whats gooooing ooooooonnnnnnnnnn?
-
I have update to FCP7 and now I can't export as FLV
Hi, First sorry for my bad English, this is not my mother tongue. My problem is the next, In my PowerMac with FCP6, Flash8 Video Encoder, Flash8 and Quicktime Pro 7, I use to export without problem from FCP as FLV by File / using Quicktime conversion
-
Is there a phone number to actually speak to a human at Verizon?
is there a phone number to actually speak to a human at Verizon?
-
Loading settings from xml and applying
Hi, I've got an xml where im writing certain settings of a application. This is what the xml looks like; <?xml version="1.0" encoding="UTF-8" ?> - <PTMViewProfile> - <viewProfile> <testSequences /> <projectName tag="default" /> - <tsFrames> <ts