Results 1 to 2 of 2
  1. #1
    Godzilla is offline Member
    Join Date
    Jul 2007
    Posts
    3
    Rep Power
    0

    Default Rectangle expands with applet frame

    Hello,

    I've been trying to get this program to work that when I expand the applet frame the rectangle will expand with it. Any ideas on how I can fix it or any good sources worth reading. Thanks for any help.

    Java Code:
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import java.applet.Applet;
    
    
    import java.awt.*;
    
    
    public class blueRectangle extends Applet
    {
    
    	public void paint(Graphics g)
    
       {
        Graphics2D g2 = (Graphics2D)g;
    
    	Rectangle box = new Rectangle(0, 0, 200, 100);
    	g2.draw(box);
    
    	Color BLUE = new Color(0.0F, 0.0F, 1.0F);
    
    	g2.setColor(Color.blue);
    	g2.fill(box);
    
    }
    }

  2. #2
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    If this is an applet, you wont need this because applet sizes are not dynamic. You specify the size inside html files.

    If this was a jframe, i would suggest you to get the size of the frame, capture windowResized event, rescale the rectangle dimensions there and call repaint to redraw frame. But for applet i don't think there is a appletResized event. :)

Similar Threads

  1. Rectangle Intersection
    By Gwindow in forum Java 2D
    Replies: 1
    Last Post: 04-24-2008, 04:53 PM
  2. help with rectangle class
    By darkgt in forum New To Java
    Replies: 7
    Last Post: 11-14-2007, 07:19 PM
  3. Frame Query
    By Daniel in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 07:27 PM
  4. Web Services - IBM Expands SOA Management Practice
    By Felissa in forum Web Frameworks
    Replies: 0
    Last Post: 06-25-2007, 05:08 AM
  5. Rectangle with rounded edges??
    By orchid in forum Java 2D
    Replies: 1
    Last Post: 05-10-2007, 03:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •