The Artima Developer Community
Sponsored Link

Java Answers Forum
GridLayout used in program problem HELP!!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jenga

Posts: 3
Nickname: topazz
Registered: Jul, 2002

GridLayout used in program problem HELP!! Posted: Aug 19, 2002 3:26 PM
Reply to this message Reply
Advertisement
I need help with a question.

Write a program that places four fans in a fram of GridLayout with two rows and two columns. I have pasted code below which shows what the "fans" should look like. Thanks!!

// TestArcs.java: Demonstrate drawing 4 arcs ( red fanblades ), in blue circle
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Graphics;


public class TestArcs extends JFrame
{

public TestArcs()
{
setTitle("Exercise 8.13");
getContentPane().add(new ArcsPanel());
}


public static void main(String[] args)
{
TestArcs frame = new TestArcs();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(250, 300);
frame.setVisible(true);
}
}


class ArcsPanel extends JPanel
{

public void paintComponent(Graphics g)
{
super.paintComponent(g);

int xCenter = getWidth()/2;
int yCenter = getHeight()/2;
int radius =
(int)(Math.min(getSize().width, getSize().height)*0.4);

int x = xCenter - radius;
int y = yCenter - radius;


g.setColor(Color.blue);
g.drawOval(14, 32, 210, 210);


g.setColor(Color.red);
g.fillArc(x, y, 2*radius, 2*radius, 0, 30);
g.fillArc(x, y, 2*radius, 2*radius, 90, 30);
g.fillArc(x, y, 2*radius, 2*radius, 180, 30);
g.fillArc(x, y, 2*radius, 2*radius, 270, 30);
}
}

Topic: About Jasper Report Previous Topic   Next Topic Topic: Telnet

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use