Applet Visibility & SuperImposing prob

  • Java
  • Thread starter zak100
  • Start date
In summary, the conversation is about color problems when increasing the size of an applet and trying to superimpose objects on top of each other. The issue is demonstrated through a code example of overlapping red and green triangles. The solution is to create a separate polygon object for the second set of points.
  • #1
zak100
462
11
Hi,

I am getting color problems when I increase the size of applet & also when I try to superimpose one object on top of other. For instance, this triangle vanishes when I increase the size of applet to full screen.

GreenTriangleAppletVisible.jpg


I can't understand how to display the object when the applet is full screened.

Similarly I am getting the following output when I am drawing a Green applet over the red applet
superimpose Color Triangles prob.jpg


Java:
import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
import javax.imageio.ImageIO;
import java.io.*;

public class TwoEqTriColor extends Applet{
int ix1=30;
int iy1=30;
int ix2=120;
int iy2=30;
int ix1r=25;
int ix2r=120;
int iy1r=69;
int iy2r=5;
int ix3=75;
int iy3=107;
Polygon poly = new Polygon();
public  void paint(Graphics g) {
        g.setColor(Color.RED);
        poly.addPoint(ix1r,iy1r);
        poly.addPoint(ix2r,iy2r);
        poly.addPoint(ix3,iy3);
        g.fillPolygon(poly);

        g.setColor(Color.GREEN);
        poly.addPoint(ix1,iy1);
        poly.addPoint(ix2,iy2);
        poly.addPoint(ix3,iy3);
        g.fillPolygon(poly);             
    }
}

Somebody please guide me.

Zulfi.
 
Technology news on Phys.org
  • #2
You need to create another polygon object before adding the second set of points. You want two overlapping triangles right?
 

Related to Applet Visibility & SuperImposing prob

What is the purpose of applet visibility?

The purpose of applet visibility is to determine whether an applet is currently visible on the screen or hidden. This is important in order to optimize performance and conserve system resources.

How can I determine the visibility of an applet?

You can use the isVisible() method to determine if the applet is currently visible. This method returns a boolean value of true if the applet is visible and false if it is hidden.

How can I make an applet visible or hidden?

You can use the setVisible() method to make an applet visible or hidden. This method takes a boolean parameter, where true makes the applet visible and false hides it.

What is superimposing in relation to applets?

Superimposing in relation to applets refers to the ability to overlay one applet on top of another. This can be achieved by using the setLayer() method, which allows you to specify the z-index or stacking order of the applets.

Why is superimposing useful?

Superimposing is useful because it allows you to create more dynamic and interactive applets. By overlaying applets, you can create complex visual effects or combine different functionalities to enhance the user experience.

Similar threads

  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
4
Views
2K
Back
Top