Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java Applet Visibility & SuperImposing prob

  1. Apr 19, 2017 #1
    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 cant 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

    Code (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.
     
  2. jcsd
  3. Apr 20, 2017 #2

    jedishrfu

    Staff: Mentor

    You need to create another polygon object before adding the second set of points. You want two overlapping triangles right?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Applet Visibility & SuperImposing prob
  1. Java Applet Issues (Replies: 12)

  2. JTable not Visible (Replies: 2)

Loading...