Michelle Kyamo

Greenhorn
+ Follow
since Aug 25, 2009
Merit badge: grant badges
For More
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 Michelle Kyamo

Ulf Dittmer wrote:Comparing strings using the "==" operator ...



Hey, I didn't write it!



If the jar file was signed, no security exception would be happening in the first place.



My code wasn't signed, but I thought it was possible that the jar file which I am just using and didn't write may be. I am not sure how to tell.

Thank you again for your help, I will try that.
14 years ago

Ulf Dittmer wrote:

Since the library is open source you could check out why it's performing this operation, and maybe patch that out; if you're just wanting to use some of its GUI features, then I agree there should be a way to do that without resorting to potentially forbidden reflection features.



Thank you for your help.


The reason I am using that jar file is so that I can use GroupLayout even if the users java is version 5 instead of version 6 (as on many Macs). I have now looked at the source of it, and found the problem seems to be in this method (which I don't call directly, but I guess is called in order to set up the layout):



It calls java.lang.Class.getDeclaredMethod which throws the SecurityException

getDeclaredMethod

public Method getDeclaredMethod(String name,
Class<?>... parameterTypes)
throws NoSuchMethodException,
SecurityException

Returns a Method object that reflects the specified declared method of the class or interface represented by this Class object. The name parameter is a String that specifies the simple name of the desired method, and the parameterTypes parameter is an array of Class objects that identify the method's formal parameter types, in declared order. If more than one method with the same parameter types is declared in a class, and one of these methods has a return type that is more specific than any of the others, that method is returned; otherwise one of the methods is chosen arbitrarily. If the name is "<init>"or "<clinit>" a NoSuchMethodException is raised.

Parameters:
name - the name of the method
parameterTypes - the parameter array
Returns:
the Method object for the method of this class matching the specified name and parameters
Throws:
NoSuchMethodException - if a matching method is not found.
NullPointerException - if name is null
SecurityException - If a security manager, s, is present and any of the following conditions is met:

* invocation of s.checkMemberAccess(this, Member.DECLARED) denies access to the declared method
* the caller's class loader is not the same as or an ancestor of the class loader for the current class and invocation of s.checkPackageAccess() denies access to the package of this class

Since:
JDK1.1



When you said I may be able to "patch that out", do you mean change the code in the jar file? I could maybe try deleting this portion since I can see there is another "if" further down that deals with "Aqua" again, but I don't really know enough about it to know if this might break something else. Also, if I change the code I have to make the jar again on my own, which would get rid of any signing they may have put on it. Will that cause another security problem?

14 years ago
My applet depends on a jar file. (this one: https://swing-layout.dev.java.net/servlets/ProjectDocumentList?folderID=11880&expandFolder=11880&folderID=0 ) It runs fine on my computer and at least two others. On another computer, it will not run. Here is the error message.

I guess it seems to be not allowed to look at the methods that exist inside the jar file?

I don't understand why there are security problems or extra permissions needed, since the applet does not try to access or affect anything on the users computer or anything fishy like that.

How can I fix this? Do I need to sign my applet? I do not understand how to do that. If I do sign it, doesn't that mean that users will get a security popup asking them to trust me that the code isn't malicious? For my application, such a popup is not acceptable, and shouldn't be needed since this applet doesn't try to affect anything outside itself.

Thanks for any help.

14 years ago

Ulf Dittmer wrote:That class can be found at https://swing-layout.dev.java.net/servlets/ProjectDocumentList?folderID=11880&expandFolder=11880&folderID=0.

As an aside, Java 6 is available on Intel Macs running OS X 10.6 (a.k.a Snow Leopard), but there are still many OS X users who don't have that, so it seems wise not to assume that Java 6 is available on OS X.



Thank you!

Unfortunately it did require changing a bunch of stuff like "addComponent" to "add", etc. But this was accomplished with a number of find/replace, so obviously not as much work as relayouting the whole thing. Thanks.
14 years ago
I have a bunch of applets I wrote, and the layouts are done using GroupLayout. However, they need to work on Macs as well (Mac java is only 1.5) and I just realized 1.5 doesn't have GroupLayout. Is there any way I can get it to work with 1.5 or am I stuck having to redo all of the layouts (which will take a long time)?

Googling reveals people talking about something "org.jdesktop.layout.GroupLayout" to accomplish this, but "import org.jdesktop.layout.GroupLayout;" cannot be resolved. It may be something within Netbeans(which I am not using)?

Thanks in advance for any help.
14 years ago

Rob Camick wrote:

I wish that JButton had a method pressButton() that I could call from within the program





Oh thank you so much, I guess I missed that when I was scanning the methods to see if there was one that might press it!
14 years ago
My applet will have multiple buttons. When some of the buttons (B,C,&D) are pressed by the user, I would like the code that is executed then to include automatically pressing another button (button A). I wish that JButton had a method pressButton() that I could call from within the program. Of course I could just copy and paste all the code that happens when button A is pressed into buttons B C and D, but I was wondering if there is a less messy way to do this.
14 years ago
I have an applet that works fine on all the Windows machines I have tested it on, in both IE and Firefox but does not load on Macs. They say they see a red X instead of the applet.

What are possible reasons for this? What can I try that might fix the problem? I am confused because I thought Java should run the same way no matter what the underlying operating system.

The only clue I have found so far is that the Macs seem to have Java 1.5 and Windows have Java 1.6. But I compiled it with version 1.5 (in eclipse: Run > Run Configurations > JRE> Execution Environment > J2SE 1.5 (Java)) and it still doesn't work on Macs.
14 years ago

Michelle Kyamo wrote:It seems I can only make the attributes in StyleConstants work, not anything in TextAttribute.

I reduced the font size of the superscript a little, which makes the problem a little less (the underlines are offset still, but less so).



Does anyone know how to make the TextAttribute work so I can use UNDERLINE_LOW_ONE_PIXEL?
14 years ago
It seems I can only make the attributes in StyleConstants work, not anything in TextAttribute.

I reduced the font size of the superscript a little, which makes the problem a little less (the underlines are offset still, but less so).
14 years ago
My applet works fine when I test it on my pc (through Eclipse).

When I put it on a webpage though, it does not work. The webpage shows a blank screen at first, but through reloading the page and/or clicking, part of it shows. Once I get the slider to show and drag it around, some of the parts of the applet that change do show, but some display weird and some not at all.

You can look at the problem here (Edit: link removed because error is fixed).

ETA: I fixed the problem. It wasn't finding one of my images properly. I'm still surprised that something like that would cause such havoc with the rest of the applet though. Why wouldn't it display everything except the broken picture?
14 years ago

Darryl Burke wrote:If all else fails, you could try applying the UNDERLINE_LOW_ONE_PIXEL / UNDERLINE_LOW_TWO_PIXEL attribute to the superscripted text.



Trying to do this but it doesn't seem to be working (I mean I can't seem to apply the attribute at all, not that it doesn't fix my problem).

doc2 = textpane2.getStyledDocument();
superscript = doc2.addStyle("superscript",null);
StyleConstants.setSuperscript(superscript,true);
undersuper = doc2.addStyle("undersuper", superscript);
undersuper.addAttribute(TextAttribute.UNDERLINE,TextAttribute.UNDERLINE_LOW_TWO_PIXEL);

I then use undersuper in the insertString method of StyledDocument (have also tried setCharacterAttributes) and the text appears superscripted with no underline.
14 years ago

Paul Clapham wrote:I don't know but I'm going to speculate.

What you are seeing is superscripted underlined characters. (Which is something that I have seen in print.) What you want to see is underlined superscripted characters. (I haven't seen that in print but it seems like a reasonable thing to want.) Perhaps the order in which you set up the styling makes a difference? Perhaps not, that's just a guess.



Thanks for the idea, but the switching the order didn't change anything.
14 years ago
I have a StyledDocument where I want one whole line to be underlined, and a few characters in the line are also in superscript. What happens is that the underline that runs under the superscripted characters is raised compared to the underline under the regular characters. I want the underline to be continuous under the whole line. Is there a way to fix this?
14 years ago

pete stein wrote:

Michelle Kyamo wrote:Thanks, I will read that tomorrow. Does that mean it's a bad idea to be using Swing and non-Swing things in the same applet?


Yes, in general it's a bad idea, unless you have a darn good reason for doing so, and really know what you are doing and why.



OK, I have deleted the paint method altogether and am trying to redo it with everything in Swing this time. Working so far. Thanks everyone for the help.
14 years ago