Closed
Bug 393559
Opened 17 years ago
Closed 17 years ago
cannot set custom cursor on components in java applets
Categories
(Plugins Graveyard :: Java (Java Embedding Plugin), defect)
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: rkunkel, Assigned: smichaud)
Details
Attachments
(1 file)
965 bytes,
image/x-png
|
Details |
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) Build Identifier: Mozilla/5.0 (Macintosh;U;PPC Mac OS X Setting custom cursors on swing components in java applets when using FireFox on the MAC does not work. It works OK with Safari on the MAC and with FireFox on Windows. There is a mechanism in java whereby it is possible to change the cursor when it is moved over a component by using the setCursor() method. There are several preconfigured cusrors(normal, cross-hair, hand) to choose from. But it is also possible to create a custom one with an image file. Code that successfully does this with Safari on the MAC and FireFox on Windows does not work with FireFox on the MAC. Namely, the cursor never changes. Interestingly, it is possible to change the cursor to one of the predefined ones, just not a custom cursor. Here is some sample code that will exhibit the problem: package apptest; import javax.swing.*; import java.awt.*; public class MyApplet extends JApplet { private JPanel mainPanel; public void init() { mainPanel = new JPanel(new GridLayout(4,2,15,15)); ImageIcon ic = null; try { ic = new ImageIcon(this.getClass().getClassLoader().getResource("apptest/pencil.png")); } catch(Exception ex) { ex.printStackTrace(); } Toolkit theToolkit = Toolkit.getDefaultToolkit(); Dimension dim = theToolkit.getBestCursorSize(32, 32); Point ptHotSpot = new Point(5, (int)((dim.getHeight()-5))); Cursor cursor = theToolkit.createCustomCursor (ic.getImage(), ptHotSpot, "custom"); for(int i = 0; i < 2; i++) { JButton b = new JButton(String.valueOf(i + 1)); b.setCursor(cursor); mainPanel.add(b); } getContentPane().add(mainPanel); } } The following html can be used to load the applet if the applet is placed in a subdirectory called apptest, compiled and placed in a jar file called apptest.jar <html> <embed width="800" height="548" scriptable="true" pluginspage="http://java.sun.com/products/plugin/index.html#download" mayscript="true" archive="apptest.jar" type="application/x-java-applet;version=1.5" code="apptest.MyApplet.class" java_codebase="." id="applet_test"/> </embed> </html> The file referenced in the code as "apptest/pencil.png" refers in my test case to a small png file that looks like a pencil. Any small image file can be used for this test. Just change the source code appropriately and include it in the .jar file. When running the applet, after it has been given focus, say by clicking on one of the two buttons, the cursor should change when over the button and go back to the default when not on the button. With FireFox on the MAC it never changes. With Safarit it does. Reproducible: Always Steps to Reproduce: 1.Compile and run the test code 2.Click on a button and move the cursor around on and off the buttons 3.The cursor does not change. The cursor change change to match the image file as one mouses over the buttons.
Updated•17 years ago
|
Assignee: nobody → smichaud
Component: General → Java Embedding Plugin
Product: Firefox → Core
QA Contact: general → java.jep
Assignee | ||
Comment 1•17 years ago
|
||
> The file referenced in the code as "apptest/pencil.png" refers in my
> test case to a small png file that looks like a pencil. Any small
> image file can be used for this test.
I'll bet that there are certain restrictions on this file
... especially on its size. Please attach the "pencil.png" that you
used in your tests to this bug (using "add an attachment"). I'll use
it in my tests.
Reporter | ||
Comment 2•17 years ago
|
||
As requested by smichaud@pobox.com the pencil.png file has been added as an attachment.
Assignee | ||
Comment 3•17 years ago
|
||
I'm only able to reproduce your report (or something like it) on OS X 10.3.9. But even there your problem only happens with certain values for the custom cursor's "hotspot". And on OS X 10.4.10 my results are very different from yours. On OS X 10.3.9 I found that your pencil.png custom cursor works in Safari and fails to appear (though the applet does load) in Firefox 2.0.0.6 ... but only so long as the cursor's hotspot contains values higher than '15'. If I change your code to specify a hotspot whose x and y values are both '15' or less, your custom cursor also works in Firefox (though sometimes I first have to click on the applet to give it the keyboard focus). On OS X 10.4.10, I found that specifying a hotspot with x or y values higher than '23' (as your current code does) causes your applet to fail to load (with an "invalid hotSpot" Java error) when using Java 5.0 (which is the default Java version). This happens in both Firefox 2.0.0.6 and Safari. With Java 1.4.2 (on OS X 10.4.10) I get different results on my PPC Mac and my Intel Mac! On my PPC Mac my results are pretty close to what I see on OS X 10.3.9: If the cursor's hotspot contains values higher than '23', your applet loads in Firefox, but the custom cursor doesn't appear. But in Safari your custom cursor does appear (when you mouse over one of the applet's buttons). On my Intel Mac your custom cursor "works" in both Safari and Firefox, even if its hot spot contains values higher than '23'. But since the problem is so easy to work around (by controlling what values you specify for the custom cursor's hotspot), I will probably not be working on this anytime soon.
Status: UNCONFIRMED → RESOLVED
Closed: 17 years ago
Resolution: --- → WONTFIX
Assignee | ||
Comment 4•17 years ago
|
||
[Oops. I dropped the following from comment #3. It should be the second to last paragraph.] Where the behavior of the custom cursor differs between Safari and Mozilla.org browsers, it's possible that this is due to some kind of Apple bug that the Java Embedding Plugin has failed to work around.
Component: Java Embedding Plugin → Java (Java Embedding Plugin)
Product: Core → Plugins
Updated•8 years ago
|
Product: Plugins → Plugins Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•