This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes help with a class. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "help with a class." Watch "help with a class." New topic
Author

help with a class.

kotoisin
Greenhorn

Joined: Nov 08, 2004
Posts: 5
I am a beginner in Java, and I am trying to make an exercise, where I am to make a class, -CoffeMug, which implements the interface Icon.
The class draws an Image of a CoffeeMug and fills it, by drawing and filling shapes.

import javax.swing.Icon;
import java.awt*;

public class CoffeeMug implements Icon
{
//constructs a coffeemug
private int width;
private int height;
private Color color;

public CoffeMug(int w, int h) {
width = w;
height = h;
color = Color.BLUE;
}
public int getIconWidth()
{
return width;
}

public int getIconHeight()
{
return width;
}

public void paintIcon(Component c, Graphics g, int x, int y)
{
Graphics2D g2 = (Graphics2D) g;
g2.setColor( color );
g2.fill( CoffeeMug );
}
}
I know it is SO wrong... But anyone have some advice for me?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: help with a class.
 
Similar Threads
advice on drawing a square wave pulse train
Wanted: Java2D example of zooming and panning with scroll bars
How do I change color on an Icon?
Creating an image and Drawing to it.
Add image to JPanel