DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   Error warning using show() from java.awt.Window (http://www.daniweb.com/forums/thread102861.html)

Aia Dec 29th, 2007 5:34 pm
Error warning using show() from java.awt.Window
 
Self-teaching Java, I am following a video tutorial about simple windows.
Encountered a warning error using the example provided in the tutorial.

Here's the piece of code.
import java.awt.Frame;
import java.awt.Label;
import java.awt.AWTEvent;
import java.awt.event.WindowEvent;

public class HowdyByeWindow extends Frame {
        public static void main( String[] args ) {
                new HowdyWindow();
        }
        HowdyByeWindow() {
                Label label;
                label = new Label( "Howdy" );
                add( label );
                pack();
                show();
        }
        public void processWindowEvent( WindowEvent event ) {
                if ( event.getID() == WindowEvent.WINDOW_CLOSING )
                        System.exit( 0 );
        }
}

Here's the warning when compiled without flags:
C:\Programming\JavaProg\HowdyWindow>javac HowdyByeWindow.java
Note: HowdyByeWindow.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Followed the second note and compiled using -Xlint:deprecation:
C:\Programming\JavaProg\HowdyWindow>javac -Xlint:deprecation HowdyByeWindow.java

HowdyByeWindow.java:15: warning: [deprecation] show() in java.awt.Window has been deprecated
                show();
                ^
1 warning

What do I need to do about that warning? Can I substitute show() for something else?
Don't mind if you explain to me things like if "I were a dummy", since I'm barely getting acquaint with the language.

masijade Dec 29th, 2007 6:22 pm
Re: Error warning using show() from java.awt.Window
 
change from show() to setVisible(true) .... and find a better tutorial, that one's outdated.

darkagn Dec 29th, 2007 8:43 pm
Re: Error warning using show() from java.awt.Window
 
Quote:

Originally Posted by masijade (Post 500410)
change from show() to setVisible(true) .... and find a better tutorial, that one's outdated.

Masijade's right here - find a tutorial on swing rather than awt as the swing packages have mostly overtaken the functionality of the awt packages.

Aia Dec 29th, 2007 10:58 pm
Re: Error warning using show() from java.awt.Window
 
Thank you.


All times are GMT -4. The time now is 12:08 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC