wood burning stoves 2.0*
The moose likes Java in General and the fly likes whts wrong with this code. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "whts wrong with this code." Watch "whts wrong with this code." New topic
Author

whts wrong with this code.

Dinesh Jayaraj
Greenhorn

Joined: Nov 19, 2000
Posts: 23
hello everybody:
here is a simple program i have written to create a frme. this pgm compiles successfully without any errors
but when i run the pgm(using command:java filename)it gives the error dialog given below
java
this program has performed an illegal operation and will be
shutdown.
if the problem persists, contact the program vendor.
but when the same program run on the other system
where same jdk1.3 has been installed it runs nicely without
giving any dialog like this.
due to this problem iam not able to create any frame or
applet,and swing programs on my systems please
anybody find out the problem and tell the solution.
thanks in advance
dinesh

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FrameDemo {
public static void main(String s[]) {
JFrame frame = new JFrame("FrameDemo");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
JLabel emptyLabel = new JLabel("");
emptyLabel.setPreferredSize(new Dimension(175, 100));
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
}
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
What environment are you trying to run the application in? If you calling "java app" from a command line in an environment that doesn't have a Graphics environment you won't be able to create a Frame (because it does have a native 'peer' to refer to). Perhaps a few more details in this area could help us figure the problem out.
Sean
Ashwin Desai
Ranch Hand

Joined: Jul 17, 2000
Posts: 124
Hi,
It looks like the Java VM is doing an illegal operation. This would mean either incorrect installation. Try Re-installing Java 1.3. I assume (based on the CRYPTIC error message) that you are using a Windows system, thus, there would be no problems with the GraphicsEnvironment.
Ashwin.
PS: Its running fine on my PC.
 
jQuery in Action, 2nd edition
 
subject: whts wrong with this code.
 
Similar Threads
JFrame Title not displayed (hp unix)
Doubt in this Swing program. can anyone clear my doubt?
why this error dialog comes(everybody please see once)
plese help urgently(why this error dialog comes?)
why use static method in creating gui