How to Get a JApplet Into JPanel

When developing Java applications, it can be useful to have the ability to assign a JApplet to a specific JPanel. While a JApplet is a special class of applets, a JPanel is a container that is used to display media files. Assigning a JApplet to a JPanel allows you to manipulate the files displayed by the panel, in ways such as applying a rotation effect to a picture, or allowing the user to control video playback. You can assign a JApplet to a JPanel by editing the source code of your application.

Instructions

    • 1

      Open a text editor or your usual Java development kit. Windows users can use Notepad, a built-in text editor. Open the file that contains the source code of your application.

    • 2

      Add the following line of code to your application:

      y.add(JPanel label);

      As opposed to "x.add," which embeds the JApplet into a regular container, "y.add" automatically assigns a JApplet to a specific JPanel.

    • 3

      Replace "JPanel label" with the label you assigned to the JPanel.

    • 4

      Save your file.

Related Searches:

Comments

Related Ads

Featured