Al Murphy Al Murphy

Greenhorn
+ Follow
since Feb 03, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Al Murphy Al Murphy

Hi,

Wondering can you help me please. I've written a small applet that uses a thread to display small pictures one after another. The images are small and stay on screen for about 3 seconds. It then abruptly disppears to be replaced by the next image.
It's pretty simple stuff really. Nothing terribly sophisticated.


For example to load up an image:

Image img = getImage(getcodeBase(), "1.jpg");
etc

The thread stuff is pretty straighforward too:

public void run()
{
Thread myThread = Thread.currentThread();
while(imageThread = mythread)
{
repaint();
image += image;// increment image
}

} // end run()


The problem is though I want to *fade* each image in and out to be replace by the next image.
However I don't know how to do this exactly. Can anyone out there help me please? Any suggestions/comments/code-samples would be most appreciative.

Cheers,
Al.
16 years ago
Folks,
I'm calling a swing-based applet using the following code. Unfortunately it doesn't appear to work when I replace "a.class" with "a.jar".
Is there any way you can invoke a jared applet using the <OBJECT> tag. I would greatly appreciate your comments...
--------------------------------------------------------------------------
CODE AS FOLLOWS:
<OBJECT
classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase = "http://java.sun.com/update/1.4.2/jinstall-1_4-windows-
i586.cab#Version=1,4,0,0"
WIDTH = 150 HEIGHT = 300 >
<PARAM NAME = CODE VALUE = a.class >
<PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.4">
<PARAM NAME = "scriptable" VALUE = "false">
</OBJECT>
16 years ago
Joe,
Yes I see now the line:
boolean pasteAvailable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).isDataFlavorSupported(DataFlavor.stringFlavor);

