Applet Visibility & SuperImposing prob

  • Context: Java 
  • Thread starter Thread starter zak100
  • Start date Start date
Click For Summary
SUMMARY

The discussion focuses on color rendering issues in Java Applets when resizing and superimposing graphical objects. The user experiences a problem where a triangle disappears upon maximizing the applet size and encounters overlapping color issues when drawing a green triangle over a red one. The solution provided emphasizes the need to create separate polygon objects for each triangle to ensure proper rendering and visibility in the applet.

PREREQUISITES
  • Understanding of Java Applet programming
  • Familiarity with AWT and Graphics classes
  • Knowledge of polygon rendering in Java
  • Basic concepts of color management in graphics
NEXT STEPS
  • Learn about creating and managing multiple Polygon objects in Java
  • Explore Java AWT's paint method for custom rendering
  • Investigate color blending techniques in Java graphics
  • Study Java Applet lifecycle and resizing behavior
USEFUL FOR

Java developers, particularly those working with graphical user interfaces and applet programming, will benefit from this discussion, especially when dealing with rendering issues and object visibility in graphical applications.

zak100
Messages
462
Reaction score
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
You need to create another polygon object before adding the second set of points. You want two overlapping triangles right?
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
848
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
8
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K