JOptionPane and Applet problem
Hi folks,
I have an applet, I want to display a pop up dialog whenever the user
does something. SO i used JOptionPane:
int userIn=JOptionPane.showInternalConfirmDialog(this,"Do you wish to generate xml for each ics/ids files pair in this data set?", "information",JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
//repaint();
The dialog just doesn't show up, I tried repaint(), tried JApplet, nothing works, what am I missing? I'm pretty sure the above code gets called.
thanks
A. Are you sure this code is executing?
B. Are you sure you aren't getting an error, possibly something like
java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent
at javax.swing.JOptionPane.createInternalFrame(JOptionPane.java:1161)
at javax.swing.JOptionPane.showInternalOptionDialog(JOptionPane.java:1025)
at javax.swing.JOptionPane.showInternalConfirmDialog(JOptionPane.java:967)
at javax.swing.JOptionPane.showInternalConfirmDialog(JOptionPane.java:931)
Similar Messages
-
How do I get rid of the "Applet window" status bar on the message boxes using JOptionPane, when I use the same in an applet?
sign your applet.
-
Help on assignment, don't understand JOptionPane and showInputDialog
Hi, I am currently studying java and have problems doing my assignment. here is the assignment question. What I am looking for is pointers and hints to start on my assignment. I am not looking for the source code, rather the way to actually understand it and start writting my code
I believe this assignment wanted me to create a class Object called Zeller with the methods in it and a ZellerTester to test the Object?
I read up on the JOptionPane and the showInputDialog, but don't really quite understand it.
Do i need a constructor for the Object Zeller?
Does my assignment require me to put the showInputDialog as a method in the Zeller class? Or put it in the ZellerTester?
The isLeapYear is a method in the Object Zeller?
Here is the assignment question
Examine the method
showInputDialog() and study its function. Note the return type of this method.
Write a program on the following requirements:
1. Use the JOptionPane facility to ask the user for three positive integers,
representing the day, month and year of a date.
2. Use the Zeller�s congruence formula to find the day of the week.
3. Should include a method boolean isLeapYear(int year)
that will return true if year is a leap year, and false otherwise.
The method should check for leap years as follow:
return true if the year is divisible by 400.
return true if the year is divisible by 4 but not by 100
return false for the remaining values
Thank you.I can't seems to return the method back to the main
Not sure where has gone wrong...
here is my code
import javax.swing.*;
public class ZellerTester
public static void main(String[]args)
int day = 28;
int month = 2;
int year = 2007;
int z;
boolean isLeapYear;
String[] displayName = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
if(month==1 || month==2) {
if (isLeapYear = false)
day = day-1;
else
day = day-2;
if(month<3)
month = month + 12;
z = (1 + day + (month * 2) + (3 * (month + 1) / 5) +
year + year / 4 + year / 400 - year/ 100) % 7;
System.out.println("The day is " +displayName[z]);
public boolean isLeapYear(int year)
if (year%400 == 0)
return true;
else if((year%4 == 0) && (year%100 != 0))
return true;
else
return false;
} -
I am reading about Zhiqun's Java Card book,
and I wonder about the relationship between a package and an applet.
Am I right in saying:
1. An applet comprises one or several packages
2. A package only belongs to one applet
3. One package is one group context
Hope to get your guidance.
B.R.
RuHERefers to your assertions,
Please help me..
Case 1
I have package A. Package A contains 2 class (A1 & A2 ) and 2 package (B and C).
Then, I make 2 applet, they are applet-B (for package B) and applet-C (for package C).
When simulationi in JCWDE, applet-B and applet-C have no problem. But, in CREF, applet throw exception and status word is 6443.
Case 2
When I try to include class A1 and A2 into package B and C, so package A is empy. Surprisingly, applet-B and applet-C can run in CREF and JCWDE. I don't know, what's wrong in case 1.
Can you give me explanation or explanation about problem in above...?
Best Regards,
Wiwit -
Hi!
I am using j2sdk 1.4.0 under linux. I have been creating an applet. The screen refresh is tied to a timer. However, the screen refresh gets very slow after 2 - 5 seconds after the applet has been started. If I move mouse in applets window, the refresh gets fast during that time.
The applet code is very simple: timer calls repaint method of the applet and applet's paint method just draws new picture to the screen using drawImage.
Anyone run into same problem? What could be wrong?
Thanks
Sammyok but whats the problem the fast refreshing??
if so then u have two options:
1)double buffering
2)if u dont need the re-paint let the java do it for u dont overide it
denny -
I'm trying to use Sax in an applet to read an xml file. My application works fine, but when I convert it to an applet, I get errors.
Does anybody know where I can get info and examples using Xml, Sax, and Applets? Any info would be helpful. Thanks.Probably nothing to do with XML. You use it in an applet precisely as you would use it in an application. You are probably running into one of the usual applet problems. Of course, this is all guesswork without any idea of what errors you are actually having.
-
Security, SocketPermission and applets
Hi, Im trying to read an url from an applet but I dont know how to set the permissions from the applet.
here is my code:
import java.applet.*;
import java.net.*;
import java.io.*;
import java.awt.*;
public class TestApplet extends Applet{
private String line;
public void init () {
try {
URL url = new URL(
"http://www.yahoo.com");
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
line = in.readLine();
in.close();
}catch (Exception e){
e.printStackTrace();
public void paint (Graphics g) {
g.drawString (line, 20, 40);
And the problems are here:
java.security.AccessControlException: access denied (java.net.SocketPermission w
ww.yahoo.com resolve)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:270)
at java.security.AccessController.checkPermission(AccessController.java:
401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1042)
at java.net.InetAddress.getAllByName0(InetAddress.java:937)
at java.net.InetAddress.getAllByName0(InetAddress.java:918)
at java.net.InetAddress.getAllByName(InetAddress.java:912)
at java.net.InetAddress.getByName(InetAddress.java:832)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:293)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:264)
at sun.net.www.http.HttpClient.New(HttpClient.java:336)
at sun.net.www.http.HttpClient.New(HttpClient.java:317)
at sun.net.www.http.HttpClient.New(HttpClient.java:312)
Does anybosy knows how can i fix this program so it can work?
Thank youIn order to access anything in client machine u have sign ur applications.
Signing JAR Files with a Test Certificate
Here are the steps needed to sign a JAR file with a test certificate:
1. Make sure that you have a JDK 1.2 or JDK 1.3 keytool and jarsigner in your path (located in the J2SE SDK bin directory).
2. Create a new key in a new keystore as follows:
keytool -genkey -keystore myKeystore -alias myself
You will get prompted for a information about the new key, such as password, name, etc. This will create the myKeystore file on disk.
3. Then, create a self-signed test certificate as follows:
keytool -selfcert -alias myself -keystore myKeystore
This will prompt for the password. Generating the certificate takes a few minutes.
4. Check to make sure that everything is ok. To list the contents of the keystore, use the command:
keytool -list -keystore myKeystore
It should list something like:
Keystore type: jks
Keystore provider: SUN
Your keystore contains 1 entry:
myself, Tue Jan 23 19:29:32 PST 2001, keyEntry,
Certificate fingerprint (MD5):
C2:E9:BF:F9:D3:DF:4C:8F:3C:5F:22:9E:AF:0B:42:9D
5.Finally, sign the JAR file with the test certificate as follows:
jarsigner -keystore myKeystore test.jar myself
6. Repeat this step on all of your JAR files.
Please note that a self-signed test certificate should only be used for internal testing, since it does not provide any guarantees about the identity of the user and therefore cannot be trusted. A trust-worthy certificate can be obtained from a certificate authority, such as VeriSign, and should be used when the application is put into production.
Regards
Edward.i -
I'm new programmer in java. There are somme applet that run with appletwier
but witch do not run with Internet explorer and Netscape. I'm always getting
this error : 'Class not found'. I want to know all the steps to run and applet
using Netscape or Internet explorer.
I'm french speaking. Sorry if my english is poor.
Thank's for your answers.I think you can't solve your problem.
The fact is that appletviewer supports the java classes you have installed with the sun's jdk... if you are using jdk 1.3.1, it uses the java libraries included in your installed distribution. IE virtual machine, instead, uses its own library, so you can't use in your applets classes like: swing, graphics2d, and so on...
I know that it's not a great help. Sorry!
However, if someone could tell us how to include these classes in our CABs/JARs... i think we are really happy! :-)
Ciao,
Paolo. -
Firefox & openJDK && applets problem
Latest Firefox & latest openJDK7 & icedtea-web-java7
Starting Firefox form console and open URL with java applet in console appears errors:
java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (ArchLinux build 7.u7_2.3.2-2-i686)
OpenJDK Client VM (build 23.2-b09, mixed mode)
File cannot be launched because offline-allowed tag not specified and system currently offline.
java.lang.NullPointerException
at net.sourceforge.jnlp.NetxPanel.runLoader(NetxPanel.java:154)
at sun.applet.AppletPanel.run(AppletPanel.java:379)
at java.lang.Thread.run(Thread.java:722)
java.lang.NullPointerException
at sun.applet.AppletPanel.run(AppletPanel.java:429)
at java.lang.Thread.run(Thread.java:722)
and applet won't run with error in Firefox's status bar: "start: applet not initialized"
If replace openJDK7 & icedtea-web-java7 to openJDK6 & icedtea-web still errors:
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.4) (ArchLinux-6.b24_1.11.4-1-i686)
OpenJDK Client VM (build 20.0-b12, mixed mode)
File cannot be launched because offline-allowed tag not specified and system currently offline.
java.lang.NullPointerException
at net.sourceforge.jnlp.NetxPanel.runLoader(NetxPanel.java:154)
at sun.applet.AppletPanel.run(AppletPanel.java:380)
at java.lang.Thread.run(Thread.java:679)
java.lang.NullPointerException
at sun.applet.AppletPanel.run(AppletPanel.java:430)
at java.lang.Thread.run(Thread.java:679)
With jre-7.7 from AUR everything works ok.
Whats wrong with openJDK and icedtea-web ?Try to disable hardware acceleration.
*Edit > Preferences > Advanced > General > Browsing: "Use hardware acceleration when available"
Create a new profile as a test to check if your current profile is causing the problems.
See Basic Troubleshooting: Make a new profile:
*https://support.mozilla.com/kb/Basic+Troubleshooting#w_8-make-a-new-profile
There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
If that new profile works then you can transfer some files from the old profile to that new profile (be careful not to copy corrupted files)
See:
*http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox -
JOptionPane, EventQueue & WToolkit Problem
I have a swing 1.2 application where I have a customized EventQueue which checks to see how long something proceses. If the event is too long, it turns the cursor to an hourglass and then turns it back to the default cursor when complete. The problems comes in whenever I have a JOptionPane (and JDialog for that matter).
If I'm processing a button event and I throw up a JOptionPane to ask a question, I want to continue processing the original button logic. This works fine. However, I notice I get a
sun.awt.windows.WToolkit object in my SystemEventQueue. I really need to get the component instead so I can set the hourglass. Does anyone have an idea on how to do this? TIA!First of all, thanks for taking the time to look at my problem.
Here's some answers to the previous questions.
1. The hourglass cursor is displayed until the JOptionPane or JDialog is displayed. Then the default cursor is displayed. Once a user clicks on a yes/no/cancel button, my program will do some tasks like updating and reading records. During this updating and reading process, I want to display the hourglass. Since I know I get an object back to the event queue, I can time the actions and set the cursor - well, in every case but JOptionPane & JDialog. I really hate the thought of having to code the cursor logic in every method that calls a JOptionPane/JDialog. Just goes against the grain. There has to be a better way.
2. Usually, I get component objects sent back to the event queue. However, whenever a JDialog or JOptionPane is displayed, I get a WToolkit object. I have no idea why. Anything else will send back components like the button,etc.
FYI... my event queue is very similar to the one listed in Java World Tip #87 (see link http://www.javaworld.com/javatips/jw-javatip87.html). I just modified it to use a glasspane. -
InitialContext - Applet Problem
Hi,
When i try to get InitialContext from Applet ( running from appletviewer),
i'm hitting this error. Please help me to solve this problem
Exactly this line gives the error
InitialContext ic = new InitalContext ( hEnv )
Error:
javax.naming.NoInitialContextException: Cannot Instantiate class:
weblogic.jndi.WLInitialContextFactory
-regards
Abdul Malikyou can use applet to pull data periodically from the servlet.
mj
"Anthony A." wrote:
What if you want to perform some type of 'realtime' push from the server?
Anthony
"minjiang" <[email protected]> wrote in message
news:[email protected]...
why do you have to call your ejbs in applet directly? Why not use aservlet in
between?
The overhead of downloading so many so big jar files to the client machinewill
kill/time out any broswer http session.
mj
Abdul Malik wrote:
Dear Friends,
After 5 days of struggle, somehow i was managed to access the EJB from
Applet. But very slow coz of Big Jar files ( can make it bit small by
identitfying required classes ). I dont know this is correct approach
or
not, but works ( damn slow )
What i did was
1) Installed the Latest Plugin 1.3.1
2) Downloaded HTMLConverter tool from java.sun.com and converted my
html file to use plugin.
3) inlcuded few jar files in archive tag.
The files i added in archive tag is
1) myapplet.jar ( applet classes )
2) weblogicaux.jar ( !!!!!!!!!!!! quite big jar file )
3) weblogicclass.jar ( jarred all the classes from classes\weblogicfolder
(!!!!!!!!!! so big jar file !!!!!! )
4) myejb.jar ( suppose to work with home and remote class, but notworking
( looking for container generated files). so i added my EJB.jar file.dont
know why ?????????? )
then it works.
well, i am not happy with this kind of approach. if any body haveefficient
one, please kindly post it.
Note: i tried in 1.2.2 plugin ( works )
Environment: Windows 2000 / Windows 98, Weblogic 5.1 Service pack 7
-regards
Abdul Malik
"Daniel Hoppe" <[email protected]> wrote in message
news:[email protected]...
Anthony,
why should he place j2ee.jar in the applet classpath? Shouldn't be there
actually. Your problem seems to be related to a class which is not
serializable.
Daniel
-----Ursprüngliche Nachricht-----
Von: Anthony A. [mailto:[email protected]]
Bereitgestellt: Freitag, 22. Juni 2001 18:10
Bereitgestellt in: jndi
Unterhaltung: InitialContext - Applet Problem
Betreff: Re: InitialContext - Applet Problem
As a test, try to place the j2ee.jar and weblogic.jar in your
<archive tag>.
I have this code in my applet's init() method and it fails
due to a JMS
Exception.
I'm using BEA's web server, jndi server, and app server on
the same box as
the client.
Thanks,
Anthony
code:
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://anthony01:7001");
System.out.println("creating context");
InitialContext ctx = new InitialContext(ht);
error:
JMSException: weblogic.jms.common.JMSException:
java.rmi.MarshalException:
failed to marshal public abstract weblogic.jms.client.JMSConnection
weblogic.jms.frontend.FEConnectionFactoryRemote.createConnecti
on(weblogic.rj
vm.JVMID,weblogic.jms.client.JMSCallbackRemote) throws
javax.jms.JMSException,java.rmi.RemoteException; nested exception is:
java.io.NotSerializableException: weblogic.jms.client.JMSCallback -
Question
I am not able to launch FF everytime i try to open it, it says FF has to submit a crash report,and restore yr tabs. I even tried doing that and the report was submitted too, but still FF did not start, and the problem still persists, please help me solve this issue
'''(in English)'''Hi Danny,
Per my understanding that you can't get the expect result by using the expression "=Count(Fields!TICKET_STATUS.Value=4) " to count the the TICKET_STATUS which value is 4, the result will returns the count of all the TICKET_STATUS values(206)
but not 180, right?
I have tested on my local environment and can reproduce the issue, the issue caused by you are using the count() function in the incorrect way, please modify the expression as below and have a test:
=COUNT(IIF(Fields!TICKET_STATUS.Value=4 ,1,Nothing))
or
=SUM(IIF(Fields!TICKET_STATUS=4,1,0))
If you still have any problem, please feel free to ask.
Regards,
Vicky Liu
Vicky Liu
TechNet Community Support -
BOSD, Battery issues and Heating problem after iOS 8 upgrade
i have upgraded my iPad mini to iOS 8. Ever since I upgraded to iOS 8 am facing blue screen issues and heating problem as well. This is really frustrating even the patch iOS 8.0.2 dint solve the problem. Are you guys listening our complaints. When will you fixing it.
The same thing happened to me on my 2012 Subaru Outback. I'm not sure this will help you since you have a Honda, but I'm posting this just in case.
I paired the audio on my car with my iPhone 6. However, when I turned the car off and back on again, the iPhone would not pair automatically. I had to manually connect the iPhone with the car. Turns out there are two separate bluetooth pairings on my car: one for phone which allows up to 5 devices and one for audio which allows only one device. So I did the second bluetooth pairing for the phone (had already done the audio), and that fixed it. YMMV -
I am making code to try to make a game and my problem is that my code
will not let it change the hit everytime so im getting the first guy to hit 1 then next hits 8 and so on and always repeats.
Another problem is that I would like it to attack with out me telling it how much times to attack. I am using Object oriented programming.
Here is the code for my objects:
import java.lang.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.Random;
import static java.lang.Math.*;
import java.awt.*;
import java.awt.color.*;
class rockCrab {
//Wounding formula
double sL = 70; // my Strength Level
double bP = 1; // bonus for prayer (is 1 times prayer bonus)
double aB = 0; // equipment stats
double eS = (sL * bP) + 3; // effective strength
double bD = floor(1.3 + (eS/10) + (aB/80) + ((eS*aB)/640)); // my base damage
//Attack formula
double aL = 50; // my Attack Level
double eD = 1; // enemy's Defence
double eA = aL / eD; // effective Attack
double eB = 0; // equipment bonus'
double bA = ((eA/10) * (eB/10)); // base attack
//The hit formula
double fA = random() * bA;
double fH = random() * bD;
double done = rint(fH - fA);
//health formula
double health = floor(10 + sL/10 * aL/10);
rockCrab() {
void attack() {
health = floor(10 + sL/10 * aL/10);
double done = rint(fH - fA);
fA = random() * bA;
fH = random() * bD;
done = rint(fH - fA);
System.out.println("Rockcrab hit" +done);
import java.lang.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.Random;
import static java.lang.Math.*;
import java.awt.*;
import java.awt.color.*;
class self {
//Wounding formula
double sL = 1; // my Strength Level
double bP = 1; // bonus for prayer (is 1 times prayer bonus)
double aB = 0; // equipment stats
double eS = (sL * bP) + 3; // effective strength
double bD = floor(1.3 + (eS/10) + (aB/80) + ((eS*aB)/640)); // my base damage
//Attack formula
double aL = 1; // my Attack Level
double eD = 1; // enemy's Defence
double eA = aL / eD; // effective Attack
double eB = 0; // equipment bonus'
double bA = ((eA/10) * (eB/10)); // base attack
//The hit formula
double fA = random() * bA;
double fH = random() * bD;
double done = rint(fH - fA);
//health formula
double health = floor(10 + sL/10 * aL/10);
self() {
void attack() {
health = floor(10 + sL/10 * aL/10);
fA = random() * bA;
fH = random() * bD;
done = rint(fH - fA);
System.out.println("You hit" +done);
}Here is the main code that writes what the objects do:
class fight {
public static void main(String[] args) {
self instance1 = new self();
rockCrab instance2 = new rockCrab();
instance2.health = instance2.health - instance1.done;
System.out.println("You hit: " +instance1.done);
System.out.println("rockCrabs health: " + instance2.health);
instance1.health = instance1.health - instance2.done;
System.out.println("RockCrab hit: " +instance2.done);
System.out.println("rockCrabs health: " + instance1.health);
instance2.health = instance2.health - instance1.done;
System.out.println("You hit: " +instance1.done);
System.out.println("rockCrabs health: " + instance2.health);
instance1.health = instance1.health - instance2.done;
System.out.println("RockCrab hit: " +instance2.done);
System.out.println("rockCrabs health: " + instance1.health);
instance2.health = instance2.health - instance1.done;
System.out.println("You hit: " +instance1.done);
System.out.println("rockCrabs health: " + instance2.health);
instance1.health = instance1.health - instance2.done;
System.out.println("RockCrab hit: " +instance2.done);
System.out.println("rockCrabs health: " + instance1.health);
instance2.health = instance2.health - instance1.done;
System.out.println("You hit: " +instance1.done);
System.out.println("rockCrabs health: " + instance2.health);
instance1.health = instance1.health - instance2.done;
System.out.println("RockCrab hit: " +instance2.done);
System.out.println("rockCrabs health: " + instance1.health);
}when the code is run it says something like this:
you hit 1
RockCrabs health is 9
RockCrab hit 7
your health is 38
you hit 1
RockCrabs health is 8
RockCrab hit 7
your health is 31
you hit 1
RockCrabs health is 7
RockCrab hit 7
your health is 24
you hit 1
RockCrabs health is 6
RockCrab hit 7
your health is 17
my point is whatever some one hits it always repeats that
my expected output would have to be something like
you hit 1
RockCrabs health is 9
RockCrab hit 9
your health is 37
you hit 3
RockCrabs health is 6
RockCrab hit 4
your health is 33
you hit 2
RockCrabs health is 4
RockCrab hit 7
your health is 26
you hit 3
RockCrabs health is 1
RockCrab hit 6
your health is 20
Edited by: rade134 on Jun 4, 2009 10:58 AM[_Crosspost_|http://forums.sun.com/thread.jspa?threadID=5390217] I'm locking.
-
A rather odd and annoying problem has recently been occuring on my MBP. A couple days ago my remote (after working without fail for over a year now) suddenly stopped working. Yesterday night and this morning it started working again but after a while it stopped again. I've read dozens of support articles which haven't really helped because there seems to be another problem.
Most articles have stated that there is an option to disable the IR receiver in the "security" window under system preferences. When the IR and remote are not working this option disappears but when they are working the option is present. I have also tried replacing the battery without any result.
I am now thinking that it might have something to do with heat buildup because it is mainly occuring after the laptop has been on for about a half hour, so I am going to try to borrow someone's fan.
If anyone has any suggestions to solve this I would appreciate it if you could help. Thanks!
MacBook Pro 1.83 GHz Mac OS X (10.4.9)check out this thread. Seems to be the same problem.
http://discussions.apple.com/thread.jspa?messageID=4701905�
Maybe you are looking for
-
Error message while opening cs3
I cannot get my photoshop cs3 extended to fully open on my desktop. error message pops up saying photoshop has stopped working. the credits run though. and it looks as though it is going to open. then stops:) Any advice would be greatly appreciated!
-
Clicking an e-mail link in Safari doesn't open default mail client
Eudora has been my default mailer for many years. Yet after the last Safari update a few days ago, the browser suddenly ignores Eudora's default status although it is clearly checked in Eudora's preferences. Instead, Safari thinks Mail is my default
-
Online keyboard shortcuts documentation for Final Cut Pro 6
Hello, Does anyone know where to find a pdf or other doc or website for Final Cut Pro 6 keyboard shortcuts online? There's not one in the manual that I could find, actually (still getting acclimated from Avid days, I sure could use an extensive refer
-
XI Pipeline Services - questions
HI, sap documentation told me this pipeline. 1. receiver id. 2. interface id. 3. message split 4. request message mapping 5. technical routing 6. call adapter 7. request message mapping q1: why did they use the 7. request message mapping ? It´s in th
-
'th' is not supported language on AIR 15
we've an iOS app that supported several languages(en, ko, zh, th) but 'th' is not supported language on AIR 15 how can we support 'th'?