Answer» Hi friend, how are you? I am at basic level in Java. Today, I have just started to LEARN Creating Windows. I am using JCreater to create my Java Applications and it works very fine. I have JDK1.4. Today I wrote the following simple program.
import javax.swing.*; public class window { static JFrame AWINDOW=new JFrame("First Window"); public static void main(String args[]) { int a=400; int b=150; aWindow.setBounds(50,100,a,b); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.setVisible(true); } }
Now when I execute it, it display the window for just a moment and then MS DOS prompt comes with the text "Press any key to continue..." and that window disappears. What the prblem is? I shall be very thankfull to you? Okay take care of you and OTHERS and be happy. Bye... DeWWhat happens when you "press any key to continue..."?here try this...
Code: [SELECT]import javax.swing.*;
public class MyWindow {
static JFrame aWindow = new JFrame("First Window");
public static void main(String args[]) { int a=400; int b=150; aWindow.setBounds(50,100,a,b); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.setVisible(true); } }
you named your class window which is a keyword in java
|