943,948 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 12588
  • Java RSS
Dec 29th, 2007
0

Error warning using show() from java.awt.Window

Expand Post »
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.
Java Syntax (Toggle Plain Text)
  1. import java.awt.Frame;
  2. import java.awt.Label;
  3. import java.awt.AWTEvent;
  4. import java.awt.event.WindowEvent;
  5.  
  6. public class HowdyByeWindow extends Frame {
  7. public static void main( String[] args ) {
  8. new HowdyWindow();
  9. }
  10. HowdyByeWindow() {
  11. Label label;
  12. label = new Label( "Howdy" );
  13. add( label );
  14. pack();
  15. show();
  16. }
  17. public void processWindowEvent( WindowEvent event ) {
  18. if ( event.getID() == WindowEvent.WINDOW_CLOSING )
  19. System.exit( 0 );
  20. }
  21. }

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)
  1. C:\Programming\JavaProg\HowdyWindow>javac -Xlint:deprecation HowdyByeWindow.java
  2.  
  3. HowdyByeWindow.java:15: warning: [deprecation] show() in java.awt.Window has been deprecated
  4. show();
  5. ^
  6. 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.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Dec 29th, 2007
2

Re: Error warning using show() from java.awt.Window

change from show() to setVisible(true) .... and find a better tutorial, that one's outdated.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Dec 29th, 2007
0

Re: Error warning using show() from java.awt.Window

Click to Expand / Collapse  Quote originally posted by masijade ...
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.
Reputation Points: 395
Solved Threads: 192
Veteran Poster
darkagn is offline Offline
1,136 posts
since Aug 2007
Dec 29th, 2007
0

Re: Error warning using show() from java.awt.Window

Thank you.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Jun 29th, 2011
0
Re: Error warning using show() from java.awt.Window
Thank you!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
way23 is offline Offline
1 posts
since Jun 2011

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: JAVA Login Form
Next Thread in Java Forum Timeline: java error help: java.lang.VerifyError





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC