| | |
Error warning using show() from java.awt.Window
Thread Solved
![]() |
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.
Here's the warning when compiled without flags:
Followed the second note and compiled using -Xlint:deprecation:
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.
Encountered a warning error using the example provided in the tutorial.
Here's the piece of code.
Java Syntax (Toggle Plain Text)
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:
Java Syntax (Toggle Plain Text)
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.
Last edited by Aia; Dec 29th, 2007 at 5:35 pm.
change from show() to setVisible(true) .... and find a better tutorial, that one's outdated.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. ![]() |
Other Threads in the Java Forum
- Previous Thread: Components
- Next Thread: isFixReg() ???
| Thread Tools | Search this Thread |
-xlint 911 actionlistener addball addressbook android applet application array automation binary blackberry block bluetooth button character class client code compile component consumer css csv database desktop developmenthelp eclipse ee error fractal ftp game gameprogramming givemetehcodez graphics gui html image j2me j2seprojects japplet java javaarraylist javac javaee javaprojects jni jpanel julia jvm lego linked linux loan mac method mobile netbeans notdisplaying number objects online oriented phone printf problem program programming project projects recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server service set singleton sms software sort sql string swing system test textfields threads time title tree tutorial-sample ubuntu update windows