tries to access the default clipboard - which according to yourself is not allowed. Problems is though what alternative can I use with an applet. does swing comes with a clipboard??
Al.
16 years ago
Folks,
Interesting one here. I've implemented a right mouse click popup menu thingy that I found somewhere (code included below).
It works perfectly using the appletviewer but when I view it in IE6.0 & NN7.1 I get the following error message "java.security.AccessControlException: access denied (java.awt.AWTPermission accessClipboard)" Full error message under this.
I would greatly appreciate your comemnts and suggestions on this...
Thanks,
Al
****** ERROR MESSAGE AS FOLLOWS *******
Java(TM) Plug-in: Version 1.4.2_03
Using JRE version 1.4.2_03 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\amurphy
Proxy Configuration: Browser Proxy Configuration
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------
java.security.AccessControlException: access denied (java.awt.AWTPermission accessClipboard)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkSystemClipboardAccess(Unknown Source)
at sun.awt.windows.WToolkit.getSystemClipboard(Unknown Source)
at PopupMenuMouseListener.mouseClicked(PopupMenuMouseListener.java:142)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.security.AccessControlException: access denied (java.awt.AWTPermission accessClipboard)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkSystemClipboardAccess(Unknown Source)
at sun.awt.windows.WToolkit.getSystemClipboard(Unknown Source)
at PopupMenuMouseListener.mouseClicked(PopupMenuMouseListener.java:142)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
****** END ERROR MESSAGE ******
CODE AS FOLLOWS:
public class Widgets extends JApplet
{
int appletWidth, appletHeight;
JPanel P1;
JTextField jtfInput;
JTextArea jtaOutput;
PopupMenuMouseListener pmml = new PopupMenuMouseListener();

public void init()
{
// Physical dimensions of the applet
Dimension d = getSize();
appletWidth = d.width;
appletHeight = d.height;
// Colors of the applet
getContentPane().setBackground(Color.black);
getContentPane().setForeground(Color.white);
getContentPane().setLayout(new BorderLayout());

P1 = new JPanel();
jtfInput = new JTextField(10);
jtfInput.addMouseListener(pmml);
jtaOutput = new JTextArea(10, 10);
jtaOutput.addMouseListener(pmml);
P1.add(jtfInput);
P1.add(jtaOutput);
getContentPane().add(P1, BorderLayout.CENTER);

} // end init()
**** END CODE ******
**** POPUP CODE ****

import java.awt.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import javax.swing.*;
//import javax.swing.event.*;
import javax.swing.text.*;
public class PopupMenuMouseListener extends MouseAdapter
{
private JPopupMenu popup = new JPopupMenu();
private JMenuItem undoItem, cutItem, copyItem, pasteItem, deleteItem, selectAllItem;
private JTextComponent textComponent;
String savedstring="";
String lastactionselected="";

public PopupMenuMouseListener()
{
Action action = new AbstractAction("Undo")
{
public void actionPerformed(ActionEvent ae)
{
if(lastactionselected.compareTo("")!=0)
{
textComponent.setText("");
textComponent.replaceSelection(savedstring);
}
}
};
undoItem = popup.add(action);
undoItem.setMnemonic('t');
popup.addSeparator();
action = new AbstractAction("Cut")
{
public void actionPerformed(ActionEvent ae)
{
lastactionselected="c";
savedstring=textComponent.getText();
textComponent.cut();
}
};
cutItem = popup.add(action);
cutItem.setMnemonic('t');
action = new AbstractAction("Copy")
{
public void actionPerformed(ActionEvent ae)
{
lastactionselected="";
textComponent.copy();
}
};
copyItem = popup.add(action);
copyItem.setMnemonic('c');
action = new AbstractAction("Paste")
{
public void actionPerformed(ActionEvent ae)
{
lastactionselected="p";
savedstring=textComponent.getText();
System.out.println("in paste code savedstring is: "+savedstring);
textComponent.paste();
}
};
pasteItem = popup.add(action);
pasteItem.setMnemonic('p');
action = new AbstractAction("Delete")
{
public void actionPerformed(ActionEvent ae)
{
lastactionselected="d";
savedstring=textComponent.getText();
textComponent.replaceSelection("");
}
};
deleteItem = popup.add(action);
deleteItem.setMnemonic('d');
popup.addSeparator();
action = new AbstractAction("Select All")
{
public void actionPerformed(ActionEvent ae)
{
lastactionselected="s";
savedstring=textComponent.getText();
textComponent.selectAll();
}
};
selectAllItem = popup.add(action);
selectAllItem.setMnemonic('a');
}
public void mouseClicked(MouseEvent e)
{
//if (e.getModifiers()==InputEvent.BUTTON3_MASK)
if(SwingUtilities.isRightMouseButton(e))
{
if (!(e.getSource() instanceof JTextComponent))
{
return;
}
textComponent = (JTextComponent)e.getSource();
// 1.3 version
//textComponent.requestFocus();
// 1.4 preferred method
textComponent.requestFocus();
//textComponent.requestDefaultFocus();
//textComponent.requestFocusInWindow();

boolean enabled = textComponent.isEnabled();
boolean editable = textComponent.isEditable();
boolean nonempty = !(textComponent.getText()==null || textComponent.getText().equals(""));
boolean marked = textComponent.getSelectedText()!=null;
boolean pasteAvailable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).isDataFlavorSupported(DataFlavor.stringFlavor);
undoItem.setEnabled(enabled && editable);
cutItem.setEnabled(enabled && editable && marked);
copyItem.setEnabled(enabled && marked);
pasteItem.setEnabled(enabled && editable && pasteAvailable);
deleteItem.setEnabled(enabled && editable && marked);
selectAllItem.setEnabled(enabled && nonempty);
popup.show(e.getComponent(),e.getX(), e.getY());
}
}
} // end PopupMenuMouseListener

*** END POPUP CODE *****
16 years ago
CONCLUSION:
So after all that (thanks Joe) I have the answer. It's the bloody <applet> tag that does not work with it on swing based applets.
So do the folowing folks:
The <EMBED> tag is interpreted by Mozilla, for IE you should encapsulate your Swing Applet in the <OBJECT> tag, as shown in the following fragment:
<OBJECT name = "plugin-install"
classid = "clsid:CAFEEFAC-0014-0001-0004-ABCDEFFEDCBA"
codebase = "http://java.sun.com/products/plugin/autodl/jinstall-1_4_1_04-windows-i586.cab#Version=1,4,1,40";
WIDTH = 300 HEIGHT = 100 >
<PARAM NAME = CODEBASE VALUE = "http://labdo:8080/DevBasicApplet/applets/">;
<PARAM NAME = CODE VALUE = "tester.unit.applets/TesterJAppletIE.class" >
<PARAM NAME = "type" VALUE = "application/x-java-applet;jpi-version=1.4.1_04">
<PARAM NAME = "scriptable" VALUE = "false">
<COMMENT>
</COMMENT>
</OBJECT>
16 years ago
Joe,
I see now that it works with your applet that you put up (the one that uses the embed tag) but it does not work with the applet tag (like the one up on the sun site).
Weird no?
Al.
16 years ago
Joe,
Here's an update. I installed Ad-Aware 6.0. It scanned and found 1 or 2 wee things. Nothing serious though. I removed them and checked the applet. It was not working. I rebooted and checked the applet. It was not working.
On a whim I surfed on over to the Micorsoft site. I looked at the recent patches for XP & IE. I installed some and rebooted. The applet worked.
This morning when I came in I installed some more. Rebooted and the applet worked for a while. It then stopped working after about 1 hour. All I was doing was surfing. I made not changes to the system.
It appears as if the patches to various things made the plug-in work - for a while but then it stopped. I don't know why though? No error messages are thrown. It's like the plug-in does not kick in. (Meanwhile it's still working in NN). I wonder does the plug-in output to any files I can have a look at - perhaps I can get more inro there...
Al.
16 years ago
Joe,
Thanks I'l try that. I have the Google pop-up blocker installed .That couldn;t be it could it? I'll install the what you recommended and find out...
Al.
The investigator
16 years ago
Joe,
I've uninstalled what I could and reinstalled and it's still not working properly. It's working in NN 7.1 though. I'm totally confused!
Al.
The totally confused one.
</end rant>
16 years ago
Joe,

It's stopped working. I don't know why. It was working this morning when I came in but now it has stopped. I swear I did not make any changes to any properties files.
This is weird. I am going to uninstall the Java plug-in and reinstall.
Al.
The confused.
16 years ago
Joe,
It's working! I can in to work this morning and found that I could view swing based applets.
Perhaps it was because of the full shut down that I did last night instead of the usual restart.
But I also notice that my company changed their proxy server (during a scheduled network upgrade last night). Although I can't think why this would effect a plug-in...
Anyway Joe thanks for sticking with this one and making those suggestions/commetns etc
Much appreciated.
BR,
Al.
16 years ago
Joe,
You were right. After typing "jview" on the command line I get "Microsoft <R> Command-Line Loader for Java. Version 5.00.3810"
I am not receiving any errors on the Java console as it does not appear (I take it you are referring to the View -> Java Console option in the browser menu bar. This does not appear. Neither are there any error when I look at the Java Plug-in in Control Panel.
When I click on the link you provided in IE I get taken to a mainly grey applet box with just 1 pushbutton on the top. I click on it and a pop-up appears. It won't close. Nothing installed per se.
I then went back to the swing based applet at Sun and tried it but it just renders a grey box.
It's like the Java plug-in is installed on my system but is not kicking in. I notice that I have .NET Framework v1.1 installed on this box. Should I remove this or can I just make MS's VM just go away or switch off? Where is the control panel for the MS .NET Framework???
Al.
There is a MS VM on your computer. Type "jview" at a command line and you'll see. I believe you have gone through all the steps to disable it in IE and enable the Sun VM and I don't know what else is wrong. Are you still getting an error in the java console?
Let's try something far out. If one uses the OBJECT tag rather than the APPLET tag in their HTML, they can tell the applet to install the Java Plug-In. Point your browser at this applet and let me know how it goes.
16 years ago
Joe,
"Show console" in "Basic" tab ENABLED

"About" tab in plug-in control = Java(TM) plug-in 1.4.2_03
I also did a "java -version" command at the command line. Once again I got 1.4.2_03
I think this is the most recent version? Would you agree?
Anyway I still can't view the japplet at Sun. Bummer!

I reckon like you that a MS virtual machine is on my box? But how do I get info on it and disable it completely?

Al.
The very confused.
16 years ago
Joe,
As you mentioned I now have the following in IE:
Java(Sun)
"Use Java 2 v1.4.2_03 for <applet> requires restart" ENABLED
Microsoft VM
"Java console enabled (requires restart)" DISABLED
"Java logging enabled" DISABLED
"JIT compiler for virtual machine enabled (requires reatart)" DISABLED
I rebooted but I still can;t view the japplet at Sun. I also notice that when I do Tools -> Sun Java Console nothing happens. Wasn;t this meant to do something?
I'm very confused Joe.
Al.
The confused.
16 years ago
Joe,
Interesting. I checked Control Panel where you specified and under:
"Java Plug-In will be used as the default Java Runtime in the following browser(s):"
I have both checked the options:
Microsoft Internet Explorer and
Netscape 6 or later
But prey tell what's this I hear you say about the Java VM kicking in? Can I disable the VM? Any ideas Joe? I'm really confused with this problem. It was working previously...
Confused,
Al
16 years ago