Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8114353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:07:19+00:00 2026-06-06T03:07:19+00:00

The method show(); in class Windows for java.awt in deprecated. What can I use

  • 0

The method show(); in class Windows for java.awt in deprecated. What can I use instead?

package adventure;
import java.awt.*;

import java.awt.image.*;
import java.awt.event.*;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.*;
import java.applet.*;
// Infogar testkommentar mvh Holger 2012-06-20 kl 19.03
public class Adventure extends Frame  {
    private static final long serialVersionUID=100L;
    public Adventure() {        
    setSize(850, 440);    
    World world = new DungeonWorld ( this );        

    Person me = new Person( world, "You", null );    
    show();
    me.goTo("Dungeon");     
    add( new Player( world, me ) );    
    addWindowListener(new MyWindowAdapter ());    
    }

    class MyWindowAdapter extends WindowAdapter {

    public void windowClosing (WindowEvent e) {
        System.exit(0);
    }
    }


    // Load an image from the net, making sure it has already been
    // loaded when the method returns
    public Image loadPicture ( String imageName ) {
    Image im = null;

    // Load the image from the net
    try {
        URL imageSource = new URL( "http://www...xxx/"
                       + imageName );

        try {
        im = createImage( (ImageProducer) imageSource.getContent());
        } catch (IOException e) {}

    } catch (MalformedURLException e ) { }

    // Wait to ensure that the image is loaded
    MediaTracker imageTracker = new MediaTracker( this );
    imageTracker.addImage( im, 0 );
    try {
        imageTracker.waitForID( 0 );
    }
    catch( InterruptedException e ) { }

    return im;
    }


    // Load and play a sound from /usr/local/hacks/sounds/

    public void playSound (String name) {
    URL u = null;

    try {
        u = new URL("file:" +  "/usr/local/hacks/sounds/" + name + ".au");
    } catch (MalformedURLException e ) { }

    AudioClip a = Applet.newAudioClip(u);
    a.play();
    }

    public static void main (String[] args) {       
    System.out.println("test"); 
      new Adventure();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T03:07:20+00:00Added an answer on June 6, 2026 at 3:07 am

    Let’s read the Java API for Window#show(): here

    @Deprecated
    public void show()
    

    Deprecated. As of JDK version 1.5, replaced by setVisible(boolean).

    Makes the Window visible. If the Window and/or its owner are not yet
    displayable, both are made displayable. The Window will be validated
    prior to being made visible. If the Window is already visible, this
    will bring the Window to the front.

    So you should use Window#setVisible(boolean) – for show() use setVisible(true).

    EDIT

    In some environments just replacing show() with setVisible(true) changes the behavior of the application. This happens, when you wrote a subclass of Window that overrides show() (same for hide()).

    So in your code example setVisible(true) does exactly the same as show(). But in general, just be certain, that no one overrides show() which wouldn’t be executed anymore when using setVisible(true). In such a case, you have to change the overriden methods, too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

actually i use this method to show similar words for a search request.. $query
When i use one jpeg image with this web-server its very slow to show
I'm writing a method for the Java Helper Library to show a windowless swing
i use the command line in windows to compile and then execute my java
I'm writing ADO.NET provider. For debugging I use class DbProviderFactories.GetFactory method. This method constructs
Just using the paint method and my image won't show up initially. Once I
Please see the following block of code import java.awt.Color; import java.awt.Dimension; import javax.swing.JFrame; import
I want to use WPF windows in future applications instead of Windows forms. The
I request @me , but requestDidLoadWithError method show this error. An active access token
I want to have the following method not show a warning about using raw

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.